State machine rework

This commit is contained in:
Rendo 2025-12-09 22:34:17 +05:00
commit 87919ed890
25 changed files with 102 additions and 76 deletions

View file

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