Corrected team switch logic
This commit is contained in:
parent
dfcb7020ea
commit
ca2f507024
1 changed files with 2 additions and 36 deletions
|
|
@ -75,7 +75,7 @@ func add_and_sync_peer(id: int) -> void:
|
|||
update_teams_state.emit()
|
||||
set_teams.rpc_id(id,attack_team,defence_team,specators_team)
|
||||
|
||||
@rpc("any_peer","call_remote","reliable")
|
||||
@rpc("authority","call_remote","reliable")
|
||||
func set_teams(attack: Array[int],defence: Array[int],spectators: Array[int]):
|
||||
attack_team = attack
|
||||
defence_team = defence
|
||||
|
|
@ -89,15 +89,7 @@ func swap_teams() -> void:
|
|||
if not multiplayer.is_server():
|
||||
return
|
||||
|
||||
var temp_defenders = defence_team.duplicate()
|
||||
|
||||
for attacker in attack_team:
|
||||
server_team_switch.rpc(attacker,Session.TEAMS.DEFENCE)
|
||||
|
||||
for defender in temp_defenders:
|
||||
server_team_switch.rpc(defender,Session.TEAMS.ATTACK)
|
||||
|
||||
update_peers.rpc()
|
||||
set_teams.rpc(defence_team,attack_team,specators_team)
|
||||
|
||||
@rpc("any_peer","call_local","reliable")
|
||||
func team_switch_notification(id: int, team: int) -> void:
|
||||
|
|
@ -126,32 +118,6 @@ func team_switch_notification(id: int, team: int) -> void:
|
|||
|
||||
update_teams_state.emit()
|
||||
|
||||
@rpc("authority","call_local","reliable")
|
||||
func server_team_switch(id: int, team: int) -> void:
|
||||
if multiplayer.get_remote_sender_id() != 1 and not multiplayer.is_server():
|
||||
return
|
||||
|
||||
if team == Session.TEAMS.DEFENCE:
|
||||
if attack_team.has(id):
|
||||
attack_team.erase(id)
|
||||
if specators_team.has(id):
|
||||
specators_team.erase(id)
|
||||
defence_team.append(id)
|
||||
|
||||
if team == Session.TEAMS.ATTACK:
|
||||
if defence_team.has(id):
|
||||
defence_team.erase(id)
|
||||
if specators_team.has(id):
|
||||
specators_team.erase(id)
|
||||
attack_team.append(id)
|
||||
|
||||
if team == Session.TEAMS.SPECTATE:
|
||||
if attack_team.has(id):
|
||||
attack_team.erase(id)
|
||||
elif defence_team.has(id):
|
||||
defence_team.erase(id)
|
||||
specators_team.append(id)
|
||||
|
||||
func start_game() -> void:
|
||||
if not multiplayer.is_server():
|
||||
return
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue