gros dev pre proto
* Changement de l'UI, ajouts de l'inspecteur par carte et changement de police * Ajout d'un semblant d'exploration * Ajout de la sauvegarde des entités * Restructuration mineure de l'arborescence * Fix divers et réécriture des textes
This commit is contained in:
42
entities/player/inventory/scripts/items/blueprint.gd
Normal file
42
entities/player/inventory/scripts/items/blueprint.gd
Normal file
@@ -0,0 +1,42 @@
|
||||
extends Item
|
||||
class_name Blueprint
|
||||
|
||||
@export var machine_type: MachineType
|
||||
@export var machine_level: int = 1
|
||||
|
||||
func _init(_machine_type : MachineType = null, _machine_level : int = 1):
|
||||
machine_type = _machine_type
|
||||
machine_level = _machine_level
|
||||
|
||||
func get_item_name() -> String:
|
||||
if machine_type:
|
||||
return machine_type.name
|
||||
return ""
|
||||
|
||||
func get_description() -> String:
|
||||
if machine_type:
|
||||
return machine_type.description
|
||||
return ""
|
||||
|
||||
func get_icon() -> Texture2D:
|
||||
return preload("res://common/icons/cube-3d-sphere.svg")
|
||||
|
||||
func use_text() -> String:
|
||||
if machine_type:
|
||||
return "Build " + machine_type.name
|
||||
return ""
|
||||
|
||||
func is_one_time_use():
|
||||
return true
|
||||
|
||||
func can_use(player : Player, zone : Player.ActionZone) -> bool:
|
||||
return player.terrain is Planet
|
||||
|
||||
func use(player : Player, zone : Player.ActionZone) -> bool:
|
||||
if machine_type and machine_level and player.planet:
|
||||
player.planet.add_entity(
|
||||
Machine.instantiate_machine(machine_type, machine_level),
|
||||
zone.get_global_position()
|
||||
)
|
||||
return true
|
||||
return false
|
||||
1
entities/player/inventory/scripts/items/blueprint.gd.uid
Normal file
1
entities/player/inventory/scripts/items/blueprint.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://dcowcvjk2m7va
|
||||
44
entities/player/inventory/scripts/items/fork.gd
Normal file
44
entities/player/inventory/scripts/items/fork.gd
Normal file
@@ -0,0 +1,44 @@
|
||||
extends Item
|
||||
class_name Fork
|
||||
|
||||
const USE_INTERVAL = 0.15
|
||||
|
||||
func get_item_name() -> String:
|
||||
return "Fork"
|
||||
|
||||
func get_description() -> String:
|
||||
return "Use it to harvest mature plants."
|
||||
|
||||
func get_icon() -> Texture2D:
|
||||
return preload("res://common/icons/fork.svg")
|
||||
|
||||
func get_energy_used() -> int:
|
||||
return 1
|
||||
|
||||
func get_usage_zone_radius() -> int:
|
||||
return 50
|
||||
|
||||
func get_usage_object_affected(i : InspectableEntity) -> bool:
|
||||
return i is Plant
|
||||
|
||||
func use_text() -> String:
|
||||
return "Harvest"
|
||||
|
||||
func can_use(_player : Player, zone : Player.ActionZone) -> bool:
|
||||
var areas = zone.get_affected_areas()
|
||||
for area in areas :
|
||||
if area is Plant:
|
||||
return true
|
||||
return false
|
||||
|
||||
func use(player : Player, zone : Player.ActionZone) -> bool:
|
||||
for area in zone.get_affected_areas():
|
||||
if area and area is Plant:
|
||||
harvest(area, player)
|
||||
await player.get_tree().create_timer(USE_INTERVAL).timeout
|
||||
|
||||
return true
|
||||
|
||||
func harvest(p : Plant, player: Player):
|
||||
player.play_sfx("harvest")
|
||||
p.harvest()
|
||||
1
entities/player/inventory/scripts/items/fork.gd.uid
Normal file
1
entities/player/inventory/scripts/items/fork.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://cg5to3g2bqyks
|
||||
19
entities/player/inventory/scripts/items/knife.gd
Normal file
19
entities/player/inventory/scripts/items/knife.gd
Normal file
@@ -0,0 +1,19 @@
|
||||
extends Fork
|
||||
class_name Knife
|
||||
|
||||
const KNIFE_ZONE_RADIUS = 10
|
||||
|
||||
func get_item_name() -> String:
|
||||
return "Knife"
|
||||
|
||||
func get_description() -> String:
|
||||
return "Use it to harvest mature plants. Do not cost energy."
|
||||
|
||||
func get_energy_used() -> int:
|
||||
return 0
|
||||
|
||||
func get_icon() -> Texture2D:
|
||||
return preload("res://common/icons/slice.svg")
|
||||
|
||||
func get_usage_zone_radius() -> int:
|
||||
return KNIFE_ZONE_RADIUS
|
||||
1
entities/player/inventory/scripts/items/knife.gd.uid
Normal file
1
entities/player/inventory/scripts/items/knife.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://clyixfqc8rmo
|
||||
32
entities/player/inventory/scripts/items/package.gd
Normal file
32
entities/player/inventory/scripts/items/package.gd
Normal file
@@ -0,0 +1,32 @@
|
||||
extends Item
|
||||
class_name Package
|
||||
|
||||
@export var scene: PackedScene
|
||||
@export var package_name : String
|
||||
@export_multiline var package_description : String
|
||||
|
||||
|
||||
func _init(_scene : PackedScene = null):
|
||||
scene = _scene
|
||||
|
||||
func get_item_name() -> String:
|
||||
return package_name
|
||||
|
||||
func get_description() -> String:
|
||||
return package_description
|
||||
|
||||
func get_icon() -> Texture2D:
|
||||
return preload("res://common/icons/package.svg")
|
||||
|
||||
func use_text() -> String:
|
||||
return "Open"
|
||||
|
||||
func is_one_time_use():
|
||||
return true
|
||||
|
||||
func can_use(player : Player, zone : Player.ActionZone) -> bool:
|
||||
return player.planet != null
|
||||
|
||||
func use(player : Player, zone : Player.ActionZone) -> bool:
|
||||
player.planet.instantiate_entity(scene, zone.get_global_position())
|
||||
return true
|
||||
1
entities/player/inventory/scripts/items/package.gd.uid
Normal file
1
entities/player/inventory/scripts/items/package.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://b6kubqgq0k7vj
|
||||
194
entities/player/inventory/scripts/items/seed.gd
Normal file
194
entities/player/inventory/scripts/items/seed.gd
Normal file
@@ -0,0 +1,194 @@
|
||||
extends Item
|
||||
class_name Seed
|
||||
|
||||
const MUTATION_PROBABILITY = 0.3
|
||||
|
||||
const SHOVEL_ICON = preload("res://common/icons/shovel.svg")
|
||||
const GROWING_ICON = preload("res://common/icons/chevrons-up.svg")
|
||||
const SCORE_ICON = preload("res://common/icons/growth.svg")
|
||||
|
||||
@export var plant_type: PlantType
|
||||
@export var plant_mutations: Array[PlantMutation]
|
||||
|
||||
func get_item_name() -> String:
|
||||
return "%s Seed" % plant_type.name
|
||||
|
||||
func get_description() -> String:
|
||||
return "Plant [b]%s[/b]. Must be used in decontamined zone." % plant_type.name
|
||||
|
||||
func get_icon() -> Texture2D:
|
||||
return plant_type.seed_texture
|
||||
|
||||
func get_energy_used() -> int:
|
||||
return 1
|
||||
|
||||
func get_usage_zone_radius() -> int:
|
||||
return 30
|
||||
|
||||
func get_usage_object_affected(i : InspectableEntity) -> bool:
|
||||
return i is Plant
|
||||
|
||||
func _init(
|
||||
_plant_type : PlantType = null,
|
||||
_parent_mutation : Array[PlantMutation] = []
|
||||
):
|
||||
plant_type = _plant_type
|
||||
plant_mutations = Seed.mutate(_parent_mutation)
|
||||
|
||||
func use_text() -> String:
|
||||
return "Plant " + plant_type.name
|
||||
|
||||
func is_one_time_use():
|
||||
return true
|
||||
|
||||
func can_use(player : Player, zone : Player.ActionZone) -> bool:
|
||||
if (
|
||||
player.planet == null
|
||||
or not player.planet.garden.is_in_garden(zone.get_global_position())
|
||||
):
|
||||
return false
|
||||
|
||||
var is_there_a_plant_here = false
|
||||
for area in zone.get_affected_areas():
|
||||
if area is Plant:
|
||||
is_there_a_plant_here = true
|
||||
|
||||
var is_there_contamination_in_zone = false
|
||||
for point in zone.get_points_in_zone():
|
||||
if player.planet.garden.is_there_contamination(point):
|
||||
is_there_contamination_in_zone = true
|
||||
|
||||
return not is_there_a_plant_here and not is_there_contamination_in_zone
|
||||
|
||||
func use(player : Player, zone : Player.ActionZone) -> bool:
|
||||
if player.planet == null:
|
||||
return false
|
||||
|
||||
player.play_sfx("dig")
|
||||
return player.planet.plant(
|
||||
plant_type,
|
||||
zone.get_global_position(),
|
||||
plant_mutations
|
||||
)
|
||||
|
||||
func card_info() -> CardInfo:
|
||||
var info = CardInfo.new(
|
||||
get_item_name()
|
||||
)
|
||||
info.texture = icon
|
||||
info.type_icon = TYPE_ICON
|
||||
|
||||
info.stats.append(
|
||||
CardStatInfo.new(
|
||||
"Cost %d energy" % energy_usage,
|
||||
ENERGY_ICON
|
||||
)
|
||||
)
|
||||
|
||||
if is_one_time_use():
|
||||
info.stats.append(
|
||||
CardStatInfo.new(
|
||||
"One time use",
|
||||
ONE_TIME_ICON
|
||||
)
|
||||
)
|
||||
|
||||
var effect_section = CardSectionInfo.new(
|
||||
"Effect",
|
||||
get_description()
|
||||
)
|
||||
effect_section.title_icon = ACTION_ICON
|
||||
|
||||
if energy_usage > 0:
|
||||
effect_section.title_icon = ENERGY_ICON
|
||||
|
||||
info.sections.append(effect_section)
|
||||
|
||||
if len(plant_mutations) != 0:
|
||||
var rarest : int = plant_mutations.map(
|
||||
func(m : PlantMutation) : return m.get_rarity()
|
||||
).max()
|
||||
info.bg_color = PlantMutation.get_rarity_color(rarest)
|
||||
for m in plant_mutations:
|
||||
info.sections.append(m.card_section())
|
||||
|
||||
return info
|
||||
|
||||
|
||||
func get_particles() -> Array[Particles.Parameters]:
|
||||
var param : Array[Particles.Parameters] = []
|
||||
|
||||
for m in plant_mutations:
|
||||
param.append(
|
||||
Particles.Parameters.new(
|
||||
m.get_icon(),
|
||||
PlantMutation.get_rarity_color(m.get_rarity())
|
||||
)
|
||||
)
|
||||
|
||||
return param
|
||||
|
||||
static func mutate(parent_mutation : Array[PlantMutation] = []) -> Array[PlantMutation]:
|
||||
|
||||
if randf() > MUTATION_PROBABILITY:
|
||||
return parent_mutation
|
||||
|
||||
var possible_mutations : Array[MutationPossibility] = [
|
||||
AddMutation.new()
|
||||
]
|
||||
|
||||
if len(parent_mutation):
|
||||
possible_mutations.append_array( [
|
||||
UpgradeMutation.new(),
|
||||
RemoveMutation.new(),
|
||||
])
|
||||
|
||||
var chosen_mutation = possible_mutations.pick_random()
|
||||
|
||||
return chosen_mutation.mutate(parent_mutation)
|
||||
|
||||
|
||||
class MutationPossibility:
|
||||
func mutate(_parent_mutation : Array[PlantMutation] = [])-> Array[PlantMutation]:
|
||||
return []
|
||||
|
||||
class DontMutate extends MutationPossibility:
|
||||
func mutate(parent_mutation : Array[PlantMutation] = [])-> Array[PlantMutation]:
|
||||
return parent_mutation
|
||||
|
||||
class AddMutation extends MutationPossibility:
|
||||
func mutate(parent_mutation : Array[PlantMutation] = [])-> Array[PlantMutation]:
|
||||
var new_mutations = parent_mutation.duplicate_deep()
|
||||
var mut = PlantMutation.random_mutation()
|
||||
|
||||
if mut:
|
||||
var existing_mut_id = new_mutations.find_custom(func(m:PlantMutation): m.get_mutation_name() == mut.get_mutation_name())
|
||||
|
||||
if existing_mut_id >= 0:
|
||||
new_mutations[existing_mut_id].level += 1
|
||||
else :
|
||||
new_mutations.append(mut)
|
||||
|
||||
return new_mutations
|
||||
|
||||
class UpgradeMutation extends MutationPossibility:
|
||||
func mutate(
|
||||
parent_mutation : Array[PlantMutation] = []
|
||||
) -> Array[PlantMutation]:
|
||||
var new_mutations = parent_mutation.duplicate_deep()
|
||||
|
||||
new_mutations.pick_random().level += 1
|
||||
|
||||
return new_mutations
|
||||
|
||||
class RemoveMutation extends MutationPossibility:
|
||||
func mutate(parent_mutation : Array[PlantMutation] = [])-> Array[PlantMutation]:
|
||||
var new_mutations :Array[PlantMutation] = parent_mutation.duplicate_deep()
|
||||
|
||||
var mut_to_remove = new_mutations.pick_random()
|
||||
if mut_to_remove.level > 1:
|
||||
mut_to_remove.level -= 1
|
||||
else:
|
||||
new_mutations.remove_at(new_mutations.find(mut_to_remove))
|
||||
|
||||
return new_mutations
|
||||
1
entities/player/inventory/scripts/items/seed.gd.uid
Normal file
1
entities/player/inventory/scripts/items/seed.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://bypjcvlc15gsm
|
||||
44
entities/player/inventory/scripts/items/shovel.gd
Normal file
44
entities/player/inventory/scripts/items/shovel.gd
Normal file
@@ -0,0 +1,44 @@
|
||||
extends Fork
|
||||
class_name Shovel
|
||||
|
||||
const SHOVEL_ZONE_RADIUS = 50
|
||||
|
||||
func get_item_name() -> String:
|
||||
return "Shovel"
|
||||
|
||||
func get_description() -> String:
|
||||
return "Can dig up buried seeds and can be used to harvest mature plants."
|
||||
|
||||
func get_icon() -> Texture2D:
|
||||
return preload("res://common/icons/shovel.svg")
|
||||
|
||||
func get_usage_zone_radius() -> int:
|
||||
return SHOVEL_ZONE_RADIUS
|
||||
|
||||
func get_usage_object_affected(i : InspectableEntity) -> bool:
|
||||
return i is Plant or i is UndergroundLoot
|
||||
|
||||
func use_text() -> String:
|
||||
return "Dig"
|
||||
|
||||
func can_use(_player : Player, zone : Player.ActionZone) -> bool:
|
||||
var areas = zone.get_affected_areas()
|
||||
for area in areas :
|
||||
if area is Plant or area is UndergroundLoot:
|
||||
return true
|
||||
return false
|
||||
|
||||
func use(player : Player, zone : Player.ActionZone) -> bool:
|
||||
for area in zone.get_affected_areas():
|
||||
if area and area is Plant:
|
||||
harvest(area, player)
|
||||
await player.get_tree().create_timer(USE_INTERVAL).timeout
|
||||
if area and area is UndergroundLoot:
|
||||
dig(area, player)
|
||||
await player.get_tree().create_timer(USE_INTERVAL).timeout
|
||||
|
||||
return true
|
||||
|
||||
func dig(u: UndergroundLoot, player: Player):
|
||||
player.play_sfx("dig")
|
||||
u.dig()
|
||||
1
entities/player/inventory/scripts/items/shovel.gd.uid
Normal file
1
entities/player/inventory/scripts/items/shovel.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://dya38x1h1uiyg
|
||||
21
entities/player/inventory/scripts/items/trowel.gd
Normal file
21
entities/player/inventory/scripts/items/trowel.gd
Normal file
@@ -0,0 +1,21 @@
|
||||
extends Fork
|
||||
class_name Trowel
|
||||
|
||||
const TROWEL_ZONE_RADIUS = 50
|
||||
|
||||
func get_item_name() -> String:
|
||||
return "Trowel"
|
||||
|
||||
func get_description() -> String:
|
||||
return "Use it to harvest mature plants, can get a [b]bonus seed[/b] from each plant."
|
||||
|
||||
func get_icon() -> Texture2D:
|
||||
return preload("res://common/icons/trowel.svg")
|
||||
|
||||
func get_usage_zone_radius() -> int:
|
||||
return TROWEL_ZONE_RADIUS
|
||||
|
||||
func harvest(p : Plant, player: Player):
|
||||
ProduceSeedsEffect.new(1).effect(p)
|
||||
player.play_sfx("harvest")
|
||||
p.harvest()
|
||||
1
entities/player/inventory/scripts/items/trowel.gd.uid
Normal file
1
entities/player/inventory/scripts/items/trowel.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://gvq5vic12srt
|
||||
Reference in New Issue
Block a user