26 lines
582 B
GDScript
26 lines
582 B
GDScript
@tool
|
|
extends Item
|
|
class_name SeedItem
|
|
|
|
@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 is_one_time_use():
|
|
return true
|
|
|
|
func can_use(player : Player) -> bool:
|
|
return not player.planet.is_there_contamination(player.global_position)
|
|
|
|
func use(player : Player) -> bool:
|
|
if not can_use(player):
|
|
return false
|
|
return player.planet.plant(plant_type, player.global_position)
|