seeding-planets/entities/interactables/truck/compost/scripts/compost.gd
Zacharie Guet ed7a8bcb6e gros dev pre proto
* Changement de l'UI, ajouts de l'inspecteur par carte et changement de police
* Ajout d'un semblant d'exploration
* Ajout de la sauvegarde des entités
* Restructuration mineure de l'arborescence
* Fix divers et réécriture des textes
2025-10-31 13:52:45 +01:00

72 lines
1.4 KiB
GDScript

extends Interactable
class_name Compost
const FILLED_ICON = preload("res://common/icons/bucket.svg")
signal filled(c : Compost)
signal rewarded(c : Compost)
var reward : Reward = null :
set(r):
reward = r
update_info()
var containing_seed : int = 0 :
set(c):
containing_seed = c
update_info()
func _ready():
update_info()
func update_info():
%Count.text = "" if reward == null else "%d/%d" % [containing_seed, reward.get_seed_needed()]
%Icon.texture = null if reward == null else reward.icon()
func can_interact(p : Player) -> bool:
return reward and p.data.inventory.get_item() and p.data.inventory.get_item() is Seed
func interact(p : Player) -> bool:
if not can_interact(p):
return false
p.play_sfx("harvest")
p.data.inventory.remove_current_item()
containing_seed += 1
if containing_seed >= reward.get_seed_needed():
containing_seed = 0
reward.reward(p)
rewarded.emit(self)
%AnimationPlayer.play("bump")
filled.emit(self)
return true
func card_info() -> CardInfo:
var info = CardInfo.new(
pointer_text()
)
if default_info_desc != "":
var desc_section = CardSectionInfo.new(
"Description",
default_info_desc
)
desc_section.title_icon = DESC_ICON
info.sections.append(
desc_section
)
var reward_section = CardSectionInfo.new(
"When filled",
reward.desc()
)
reward_section.title_icon = FILLED_ICON
info.sections.append(reward_section)
return info
func product(_player : Player):
pass