diff --git a/client/network/PlayerMove.gd b/client/network/PlayerMove.gd index fceea72..b4d8d8c 100644 --- a/client/network/PlayerMove.gd +++ b/client/network/PlayerMove.gd @@ -31,7 +31,7 @@ func handle_packet(data: PackedByteArray): controller.direction_changed.emit(Vector3(direction_x, 0, direction_z)) func _physics_process(_delta): - if Global.player == null: + if !Global.player: return if Global.player.position == last_sent_position: diff --git a/client/player/Player.gd b/client/player/Player.gd index 2353cbc..8106355 100644 --- a/client/player/Player.gd +++ b/client/player/Player.gd @@ -1,13 +1,19 @@ class_name Player extends Character -signal name_changed(new_name: String) - +## Player ID var id: String + +## Components var movement: MovementComponent +var state: StateComponent func _enter_tree(): - movement = get_node("Movement") + movement = $Movement + state = $State + +## Name +signal name_changed(new_name: String) func set_player_name(new_name: String): name = new_name diff --git a/client/player/skills/SkillsComponent.gd b/client/player/skills/SkillsComponent.gd index fe47e82..3e0c255 100644 --- a/client/player/skills/SkillsComponent.gd +++ b/client/player/skills/SkillsComponent.gd @@ -3,14 +3,19 @@ extends Node @export var skills: Array[Skill] +var character: Character + func _ready(): - var character := owner as Character + character = owner character.controller.used_skill.connect(use_skill) func use_skill(slot: int): if slot < 0 || slot >= skills.size(): return + if character.state.current == StateComponent.State.Skill: + return + var skill := skills[slot] if !skill: