Improved skill casting
This commit is contained in:
parent
a374acc4f0
commit
fd47c5a433
@ -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:
|
||||
|
@ -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
|
||||
|
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user