@@ -150,11 +150,11 @@ public override void OnSelectRolesPostfix()
150150 while ( AllPlayers . Count > blueTeamSize )
151151 {
152152 var player = AllPlayers [ rand . Next ( 0 , AllPlayers . Count ) ] ;
153- player . RpcSetBaseWarsTeam ( BaseWarsTeams . Red ) ;
153+ SendRPC ( player , BaseWarsTeams . Red , IsDead [ player . PlayerId ] , CanTeleport [ player . PlayerId ] ) ;
154154 AllPlayers . Remove ( player ) ;
155155 }
156156 foreach ( var player in AllPlayers )
157- player . RpcSetBaseWarsTeam ( BaseWarsTeams . Blue ) ;
157+ SendRPC ( player , BaseWarsTeams . Blue , IsDead [ player . PlayerId ] , CanTeleport [ player . PlayerId ] ) ;
158158 foreach ( var pc in PlayerControl . AllPlayerControls )
159159 {
160160 if ( GetTeam ( pc ) == BaseWarsTeams . Red )
@@ -212,7 +212,7 @@ public override void OnPet(PlayerControl pc)
212212 {
213213 SpawnPlayer ( pc ) ;
214214 TeleportCooldown [ pc . PlayerId ] = Options . TeleportCooldown . GetFloat ( ) ;
215- pc . RpcSetCanTeleport ( false ) ;
215+ SendRPC ( pc , GetTeam ( pc ) , IsDead [ pc . PlayerId ] , false ) ;
216216 }
217217 }
218218
@@ -265,7 +265,7 @@ public override bool OnCheckShapeshift(PlayerControl shapeshifter, PlayerControl
265265 return false ;
266266 }
267267
268- public override bool OnReportDeadBody ( PlayerControl __instance , NetworkedPlayerInfo target )
268+ public override bool OnReportDeadBody ( PlayerControl __instance , NetworkedPlayerInfo target , bool force )
269269 {
270270 return false ;
271271 }
@@ -283,7 +283,7 @@ public override void OnFixedUpdate()
283283 if ( RespawnCooldown [ pc . PlayerId ] <= 0f )
284284 {
285285 RespawnCooldown [ pc . PlayerId ] = 0f ;
286- pc . RpcSetIsDead ( false ) ;
286+ SendRPC ( pc , GetTeam ( pc ) , false , CanTeleport [ pc . PlayerId ] ) ;
287287 PlayerHealth [ pc . PlayerId ] = Options . StartingHealth . GetFloat ( ) + ( Options . HealthIncrease . GetFloat ( ) * GetLevel ( pc ) ) ;
288288 SpawnPlayer ( pc ) ;
289289 pc . SyncPlayerSettings ( ) ;
@@ -301,7 +301,7 @@ public override void OnFixedUpdate()
301301 {
302302 TeleportCooldown [ pc . PlayerId ] = 0f ;
303303 if ( ! CanTeleport [ pc . PlayerId ] )
304- pc . RpcSetCanTeleport ( true ) ;
304+ SendRPC ( pc , GetTeam ( pc ) , IsDead [ pc . PlayerId ] , true ) ;
305305 }
306306 }
307307 if ( Options . TurretSlowEnemies . GetBool ( ) )
@@ -411,6 +411,49 @@ public override string BuildPlayerName(PlayerControl player, PlayerControl seer,
411411 return name ;
412412 }
413413
414+ public void SendRPC ( PlayerControl player , BaseWarsTeams team , bool isDead , bool canTeleport )
415+ {
416+ if ( PlayerTeam [ player . PlayerId ] == team && IsDead [ player . PlayerId ] == isDead && ( ! Options . CanTeleportToBase . GetBool ( ) || CanTeleport [ player . PlayerId ] == canTeleport ) ) return ;
417+ PlayerTeam [ player . PlayerId ] = team ;
418+ IsDead [ player . PlayerId ] = isDead ;
419+ if ( Options . CanTeleportToBase . GetBool ( ) )
420+ CanTeleport [ player . PlayerId ] = canTeleport ;
421+ if ( player . AmOwner )
422+ HudManager . Instance . TaskPanel . SetTaskText ( "" ) ;
423+ MessageWriter writer = AmongUsClient . Instance . StartRpc ( player . NetId , ( byte ) CustomRPC . SyncGamemode , SendOption . Reliable ) ;
424+ writer . Write ( ( int ) team ) ;
425+ writer . Write ( isDead ) ;
426+ if ( Options . CanTeleportToBase . GetBool ( ) )
427+ writer . Write ( canTeleport ) ;
428+ writer . EndMessage ( ) ;
429+ }
430+
431+ public override void ReceiveRPC ( PlayerControl player , MessageReader reader )
432+ {
433+ PlayerTeam [ player . PlayerId ] = ( BaseWarsTeams ) reader . ReadInt32 ( ) ;
434+ IsDead [ player . PlayerId ] = reader . ReadBoolean ( ) ;
435+ if ( Options . CanTeleportToBase . GetBool ( ) )
436+ CanTeleport [ player . PlayerId ] = reader . ReadBoolean ( ) ;
437+ if ( player . AmOwner )
438+ HudManager . Instance . TaskPanel . SetTaskText ( "" ) ;
439+ }
440+
441+ public void SendRPC ( GameManager manager , SystemTypes room )
442+ {
443+ if ( ! AllTurretsPosition . Contains ( room ) ) return ;
444+ AllTurretsPosition . Remove ( room ) ;
445+ MessageWriter writer = AmongUsClient . Instance . StartRpc ( manager . NetId , ( byte ) CustomRPC . SyncGamemode , SendOption . Reliable ) ;
446+ writer . Write ( ( byte ) room ) ;
447+ writer . EndMessage ( ) ;
448+ }
449+
450+ public override void ReceiveRPC ( GameManager manager , MessageReader reader )
451+ {
452+ SystemTypes room = ( SystemTypes ) reader . ReadByte ( ) ;
453+ if ( AllTurretsPosition . Contains ( room ) )
454+ AllTurretsPosition . Remove ( room ) ;
455+ }
456+
414457 public BaseWarsTeams GetTeam ( PlayerControl player )
415458 {
416459 if ( player == null ) return BaseWarsTeams . None ;
@@ -440,7 +483,7 @@ public void Damage(PlayerControl player, float damage, PlayerControl attacker)
440483 {
441484 PlayerHealth [ player . PlayerId ] = 0f ;
442485 player . RpcTeleport ( Utils . GetOutsideMapPosition ( ) ) ;
443- player . RpcSetIsDead ( true ) ;
486+ SendRPC ( player , GetTeam ( player ) , true , CanTeleport [ player . PlayerId ] ) ;
444487 RespawnCooldown [ player . PlayerId ] = Options . BwRespawnCooldown . GetFloat ( ) ;
445488 player . SyncPlayerSettings ( ) ;
446489 if ( attacker != null )
0 commit comments