/// <summary> Despawns this player to all other players that cannot /// (or can if 'toVisible' is true) see the player in the current world. </summary> public static void GlobalDespawn(Player p, bool self, bool toVisible = false) { Player[] players = PlayerInfo.Online.Items; TabList.RemoveAll(p, self, toVisible); foreach (Player other in players) { if (p.level != other.level) { continue; } bool despawn = !Entities.CanSeeEntity(other, p); if (toVisible) { despawn = !despawn; } if (p != other && despawn) { Despawn(other, p.id); } else if (p == other && self) { Despawn(other, Entities.SelfID); } } }
/// <summary> Spawns this player to all other players that can see the player in the current world. </summary> public static void GlobalSpawn(Player p, ushort x, ushort y, ushort z, byte rotx, byte roty, bool self, string possession = "") { Player[] players = PlayerInfo.Online.Items; p.Game.lastSpawnColor = p.Game.Infected ? ZombieGame.InfectCol : p.color; TabList.Update(p, self); foreach (Player other in players) { if ((other.Loading && p != other) || p.level != other.level) { continue; } if (p != other && Entities.CanSeeEntity(other, p)) { Spawn(other, p, p.id, x, y, z, rotx, roty, possession); } else if (p == other && self) { other.pos = new ushort[3] { x, y, z }; other.rot = new byte[2] { rotx, roty }; other.oldpos = other.pos; other.oldrot = other.rot; Spawn(other, p, Entities.SelfID, x, y, z, rotx, roty, possession); } } }
/// <summary> Updates the tab list entry for this player to all other players /// (whose clients support it) who can see the player in the tab list. </summary> internal static void Update(Player p, bool self) { Player[] players = PlayerInfo.Online.Items; foreach (Player other in players) { if (p == other) { if (self) { Add(other, p, Entities.SelfID); } continue; } if (!Server.TablistGlobal && p.level != other.level) { continue; } if (Entities.CanSeeEntity(other, p)) { Add(other, p, p.id); } if (Entities.CanSeeEntity(p, other)) { Add(p, other, other.id); } } }
/// <summary> Despawns this player to all other players that can see the player in the current world. </summary> public static void GlobalDespawn(Player p, bool self, bool diffWorld = false) { Player[] players = PlayerInfo.Online.Items; foreach (Player other in players) { if (p.level != other.level) { continue; } // If same world, despawn if we can't see them. bool despawn = Entities.CanSeeEntity(other, p); if (!diffWorld) { despawn = !despawn; } if (p != other && despawn) { other.DespawnEntity(p.id); } else if (p == other && self) { other.DespawnEntity(255); } } }
/// <summary> Updates the tab list entry for this player to all other players /// (whose clients support it) in the server. </summary> internal static void RemoveAll(Player p, bool self, bool toVisible) { if (!Server.TablistGlobal) { return; } Player[] players = PlayerInfo.Online.Items; foreach (Player other in players) { if (p == other) { if (self) { Remove(other, Entities.SelfID); } continue; } bool despawn = !Entities.CanSeeEntity(other, p); if (toVisible) { despawn = !despawn; } if (despawn) { Remove(other, p.id); } despawn = !Entities.CanSeeEntity(p, other); if (toVisible) { despawn = !despawn; } if (despawn) { Remove(p, other.id); } } }