fix the occuring that client doesn't get goals on joined
This commit is contained in:
@@ -354,6 +354,9 @@ func add_player_character(peer_id):
|
|||||||
var bot_to_replace = get_node_or_null(str(bots[0])) if bots.size() > 0 else null
|
var bot_to_replace = get_node_or_null(str(bots[0])) if bots.size() > 0 else null
|
||||||
if bot_to_replace:
|
if bot_to_replace:
|
||||||
player_character.goals = bot_to_replace.goals.duplicate()
|
player_character.goals = bot_to_replace.goals.duplicate()
|
||||||
|
else:
|
||||||
|
# Only generate new goals if not inheriting from a bot
|
||||||
|
player_character.append_random_goals()
|
||||||
|
|
||||||
func add_bot(bot_id):
|
func add_bot(bot_id):
|
||||||
rpc("create_bot", bot_id)
|
rpc("create_bot", bot_id)
|
||||||
|
|||||||
+5
-4
@@ -400,10 +400,11 @@ func initialize_random_goals(_size:int, min_value:int, max_value:int, null_count
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
# Remove this since goals are now set by main.gd
|
# Remove this since goals are now set by main.gd
|
||||||
#func append_random_goals():
|
func append_random_goals():
|
||||||
# goals.append_array(initialize_random_goals(9, 7, 10, 1.0))
|
goals.append_array(initialize_random_goals(9, 7, 10, 1.0))
|
||||||
# if is_multiplayer_authority():
|
|
||||||
# rpc("sync_goals", goals)
|
if is_multiplayer_authority():
|
||||||
|
rpc("sync_goals", goals)
|
||||||
|
|
||||||
func bot_try_grab_item() -> bool:
|
func bot_try_grab_item() -> bool:
|
||||||
if not enhanced_gridmap or action_points <= 0:
|
if not enhanced_gridmap or action_points <= 0:
|
||||||
|
|||||||
Reference in New Issue
Block a user