Fixed some errors

This commit is contained in:
Rendo 2025-12-09 23:54:02 +05:00
commit e6a47a4772
9 changed files with 32 additions and 32 deletions

View file

@ -13,6 +13,8 @@ func _ready() -> void:
else:
push_warning("Child of state machine is not state")
await get_tree().process_frame
await get_tree().process_frame
current_state.enter()
func on_transition_required(to: StringName):

View file

@ -5,10 +5,11 @@ class_name SubStateMachine
@export var enter_state: State
func _enter() -> void:
change_state(enter_state)
if is_multiplayer_authority():
change_state(enter_state)
func _exit() -> void:
current_state.exit()
pass
func update(delta: float) -> void:
if current_state == null:

View file

@ -56,7 +56,10 @@ 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()
#Replace with way to ensure all players loaded
await get_tree().process_frame
await get_tree().process_frame
state._enter()
func process_spawned_weapon(weapon_node: Node):
@ -83,13 +86,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)