Improved skill casting

This commit is contained in:
Eduard Urbach 2024-02-16 14:45:49 +01:00
parent a374acc4f0
commit fd47c5a433
Signed by: akyoto
GPG Key ID: C874F672B1AF20C0
3 changed files with 16 additions and 5 deletions

View File

@ -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:

View File

@ -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

View File

@ -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: