Synced the all playerboards, but there's still bugged while new player connected
This commit is contained in:
+11
-19
@@ -943,22 +943,12 @@ func sync_goals(new_goals: Array):
|
||||
|
||||
@rpc("any_peer", "call_local")
|
||||
func sync_playerboard(new_playerboard: Array):
|
||||
playerboard = new_playerboard
|
||||
playerboard = new_playerboard.duplicate()
|
||||
var main = get_tree().get_root().get_node_or_null("Main")
|
||||
if main:
|
||||
main.rpc("sync_playerboard", get_multiplayer_authority(), playerboard)
|
||||
_after_action_completed()
|
||||
|
||||
@rpc("any_peer", "call_local")
|
||||
func sync_behavior_tree(enabled: bool):
|
||||
var behavior_tree = $BehaviorTree
|
||||
if behavior_tree:
|
||||
behavior_tree.enabled = enabled
|
||||
behavior_tree.actor = self
|
||||
#behavior_tree.blackboard = blackboard
|
||||
|
||||
## Ensure blackboard has required values
|
||||
#blackboard.set_value("action_points", action_points)
|
||||
#blackboard.set_value("goals", goals)
|
||||
#blackboard.set_value("playerboard", playerboard)
|
||||
|
||||
func _after_action_completed():
|
||||
if multiplayer.get_unique_id() == get_multiplayer_authority():
|
||||
var main = get_tree().get_root().get_node_or_null("Main")
|
||||
@@ -969,13 +959,15 @@ func _after_action_completed():
|
||||
has_performed_action = false
|
||||
has_moved_this_turn = false
|
||||
|
||||
# Update blackboard after action points change
|
||||
#var blackboard = $Blackboard
|
||||
#if blackboard:
|
||||
#blackboard.set_value("action_points", action_points)
|
||||
|
||||
main.update_button_states()
|
||||
main.update_playerboard_ui()
|
||||
|
||||
# Add this line to sync all boards
|
||||
main.update_all_players_boards()
|
||||
|
||||
# Add sync for playerboard
|
||||
if is_multiplayer_authority():
|
||||
main.rpc("sync_playerboard", get_multiplayer_authority(), playerboard)
|
||||
|
||||
func consume_action_points(points: int):
|
||||
if not is_instance_valid(self) or not is_multiplayer_authority():
|
||||
|
||||
Reference in New Issue
Block a user