45 lines
971 B
GDScript
45 lines
971 B
GDScript
extends Item
|
|
class_name Fork
|
|
|
|
const USE_INTERVAL = 0.15
|
|
|
|
func get_item_name() -> String:
|
|
return tr("FORK")
|
|
|
|
func get_description() -> String:
|
|
return tr("FORK_DESC_TEXT")
|
|
|
|
func get_icon() -> Texture2D:
|
|
return preload("res://common/icons/fork.svg")
|
|
|
|
func get_energy_used() -> int:
|
|
return 1
|
|
|
|
func get_usage_zone_radius() -> int:
|
|
return 50
|
|
|
|
func get_usage_object_affected(i : InspectableEntity) -> bool:
|
|
return i is Plant
|
|
|
|
func use_text() -> String:
|
|
return tr("HARVEST")
|
|
|
|
func can_use(_player : Player, zone : Player.ActionZone) -> bool:
|
|
var areas = zone.get_affected_areas()
|
|
for area in areas :
|
|
if area is Plant:
|
|
return true
|
|
return false
|
|
|
|
func use(player : Player, zone : Player.ActionZone) -> bool:
|
|
for area in zone.get_affected_areas():
|
|
if area and area is Plant:
|
|
harvest(area, player)
|
|
await player.get_tree().create_timer(USE_INTERVAL).timeout
|
|
|
|
return true
|
|
|
|
func harvest(p : Plant, player: Player):
|
|
AudioManager.play_sfx("Harvest")
|
|
p.harvest()
|