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():
|
for child in get_children():
|
||||||
if child is State:
|
if child is State:
|
||||||
states[child.name] = child
|
states[child.name] = child
|
||||||
child.transition.connect(on_transition_required)
|
child.transition.connect(on_transition_required.rpc)
|
||||||
else:
|
else:
|
||||||
push_warning("Child of state machine is not state")
|
push_warning("Child of state machine is not state")
|
||||||
|
|
||||||
|
@rpc("authority","call_local","reliable")
|
||||||
func on_transition_required(to: StringName):
|
func on_transition_required(to: StringName):
|
||||||
if states.has(to) == false:
|
if states.has(to) == false:
|
||||||
push_warning("Incorrect state request: " + to)
|
push_warning("Incorrect state request: " + to)
|
||||||
|
|
@ -26,8 +27,6 @@ func change_state(to_state: State) -> void:
|
||||||
current_state = to_state
|
current_state = to_state
|
||||||
current_state.enter()
|
current_state.enter()
|
||||||
|
|
||||||
update_remote_machines.rpc(to_state.name)
|
|
||||||
|
|
||||||
@rpc("authority","call_local","unreliable")
|
@rpc("authority","call_local","unreliable")
|
||||||
func clear_state():
|
func clear_state():
|
||||||
if current_state == null:
|
if current_state == null:
|
||||||
|
|
@ -35,13 +34,6 @@ func clear_state():
|
||||||
current_state.exit()
|
current_state.exit()
|
||||||
current_state = null
|
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:
|
func _process(delta: float) -> void:
|
||||||
if current_state == null:
|
if current_state == null:
|
||||||
return
|
return
|
||||||
|
|
|
||||||
|
|
@ -12,11 +12,12 @@ func _input(event: InputEvent) -> void:
|
||||||
if not machine.is_multiplayer_authority(): return
|
if not machine.is_multiplayer_authority(): return
|
||||||
|
|
||||||
if event.is_action_pressed("plr_reload"):
|
if event.is_action_pressed("plr_reload"):
|
||||||
init_reload()
|
init_reload.rpc()
|
||||||
|
|
||||||
func use_begin() -> void:
|
func use_begin() -> void:
|
||||||
transition.emit("Shoot")
|
transition.emit("Shoot")
|
||||||
|
|
||||||
|
@rpc("authority","call_local","reliable")
|
||||||
func init_reload():
|
func init_reload():
|
||||||
if machine.ammo == machine.max_ammo:
|
if machine.ammo == machine.max_ammo:
|
||||||
return
|
return
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue