This commit is contained in:
Marek Lenczewski
2026-04-02 19:30:44 +02:00
parent c7e6f8f4b5
commit 73af6abeb7
90 changed files with 138 additions and 133 deletions

28
scenes/player/player.gd Normal file
View File

@@ -0,0 +1,28 @@
extends CharacterBody3D
@export var stats: BaseStats
func _ready() -> void:
add_to_group("player")
Stats.register(self, stats)
var cooldown_system: Node = get_tree().get_first_node_in_group("cooldown_system")
if cooldown_system:
cooldown_system.register(self, 5)
if GameState.returning_from_dungeon:
GameState.restore_player(self)
global_position = GameState.portal_position + Vector3(0, 1, -5)
GameState.returning_from_dungeon = false
elif GameState.dungeon_cleared:
GameState.clear()
var health: float = Stats.get_stat(self, "health")
var max_health: float = Stats.get_stat(self, "max_health")
var shield: float = Stats.get_stat(self, "shield")
var max_shield: float = Stats.get_stat(self, "max_shield")
EventBus.health_changed.emit(self, health, max_health)
EventBus.shield_changed.emit(self, shield, max_shield)
func _exit_tree() -> void:
Stats.deregister(self)
var cooldown_system: Node = get_tree().get_first_node_in_group("cooldown_system")
if cooldown_system:
cooldown_system.deregister(self)