diff --git a/scripts/state_machine/machine.gd b/scripts/state_machine/machine.gd index 25c0e77..2ee4bdd 100644 --- a/scripts/state_machine/machine.gd +++ b/scripts/state_machine/machine.gd @@ -9,10 +9,11 @@ func _ready() -> void: for child in get_children(): if child is State: states[child.name] = child - child.transition.connect(on_transition_required) + child.transition.connect(on_transition_required.rpc) else: push_warning("Child of state machine is not state") +@rpc("authority","call_local","reliable") func on_transition_required(to: StringName): if states.has(to) == false: push_warning("Incorrect state request: " + to) @@ -25,8 +26,6 @@ func change_state(to_state: State) -> void: current_state.exit() current_state = to_state current_state.enter() - - update_remote_machines.rpc(to_state.name) @rpc("authority","call_local","unreliable") func clear_state(): @@ -35,13 +34,6 @@ func clear_state(): current_state.exit() current_state = null -@rpc("authority","call_remote","unreliable") -func update_remote_machines(to: StringName) -> void: - if current_state != null: - current_state.exit() - current_state = states[to] - current_state.enter() - func _process(delta: float) -> void: if current_state == null: return diff --git a/scripts/weapon_system/gun/idle_state.gd b/scripts/weapon_system/gun/idle_state.gd index f1d7398..ffa2a4f 100644 --- a/scripts/weapon_system/gun/idle_state.gd +++ b/scripts/weapon_system/gun/idle_state.gd @@ -12,11 +12,12 @@ func _input(event: InputEvent) -> void: if not machine.is_multiplayer_authority(): return if event.is_action_pressed("plr_reload"): - init_reload() + init_reload.rpc() func use_begin() -> void: transition.emit("Shoot") +@rpc("authority","call_local","reliable") func init_reload(): if machine.ammo == machine.max_ammo: return