36 lines
800 B
GDScript
36 lines
800 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 generate_action_area(player : Player) -> ActionArea:
|
|
return ActionArea.new(
|
|
player,
|
|
10
|
|
)
|
|
|
|
func use_text(_player) -> String:
|
|
return "Plant " + plant_type.name
|
|
|
|
func is_one_time_use():
|
|
return true
|
|
|
|
func can_use(player : Player) -> bool:
|
|
return not player.planet.is_there_contamination(player.action_area.global_position)
|
|
|
|
func use(player : Player) -> bool:
|
|
if not can_use(player):
|
|
return false
|
|
player.play_sfx("dig")
|
|
return player.planet.plant(plant_type, player.action_area.global_position)
|