public static string Run(string[] args, Loudness loud = Loudness.NORMAL, string solutionDir = null) { if (solutionDir == null) { solutionDir = SolutionUtilities.GetSolutionDir(); } string stdout, stderr; int ret = CaideExe.Execute(args, solutionDir, out stdout, out stderr); if (ret != 0) { if (loud >= Loudness.NORMAL) { Logger.LogError("caide.exe error. Return code {0}\n{1}\n{2}", ret, stdout, stderr); } if (loud >= Loudness.LOUD) { MessageBox.Show(string.Format("caide.exe error. Return code {0}\n{1}\n{2}", ret, stdout, stderr)); } return(null); } return(stdout); }
private void AnnounceNewCrewmember(GameObject player) { PlayerScript playerScript = player.GetComponent <PlayerScript>(); Occupation playerOccupation = playerScript.mind.occupation; string playerName = player.ExpensiveName(); Loudness annoucementImportance = GetAnnouncementImportance(playerOccupation); ChatChannel chatChannels = ChatChannel.Common; string commonMessage = $"{playerName} has signed up as {playerOccupation.DisplayName}."; string deptMessage = $"{playerName}, {playerOccupation.DisplayName}, is the department head."; // Get the channel of the newly joined head from their occupation. if (channelFromJob.ContainsKey(playerOccupation.JobType)) { BroadcastCommMsg(channelFromJob[playerOccupation.JobType], deptMessage, annoucementImportance); } // Announce the arrival on the CentComm channel if is a CentComm occupation. if (JobCategories.CentCommJobs.Contains(playerOccupation.JobType)) { chatChannels = ChatChannel.CentComm; } else if (playerOccupation.IsCrewmember == false) { // Don't announce non-crewmembers like wizards, fugitives at all (they don't have their own chat channel). return; } BroadcastCommMsg(chatChannels, commonMessage, GetAnnouncementImportance(playerOccupation)); }
public void UpdateClientChat(string message, ChatChannel channels, bool isOriginator, GameObject recipient, Loudness loudness, ChatModifier modifiers) { if (string.IsNullOrEmpty(message)) { return; } trySendingTTS(message); if (PlayerManager.LocalPlayerScript == null) { channels = ChatChannel.OOC; } if (channels != ChatChannel.None) { // replace action messages with chat bubble if (channels.HasFlag(ChatChannel.Combat) || channels.HasFlag(ChatChannel.Action) || channels.HasFlag(ChatChannel.Examine) || modifiers.HasFlag(ChatModifier.Emote)) { if (isOriginator) { ChatBubbleManager.Instance.ShowAction(Regex.Replace(message, "<.*?>", string.Empty), recipient); } } ChatUI.Instance.AddChatEntry(message); } }
/// <summary> /// Do not use this message directly. If you need to do work with the chat system use /// the Chat API (the only exception to this rule is if you just need to send 1 msg to 1 client from the server /// i.e syndi special roles) /// </summary> public static NetMessage Send(GameObject recipient, ChatChannel channels, ChatModifier chatMods, string chatMessage, Loudness loudness = Loudness.NORMAL, string othersMsg = "", GameObject originator = null, string speaker = "", bool stripTags = true) { uint origin = NetId.Empty; if (originator != null) { origin = originator.GetComponent <NetworkIdentity>().netId; } NetMessage msg = new NetMessage { Recipient = recipient.GetComponent <NetworkIdentity>().netId, Channels = channels, ChatModifiers = chatMods, Message = chatMessage, OthersMessage = othersMsg, Originator = origin, Speaker = speaker, StripTags = stripTags, Loudness = loudness }; SendTo(recipient, msg, Category.Chat, 2); return(msg); }
void Start() { source = GetComponent <AudioSource>(); loud = GetComponentInChildren <Loudness>(); source.loop = true; source.clip = paacjs[Random.Range(0, paacjs.Length)]; source.pitch = 1 + Random.Range(-0.35f, 0.35f); source.Play(); GameController.PaacjUp(); }
//This is only used to send the chat input on the client to the server public static NetMessage Send(string message, ChatChannel channels, Loudness loudness = Loudness.NORMAL) { NetMessage msg = new NetMessage { Channels = channels, ChatMessageText = message, Loudness = loudness }; Send(msg); return(msg); }
public override LocalEmbed ToEmbed() { var embed = base.ToEmbed(); embed.AddField("Type", Type.Transform(To.TitleCase), true); embed.AddField("Loudness", Loudness.ToString("+0.00;-#.00"), true); if (Velocity != 0) { embed.AddField("Velocity", Velocity.ToString("+0.00;-#.00"), true); } if (DurabilityBurn != 0) { embed.AddField("Durability Burn", $"{DurabilityBurn:+0.00;-#.00}%", true); } return(embed); }
/// <summary> /// Broadcast a comm. message to chat, by machine. Useful for e.g. AutomatedAnnouncer. /// </summary> /// <param name="sentByMachine">Machine broadcasting the message</param> /// <param name="message">The message to broadcast.</param> /// <param name="channels">The channels to broadcast on.</param> /// <param name="chatModifiers">Chat modifiers to use e.g. ChatModifier.ColdlyState.</param> /// <param name="broadcasterName">Optional name for the broadcaster. Pulls name from GameObject if not used.</param> /// <param name="voiceLevel">How loud is this message?</param> public static void AddCommMsgByMachineToChat( GameObject sentByMachine, string message, ChatChannel channels, Loudness voiceLevel, ChatModifier chatModifiers = ChatModifier.None, string broadcasterName = default) { if (string.IsNullOrWhiteSpace(message)) { return; } var chatEvent = new ChatEvent { message = message, modifiers = chatModifiers, speaker = broadcasterName != default ? broadcasterName : sentByMachine.ExpensiveName(), position = sentByMachine.WorldPosServer(), channels = channels, originator = sentByMachine, VoiceLevel = voiceLevel }; InvokeChatEvent(chatEvent); }
public static string Run(string[] args, Loudness loud = Loudness.NORMAL, string solutionDir = null) { if (solutionDir == null) { solutionDir = SolutionUtilities.GetSolutionDir(); } string stdout, stderr; int ret = CaideExe.Execute(args, solutionDir, out stdout, out stderr); if (ret != 0) { if (loud >= Loudness.NORMAL) { Logger.LogError("caide.exe error. Return code {0}\n{1}\n{2}", ret, stdout, stderr); } if (loud >= Loudness.LOUD) { MessageBox.Show(string.Format("caide.exe error. Return code {0}\n{1}\n{2}", ret, stdout, stderr)); } return null; } return stdout; }
public Dog(Loudness loudness) { Loudness = loudness; }
public void PropagateChatToClients(ChatEvent chatEvent) { List <ConnectedPlayer> players = PlayerList.Instance.AllPlayers; Loudness loud = chatEvent.VoiceLevel; //Local chat range checks: if (chatEvent.channels.HasFlag(ChatChannel.Local) || chatEvent.channels.HasFlag(ChatChannel.Combat) || chatEvent.channels.HasFlag(ChatChannel.Action)) { for (int i = players.Count - 1; i >= 0; i--) { if (players[i].Script == null) { //joined viewer, don't message them players.RemoveAt(i); continue; } if (players[i].Script.gameObject == chatEvent.originator) { //Always send the originator chat to themselves continue; } if (players[i].Script.IsGhost && players[i].Script.IsPlayerSemiGhost == false) { //send all to ghosts continue; } if (chatEvent.position == TransformState.HiddenPos) { //show messages with no provided position to everyone continue; } //Send chat to PlayerChatLocation pos, usually just the player object but for AI is its vessel var playerPosition = players[i].Script.PlayerChatLocation.OrNull()?.AssumedWorldPosServer() ?? players[i].Script.gameObject.AssumedWorldPosServer(); //Do player position to originator distance check if (DistanceCheck(playerPosition) == false) { //Distance check failed so if we are Ai, then try send action and combat messages to their camera location //as well as if possible if (chatEvent.channels.HasFlag(ChatChannel.Local) == false && players[i].Script.PlayerState == PlayerScript.PlayerStates.Ai && players[i].Script.TryGetComponent <AiPlayer>(out var aiPlayer) && aiPlayer.IsCarded == false) { playerPosition = players[i].Script.gameObject.AssumedWorldPosServer(); //Check camera pos if (DistanceCheck(playerPosition)) { //Camera can see player, allow Ai to see action/combat messages continue; } } //Player failed distance checks remove them players.RemoveAt(i); } bool DistanceCheck(Vector3 playerPos) { //TODO maybe change this to (chatEvent.position - playerPos).sqrMagnitude > 196f to avoid square root for performance? if (Vector2.Distance(chatEvent.position, playerPos) > 14f) { //Player in the list is too far away for local chat, remove them: return(false); } //Within range, but check if they are in another room or hiding behind a wall if (MatrixManager.Linecast(chatEvent.position, LayerTypeSelection.Walls, layerMask, playerPos).ItHit) { //If it hit a wall remove that player return(false); } //Player can see the position return(true); } } if (chatEvent.originator != null) { //Get NPCs in vicinity var npcs = Physics2D.OverlapCircleAll(chatEvent.position, 14f, npcMask); foreach (Collider2D coll in npcs) { var npcPosition = coll.gameObject.AssumedWorldPosServer(); if (MatrixManager.Linecast(chatEvent.position, LayerTypeSelection.Walls, layerMask, npcPosition).ItHit == false) { //NPC is in hearing range, pass the message on: Physics2D.OverlapCircleAll(chatEvent.originator.AssumedWorldPosServer(), 8f, itemsMask); var mobAi = coll.GetComponent <MobAI>(); if (mobAi != null) { mobAi.LocalChatReceived(chatEvent); } } } if (radioCheckIsOnCooldown == false) { CheckForRadios(chatEvent); } } } for (var i = 0; i < players.Count; i++) { ChatChannel channels = chatEvent.channels; if (channels.HasFlag(ChatChannel.Combat) || channels.HasFlag(ChatChannel.Local) || channels.HasFlag(ChatChannel.System) || channels.HasFlag(ChatChannel.Examine) || channels.HasFlag(ChatChannel.Action)) { //Binary check here to avoid speaking in local when speaking on binary if (!channels.HasFlag(ChatChannel.Binary) || (players[i].Script.IsGhost && players[i].Script.IsPlayerSemiGhost == false)) { UpdateChatMessage.Send(players[i].GameObject, channels, chatEvent.modifiers, chatEvent.message, loud, chatEvent.messageOthers, chatEvent.originator, chatEvent.speaker, chatEvent.stripTags); continue; } } if (players[i].Script == null) { channels &= ChatChannel.OOC; } else { channels &= players[i].Script.GetAvailableChannelsMask(false); } //if the mask ends up being a big fat 0 then don't do anything if (channels != ChatChannel.None) { UpdateChatMessage.Send(players[i].GameObject, channels, chatEvent.modifiers, chatEvent.message, loud, chatEvent.messageOthers, chatEvent.originator, chatEvent.speaker, chatEvent.stripTags); } } if (rconManager != null) { string message = $"{chatEvent.speaker} {chatEvent.message}"; if ((namelessChannels & chatEvent.channels) != chatEvent.channels) { message = $"<b>[{chatEvent.channels}]</b> {message}"; } RconManager.AddChatLog(message); } }
void ReceiveLoudness(byte value) { loudness = (Loudness)value; RaisePropertyChanged("Loudness"); }
/// <summary> /// This should only be called via UpdateChatMessage /// on the client. Do not use for anything else! /// </summary> public static void ProcessUpdateChatMessage(uint recipientUint, uint originatorUint, string message, string messageOthers, ChatChannel channels, ChatModifier modifiers, string speaker, GameObject recipient, Loudness loudness, bool stripTags = true) { var isOriginator = true; if (recipientUint != originatorUint) { isOriginator = false; if (!string.IsNullOrEmpty(messageOthers)) { //If there is a message in MessageOthers then determine //if it should be the main message or not. message = messageOthers; } } if (GhostValidationRejection(originatorUint, channels)) { return; } var msg = ProcessMessageFurther(message, speaker, channels, modifiers, loudness, originatorUint, stripTags); ChatRelay.Instance.UpdateClientChat(msg, channels, isOriginator, recipient, loudness, modifiers); }
/// <summary> /// Processes message further for the chat log. /// Adds text styling, color and channel prefixes depending on the message and its modifiers. /// </summary> /// <returns>The chat message, formatted to suit the chat log.</returns> public static string ProcessMessageFurther(string message, string speaker, ChatChannel channels, ChatModifier modifiers, Loudness loudness, uint originatorUint = 0, bool stripTags = true) { playedSound = false; //Highlight in game name by bolding and underlining if possible //Dont play sound here as it could be examine or action, we only play sound for someone speaking message = HighlightInGameName(message, false); //Skip everything if system message if (channels.HasFlag(ChatChannel.System)) { return(message); } //Skip everything in case of combat channel if (channels.HasFlag(ChatChannel.Combat)) { return(AddMsgColor(channels, $"<i>{message}</i>")); //POC } //Skip everything if it is an action or examine message or if it is a local message //without a speaker (which is used by machines) if (channels.HasFlag(ChatChannel.Examine) || channels.HasFlag(ChatChannel.Action) || channels.HasFlag(ChatChannel.Local) && string.IsNullOrEmpty(speaker)) { return(AddMsgColor(channels, $"<i>{message}</i>")); } // Skip everything if the message is a local warning if (channels.HasFlag(ChatChannel.Warning)) { return(AddMsgColor(channels, $"<i>{message}</i>")); } if (stripTags) { message = StripTags(message); //Bold names again after tag stripping message = HighlightInGameName(message); } //Check for emote. If found skip chat modifiers, make sure emote is only in Local channel if ((modifiers & ChatModifier.Emote) == ChatModifier.Emote) { // /me message channels = ChatChannel.Local; message = AddMsgColor(channels, $"<i><b>{speaker}</b> {message}</i>"); return(message); } //Check for OOC. If selected, remove all other channels and modifiers (could happen if UI f***s up or someone tampers with it) if (channels.HasFlag(ChatChannel.OOC)) { //ooc name quick fix var name = Regex.Replace(speaker, @"\t\n\r", ""); if (string.IsNullOrWhiteSpace(name)) { name = "nerd"; } //highlight OOC name by bolding and underlining if possible message = HighlightName(message, ServerData.Auth.CurrentUser.DisplayName); message = AddMsgColor(channels, $"[ooc] <b>{name}: {message}</b>"); return(message); } //Ghosts don't get modifiers if (channels.HasFlag(ChatChannel.Ghost)) { string[] _ghostVerbs = { "cries", "moans" }; return(AddMsgColor(channels, $"[dead] <b>{speaker}</b> {_ghostVerbs.PickRandom()}: {message}")); } string verb = "says,"; if ((modifiers & ChatModifier.Mute) == ChatModifier.Mute) { return(""); } if ((modifiers & ChatModifier.Whisper) == ChatModifier.Whisper) { verb = "whispers,"; message = $"<i>{message}</i>"; } else if ((modifiers & ChatModifier.Sing) == ChatModifier.Sing) { verb = "sings,"; message += " ♫"; } else if ((modifiers & ChatModifier.Yell) == ChatModifier.Yell) { verb = "yells,"; message = $"<b>{message}</b>"; } else if ((modifiers & ChatModifier.Query) == ChatModifier.Query) { verb = "queries,"; } else if ((modifiers & ChatModifier.State) == ChatModifier.State) { verb = "states,"; } else if ((modifiers & ChatModifier.ColdlyState) == ChatModifier.ColdlyState) { verb = "coldly states,"; } else if ((modifiers & ChatModifier.Exclaim) == ChatModifier.Exclaim) { verb = "exclaims,"; } else if ((modifiers & ChatModifier.Question) == ChatModifier.Question) { verb = "asks,"; } var chan = $"[{channels.ToString().ToLower().Substring(0, 3)}] "; if (channels.HasFlag(ChatChannel.Command)) { chan = "[cmd] "; } if (channels.HasFlag(ChatChannel.Local)) { chan = ""; } var textSize = loudness switch { Loudness.QUIET => ChatTemplates.SmallText, Loudness.LOUD => ChatTemplates.LargeText, Loudness.SCREAMING => ChatTemplates.VeryLargeText, Loudness.EARRAPE => ChatTemplates.ExtremelyLargeText, _ => message.Contains("!!") ? ChatTemplates.LargeText : ChatTemplates.NormalText, }; return(AddMsgColor(channels, $"{chan}<b>{speaker}</b> {verb}" // [cmd] Username says, + " " // Two hair spaces. This triggers Text-to-Speech. + $"<size={textSize}>" + "\"" + message + "\"" + "</size>")); // "This text will be spoken by TTS!" }
public Cat(Loudness loudness) { Loudness = loudness; }
public Cat() { Loudness = Loudness.LOW; }
/// <summary> /// Send a Chat Msg from a player to the selected Chat Channels /// Server only /// </summary> public static void AddChatMsgToChat(ConnectedPlayer sentByPlayer, string message, ChatChannel channels, Loudness loudness = Loudness.NORMAL) { message = AutoMod.ProcessChatServer(sentByPlayer, message); if (string.IsNullOrWhiteSpace(message)) { return; } //Sanity check for null username if (string.IsNullOrWhiteSpace(sentByPlayer.Username)) { Logger.Log($"Null/empty Username, Details: Username: {sentByPlayer.Username}, ClientID: {sentByPlayer.ClientId}, IP: {sentByPlayer.Connection.address}", Category.Admin); return; } var player = sentByPlayer.Script; //Check to see whether this player is allowed to send on the chosen channels if (player != null) { channels &= player.GetAvailableChannelsMask(true); } else { //If player is null, must be in lobby therefore lock to OOC channels = ChatChannel.OOC; } if (channels == ChatChannel.None) { return; } // The exact words that leave the player's mouth (or that are narrated). Already includes HONKs, stutters, etc. // This step is skipped when speaking in the OOC channel. (string message, ChatModifier chatModifiers)processedMessage = (string.Empty, ChatModifier.None); // Placeholder values bool isOOC = channels.HasFlag(ChatChannel.OOC); if (!isOOC) { processedMessage = ProcessMessage(sentByPlayer, message); if (string.IsNullOrWhiteSpace(processedMessage.message)) { return; } } var chatEvent = new ChatEvent { message = isOOC ? message : processedMessage.message, modifiers = (player == null) ? ChatModifier.None : processedMessage.chatModifiers, speaker = (player == null) ? sentByPlayer.Username : player.playerName, position = (player == null) ? TransformState.HiddenPos : player.PlayerChatLocation.AssumedWorldPosServer(), channels = channels, originator = (player == null) ? sentByPlayer.GameObject : player.PlayerChatLocation, VoiceLevel = loudness }; //This is to make sure OOC doesn't break if (sentByPlayer.Job != JobType.NULL) { CheckVoiceLevel(sentByPlayer.Script, chatEvent.channels); } if (channels.HasFlag(ChatChannel.OOC)) { chatEvent.speaker = StripAll(sentByPlayer.Username); var isAdmin = PlayerList.Instance.IsAdmin(sentByPlayer.UserId); if (isAdmin) { chatEvent.speaker = "<color=red>[A]</color> " + chatEvent.speaker; } else if (PlayerList.Instance.IsMentor(sentByPlayer.UserId)) { chatEvent.speaker = "<color=#6400ff>[M]</color> " + chatEvent.speaker; } if (Instance.OOCMute && !isAdmin) { return; } //http/https links in OOC chat if (isAdmin || !GameManager.Instance.AdminOnlyHtml) { if (htmlRegex.IsMatch(chatEvent.message)) { var messageParts = chatEvent.message.Split(' '); var builder = new StringBuilder(); foreach (var part in messageParts) { if (!htmlRegex.IsMatch(part)) { builder.Append(part); builder.Append(" "); continue; } builder.Append($"<link={part}><color=blue>{part}</color></link> "); } chatEvent.message = builder.ToString(); //TODO have a config file available to whitelist/blacklist links if all players are allowed to post links //disables client side tag protection to allow <link=></link> tag chatEvent.stripTags = false; } } ChatRelay.Instance.PropagateChatToClients(chatEvent); var strippedSpeaker = StripTags(chatEvent.speaker); //Sends OOC message to a discord webhook DiscordWebhookMessage.Instance.AddWebHookMessageToQueue(DiscordWebhookURLs.DiscordWebhookOOCURL, message, strippedSpeaker, ServerData.ServerConfig.DiscordWebhookOOCMentionsID); if (!ServerData.ServerConfig.DiscordWebhookSendOOCToAllChat) { return; } //Send it to All chat DiscordWebhookMessage.Instance.AddWebHookMessageToQueue(DiscordWebhookURLs.DiscordWebhookAllChatURL, $"[{ChatChannel.OOC}] {message}\n", strippedSpeaker); return; } // TODO the following code uses player.playerHealth, but ConciousState would be more appropriate. // Check if the player is allowed to talk: if (player != null) { if (player.playerHealth != null) { if (!player.IsDeadOrGhost && player.mind.IsMiming && !processedMessage.chatModifiers.HasFlag(ChatModifier.Emote)) { AddWarningMsgFromServer(sentByPlayer.GameObject, "You can't talk because you made a vow of silence."); return; } if (player.playerHealth.IsCrit) { if (!player.playerHealth.IsDead) { return; } else { chatEvent.channels = ChatChannel.Ghost; } } else if (!player.playerHealth.IsDead && !player.IsGhost) { //Control the chat bubble player.playerNetworkActions.ServerToggleChatIcon(true, processedMessage.message, channels, processedMessage.chatModifiers); } } } InvokeChatEvent(chatEvent); }
public Dog() { Loudness = Loudness.LOW; }
private void BroadcastCommMsg(ChatChannel chatChannels, string message, Loudness importance) { Chat.AddCommMsgByMachineToChat(gameObject, message, chatChannels, importance, ChatModifier.ColdlyState, machineName); }
public Mouse(Loudness loudness) { Loudness = loudness; }
public Mouse() { Loudness = Loudness.LOW; }