seeding-planets/common/inventory/scripts/items/seed.gd

38 lines
889 B
GDScript

extends Item
class_name Seed
@export var plant_type: PlantType
func get_item_name() -> String:
return plant_type.name
func get_description() -> String:
return plant_type.description
func get_icon() -> Texture2D:
return plant_type.seed_texture
func get_energy_used() -> int:
return 1
func _init(_plant_type : PlantType = null):
plant_type = _plant_type
func use_text() -> String:
return "Plant " + plant_type.name
func is_one_time_use():
return true
func can_use(player : Player, zone : Area2D) -> bool:
var is_there_a_plant_here = false
for area in zone.get_overlapping_areas() :
if area is Plant:
is_there_a_plant_here = true
return not is_there_a_plant_here and not player.planet.is_there_contamination(zone.global_position)
func use(player : Player, zone : Area2D) -> bool:
player.play_sfx("dig")
return player.planet.plant(plant_type, zone.global_position)