#39 ajout d'un compost plus des ajouts mineurs de qualité de vie
This commit is contained in:
34
entities/interactables/compost/scripts/compost.gd
Normal file
34
entities/interactables/compost/scripts/compost.gd
Normal file
@@ -0,0 +1,34 @@
|
||||
extends Interactable
|
||||
class_name Compost
|
||||
|
||||
|
||||
@export var value_per_seed : float = 0.5
|
||||
|
||||
var fill_value : float = 0.
|
||||
|
||||
func _process(_delta):
|
||||
%ProgressBar.value = lerp(%ProgressBar.value, fill_value * 100, 0.5)
|
||||
|
||||
func _ready():
|
||||
fill_value = 0.
|
||||
|
||||
func can_interact(p : Player) -> bool:
|
||||
return p.inventory.get_item() and p.inventory.get_item() is Seed
|
||||
|
||||
func requirement_text() -> String:
|
||||
return "You must have a seed in hand"
|
||||
|
||||
func interact(p : Player) -> bool:
|
||||
if not can_interact(p):
|
||||
return false
|
||||
|
||||
p.delete_item()
|
||||
fill_value += value_per_seed
|
||||
if fill_value >= 1.:
|
||||
$AnimationPlayer.play("empty")
|
||||
fill_value = 0
|
||||
p.upgrade()
|
||||
value_per_seed /= 1.5
|
||||
else:
|
||||
$AnimationPlayer.play("fill")
|
||||
return true
|
||||
1
entities/interactables/compost/scripts/compost.gd.uid
Normal file
1
entities/interactables/compost/scripts/compost.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://dw6jgsasb2fe1
|
||||
Reference in New Issue
Block a user