#39 ajout d'un compost plus des ajouts mineurs de qualité de vie

This commit is contained in:
2025-08-20 15:41:27 +02:00
parent 219e8258e7
commit 2f0c5a2be4
15 changed files with 454 additions and 17 deletions

View File

@@ -3,6 +3,7 @@ class_name Player
signal player_updated(player: Player)
signal action_tried_without_energy
signal upgraded
var planet : Planet # mis à jour par la classe Planet
@export var speed = 400
@@ -28,6 +29,12 @@ var can_use_item : bool = false :
can_use_item = v
if old != can_use_item:
player_updated.emit(self)
var can_interact : bool = false :
set(v):
var old = can_interact
can_interact = v
if old != can_interact:
player_updated.emit(self)
var energy : int = max_energy :
set(v):
energy = v
@@ -47,11 +54,12 @@ func get_input():
calculate_direction()
can_use_item = inventory.get_item() and inventory.get_item().can_use(self)
can_interact = closest_interactable and closest_interactable.can_interact(self)
if action_area:
action_area.activated = can_use_item
if Input.is_action_just_pressed("action"):
try_use_item()
if Input.is_action_just_pressed("interact") and closest_interactable:
if Input.is_action_just_pressed("interact") and closest_interactable and can_interact:
closest_interactable.interact(self)
if Input.is_action_just_pressed("drop") and inventory.get_item():
drop_item()
@@ -121,6 +129,11 @@ func remove_action_area():
if (action_area):
remove_child(action_area)
func upgrade():
max_energy += 1
energy += 1
upgraded.emit()
func _process(_delta):
get_input()
move_and_slide()