internal bool OnPlayerEnteredRoom(Player player) { //we already have the player added to the connections list, as it was set when we set the Owner. if (Owner == player) { return(true); } var vis = CheckVisibility?.Invoke(player) ?? true; if (vis) { ImplObservePlayer(player); _visibility.Add(player); } return(vis); }
internal void RebuildVisibility(NetMessage ccMsg) { var destMsg = Room.GetDestroyMessage(this, RandPRpcs.Hide); var hidePlayers = new List <Player>(); var showPlayers = new List <Player>(); foreach (var player in Room.Players) { if (player == null) { continue; } if (!player.IsValid) { continue; } if (player == Owner) { continue; } var vis = CheckVisibility?.Invoke(player) ?? true; if (vis && !_visibility.Contains(player)) { ImplObservePlayer(player); _visibility.Add(player); showPlayers.Add(player); } else if (!vis && _visibility.Contains(player)) { _visibility.Remove(player); ImplIgnorePlayer(player); hidePlayers.Add(player); } } Room.SendToPlayers(hidePlayers.ToArray(), destMsg, ReliabilityMode.Ordered); Room.SendToPlayers(showPlayers.ToArray(), ccMsg, ReliabilityMode.Ordered); }