State machine rework
This commit is contained in:
parent
3f99f1b8dd
commit
87919ed890
25 changed files with 102 additions and 76 deletions
|
|
@ -8,13 +8,40 @@ signal return_to_previous
|
|||
|
||||
var machine: WeaponSubStateMachine
|
||||
|
||||
func _use_begin() -> void:
|
||||
pass
|
||||
|
||||
@rpc("authority","call_remote","reliable")
|
||||
func use_begin() -> void:
|
||||
_use_begin()
|
||||
if is_multiplayer_authority():
|
||||
use_begin.rpc()
|
||||
|
||||
func _use_end():
|
||||
pass
|
||||
|
||||
@rpc("authority","call_remote","reliable")
|
||||
func use_end() -> void:
|
||||
_use_end()
|
||||
if is_multiplayer_authority():
|
||||
use_end.rpc()
|
||||
|
||||
func _alternate_state() -> void:
|
||||
pass
|
||||
|
||||
@rpc("authority","call_remote","reliable")
|
||||
func alternate_state() -> void:
|
||||
pass
|
||||
_alternate_state()
|
||||
if is_multiplayer_authority():
|
||||
alternate_state.rpc()
|
||||
# Need to clarify naming; Switch mode like firemode. For different states use
|
||||
# alternate_state
|
||||
func switch_mode() -> void:
|
||||
|
||||
func _switch_mode():
|
||||
pass
|
||||
|
||||
@rpc("authority","call_remote","reliable")
|
||||
func switch_mode() -> void:
|
||||
_switch_mode()
|
||||
if is_multiplayer_authority():
|
||||
switch_mode.rpc()
|
||||
|
|
|
|||
|
|
@ -64,11 +64,11 @@ func _ready() -> void:
|
|||
ammo_depleted.connect(system.check_for_empty)
|
||||
ammo_updated.connect(system.on_ammo_updated)
|
||||
|
||||
func enter() -> void:
|
||||
func _enter() -> void:
|
||||
super()
|
||||
player.weapon_models[visibility_target].show()
|
||||
|
||||
func exit() -> void:
|
||||
func _exit() -> void:
|
||||
super()
|
||||
player.weapon_models[visibility_target].hide()
|
||||
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ func add(state: WeaponSubStateMachine, slot: StringName) -> void:
|
|||
if current_state == null:
|
||||
current_state = state
|
||||
ammo_updated.emit(current_state.ammo,current_state.remaining_ammo)
|
||||
state.enter.call_deferred()
|
||||
state._enter.call_deferred()
|
||||
|
||||
|
||||
func process_spawned_weapon(weapon_node: Node):
|
||||
|
|
@ -83,13 +83,13 @@ func switch(to: StringName, exit: bool = true):
|
|||
if slots.has(to) == false or slots[to] == null or slots[to] == current_state or (multiplayer.get_remote_sender_id() != 1 and is_multiplayer_authority() == false):
|
||||
return
|
||||
if current_state != null and exit:
|
||||
current_state.exit()
|
||||
current_state._exit()
|
||||
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._enter()
|
||||
|
||||
ammo_updated.emit(current_state.ammo,current_state.remaining_ammo)
|
||||
switched_to.emit(current_state)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue