seeding-planets/common/inventory/scripts/items/blueprint.gd
Zacharie Guet d90d4c5df6 ajout du camion #87
* changements des objectifs, donnent juste des graines, sprite moins gros et objectifs plus nombreux
* changement de la probabilité de mutation
* refactor du code terrain et planet
2025-10-12 19:59:53 +02:00

40 lines
1.0 KiB
GDScript

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 + " level " + str(machine_level)
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.planet && player.planet.is_in_base(zone.get_global_position())
func use(player : Player, zone : Player.ActionZone) -> bool:
if machine_type and machine_level and player.planet:
player.planet.instantiate_machine(machine_type, machine_level, zone.get_global_position())
return true
return false