Fixed netcode
This commit is contained in:
parent
48a72fd613
commit
1c062489b1
2 changed files with 4 additions and 11 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue