weapon system rework
This commit is contained in:
parent
0ffc2b2497
commit
30b01100f0
27 changed files with 352 additions and 190 deletions
|
|
@ -1,6 +1,5 @@
|
|||
extends Node
|
||||
|
||||
|
||||
class_name StateMachine
|
||||
|
||||
@export var current_state: State
|
||||
|
|
@ -19,18 +18,36 @@ func on_transition_required(to: StringName):
|
|||
push_warning("Incorrect state request: " + to)
|
||||
return
|
||||
|
||||
change_state(states[to])
|
||||
|
||||
func change_state(to_state: State) -> void:
|
||||
if current_state != null:
|
||||
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():
|
||||
if current_state == null:
|
||||
return
|
||||
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:
|
||||
push_error("State is not set")
|
||||
return
|
||||
current_state.update(delta)
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
if current_state == null:
|
||||
push_error("State is not set")
|
||||
return
|
||||
current_state.physics_update(delta)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue