28 lines
651 B
GDScript
28 lines
651 B
GDScript
@tool
|
|
extends Item
|
|
class_name Seed
|
|
|
|
@export var plant_type: PlantType :
|
|
set(v):
|
|
plant_type = v
|
|
if plant_type:
|
|
name = plant_type.name
|
|
description = plant_type.description
|
|
icon = plant_type.seed_texture
|
|
|
|
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:
|
|
return 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)
|