public void ChatLocally(string username, string text) { var player = (Player)_state.Actors.Single(act => act.Id == username); var playersInRange = WorldUtils.GetActorsInRange(_state, player, player.FieldOfView).OfType <Player>(); var formattedMessage = $"[{username}]: {text}"; foreach (var otherPlayers in playersInRange) { otherPlayers.ChatHistory.Add(formattedMessage); } }
public WorldState GetStateScope(Player player) { var actorsInRange = WorldUtils.GetActorsInRange(this, player, player.FieldOfView); var disconnectedPlayers = Actors.Where(actor => actor is Player ply && !ConnectedPlayers.Contains(ply)); return(new WorldState { Maps = Maps, Actors = actorsInRange.Except(disconnectedPlayers).ToList() }); }