Switch multiplayer to state change based RPC calls method
This commit is contained in:
parent
032d2583e6
commit
bde9492c63
|
|
@ -23,8 +23,8 @@ onready var animated_sprite : AnimatedSprite = $AnimatedSprite_StateReceiver
|
|||
|
||||
## Multiplayer Variables
|
||||
puppet var puppet_pos = Vector2()
|
||||
puppet var puppet_anim_sprite_frame :int
|
||||
puppet var puppet_anim_sprite_name :String
|
||||
#puppet var puppet_anim_sprite_frame :int
|
||||
#puppet var puppet_anim_sprite_name :String
|
||||
puppet var puppet_transform: Transform2D
|
||||
|
||||
##TODO:
|
||||
|
|
@ -34,24 +34,24 @@ puppet var puppet_transform: Transform2D
|
|||
# interfaces for the state machines.
|
||||
|
||||
func _ready() -> void:
|
||||
puppet_anim_sprite_name = animated_sprite.animation
|
||||
puppet_anim_sprite_frame = animated_sprite.frame
|
||||
# puppet_anim_sprite_name = animated_sprite.animation
|
||||
# puppet_anim_sprite_frame = animated_sprite.frame
|
||||
puppet_transform = transform
|
||||
## Disable Process and Physics on puppets
|
||||
if not is_network_master():
|
||||
animated_sprite.set_process(false)
|
||||
animated_sprite.set_physics_process(false)
|
||||
# if not is_network_master():
|
||||
# animated_sprite.set_process(false)
|
||||
# animated_sprite.set_physics_process(false)
|
||||
#movement_state_machine.init_animated_actor(self)
|
||||
#movement_component.attack_function = funcref(self, "attack")
|
||||
# movement_component.player_number = player_number
|
||||
|
||||
func _process(delta):
|
||||
if is_network_master():
|
||||
rset("puppet_anim_sprite_name", animated_sprite.animation)
|
||||
rset("puppet_anim_sprite_frame", animated_sprite.frame)
|
||||
else:
|
||||
animated_sprite.animation = puppet_anim_sprite_name
|
||||
animated_sprite.frame = puppet_anim_sprite_frame
|
||||
#func _process(delta):
|
||||
# if is_network_master():
|
||||
# rset("puppet_anim_sprite_name", animated_sprite.animation)
|
||||
# rset("puppet_anim_sprite_frame", animated_sprite.frame)
|
||||
# else:
|
||||
# animated_sprite.animation = puppet_anim_sprite_name
|
||||
# animated_sprite.frame = puppet_anim_sprite_frame
|
||||
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
if is_network_master():
|
||||
|
|
|
|||
|
|
@ -80,6 +80,9 @@ func change_state(new_state: State) -> void:
|
|||
current_state = new_state
|
||||
current_state.enter()
|
||||
|
||||
#puppet puppet_change_state(new_state: State) -> void:
|
||||
# pass
|
||||
|
||||
# Seems like I don't have to do this every state change!
|
||||
# if(state_modifiers.size() > 0):
|
||||
# print("Active Modifiers:")
|
||||
|
|
@ -90,7 +93,7 @@ func change_state(new_state: State) -> void:
|
|||
|
||||
emit_signal("state_changed",current_state_name,current_state)
|
||||
|
||||
func change_to_known_state(new_state_name: String) -> void:
|
||||
puppet func puppet_change_to_known_state(new_state_name: String) -> void:
|
||||
if new_state_name.empty() == false:
|
||||
if states_index.has(new_state_name):
|
||||
change_state(states_index[new_state_name])
|
||||
|
|
@ -98,6 +101,16 @@ func change_to_known_state(new_state_name: String) -> void:
|
|||
push_warning(get_parent().name + ": Attempt to switch state to unknown: " + new_state_name)
|
||||
change_state(states_index["default"])
|
||||
|
||||
func change_to_known_state(new_state_name: String) -> void:
|
||||
if is_network_master():
|
||||
if new_state_name.empty() == false:
|
||||
if states_index.has(new_state_name):
|
||||
change_state(states_index[new_state_name])
|
||||
else:
|
||||
push_warning(get_parent().name + ": Attempt to switch state to unknown: " + new_state_name)
|
||||
change_state(states_index["default"])
|
||||
rpc("puppet_change_to_known_state", new_state_name)
|
||||
|
||||
#func check_parent_before_state_change(new_state_name: String) -> bool:
|
||||
# ##TODO: Make this a verifiable funcref or something
|
||||
# if get_parent().has_method("check_state_change"):
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user