Bomb
This commit is contained in:
parent
388fe1ccce
commit
6b939d241c
12 changed files with 128 additions and 68 deletions
|
|
@ -9,6 +9,7 @@ class_name WeaponSystem
|
|||
@export var camera: PlayerCamera
|
||||
|
||||
var current_state: WeaponSubStateMachine
|
||||
var last_slot: StringName
|
||||
|
||||
var slots: Dictionary[StringName,WeaponSubStateMachine] = {
|
||||
"primary": null,
|
||||
|
|
@ -29,6 +30,7 @@ func _ready() -> void:
|
|||
child.system = self
|
||||
child.animation_player = animation_player
|
||||
child.player_camera = camera
|
||||
child.request_return.connect(return_to_previous)
|
||||
else:
|
||||
push_warning("Child of weapon system is not ability or weapon")
|
||||
|
||||
|
|
@ -56,18 +58,28 @@ func switch(to: StringName):
|
|||
if slots.has(to) == false or slots[to] == null or slots[to] == current_state:
|
||||
return
|
||||
current_state.exit()
|
||||
current_state.in_use = false
|
||||
if current_state.can_be_previous:
|
||||
last_slot = slots.find_key(current_state)
|
||||
else:
|
||||
last_slot = ""
|
||||
current_state = slots[to]
|
||||
current_state.enter()
|
||||
current_state.in_use = true
|
||||
|
||||
switched_to.emit(current_state)
|
||||
|
||||
#update_remotes.rpc(to)
|
||||
update_remotes.rpc(to)
|
||||
|
||||
func return_to_previous():
|
||||
if last_slot != "":
|
||||
switch(last_slot)
|
||||
|
||||
@rpc("authority","call_remote","reliable")
|
||||
func update_remotes(to: StringName):
|
||||
switch(to)
|
||||
current_state.exit()
|
||||
current_state = slots[to]
|
||||
current_state.enter()
|
||||
|
||||
switched_to.emit(current_state)
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
if current_state == null:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue