/// <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 UpdateChatMessage Send(GameObject recipient, ChatChannel channels, ChatModifier chatMods, string chatMessage, string othersMsg = "", GameObject originator = null, string speaker = "", bool stripTags = true) { uint origin = NetId.Empty; if (originator != null) { origin = originator.GetComponent <NetworkIdentity>().netId; } UpdateChatMessage msg = new UpdateChatMessage { Recipient = recipient.GetComponent <NetworkIdentity>().netId, Channels = channels, ChatModifiers = chatMods, Message = chatMessage, OthersMessage = othersMsg, Originator = origin, Speaker = speaker, StripTags = stripTags }; msg.SendTo(recipient); return(msg); }
public override void SignalFailed() { if (pickupable.ItemSlot != null && pickupable.ItemSlot.Player != null) { UpdateChatMessage.Send(pickupable.ItemSlot.Player.gameObject, ChatChannel.Examine, ChatModifier.None, "You feel your signaler vibrate."); } }
protected override void ServerPerformInteraction(HandApply interaction) { var livingHealth = interaction.TargetObject.GetComponent <LivingHealthBehaviour>(); string ToShow = (livingHealth.name + " is " + livingHealth.ConsciousState.ToString() + "\n" + "OverallHealth = " + livingHealth.OverallHealth.ToString() + " Blood level = " + livingHealth.bloodSystem.BloodLevel.ToString() + "\n" + "Blood levels = " + livingHealth.CalculateOverallBloodLossDamage() + "\n"); string StringBuffer = ""; float TotalBruteDamage = 0; float TotalBurnDamage = 0; foreach (BodyPartBehaviour BodyPart in livingHealth.BodyParts) { StringBuffer += BodyPart.Type.ToString() + "\t"; StringBuffer += BodyPart.BruteDamage.ToString() + "\t"; TotalBruteDamage += BodyPart.BruteDamage; StringBuffer += BodyPart.BurnDamage.ToString(); TotalBurnDamage += BodyPart.BurnDamage; StringBuffer += "\n"; } ToShow = ToShow + "Overall, Brute " + TotalBruteDamage.ToString() + " Burn " + TotalBurnDamage.ToString() + " OxyLoss " + livingHealth.bloodSystem.OxygenDamage.ToString() + "\n" + "Body Part, Brute, Burn \n" + StringBuffer; if (livingHealth.cloningDamage > 0) { ToShow += $"Cellular Damage Level: {livingHealth.cloningDamage}"; } UpdateChatMessage.Send(interaction.Performer, ChatChannel.Examine, ToShow); }
protected override void ServerPerformInteraction(MouseDrop interaction) { var pna = interaction.Performer.GetComponent <PlayerNetworkActions>(); var closetControl = GetComponent <ClosetControl>(); if (!closetControl.IsClosed) { UpdateChatMessage.Send(interaction.Performer, ChatChannel.Examine, "You wrestle with the body bag, but it won't fold while unzipped."); return; } if (!closetControl.IsEmpty()) { UpdateChatMessage.Send(interaction.Performer, ChatChannel.Examine, "There are too many things inside of the body bag to fold it up!"); return; } // Add folded to player inventory InventoryManager.EquipInInvSlot(pna.Inventory[pna.activeHand], PoolManager.PoolNetworkInstantiate(prefabVariant)); // Remove from world PoolManager.PoolNetworkDestroy(gameObject); }
public override void AfterSpawn(ConnectedPlayer player) { UpdateChatMessage.Send(player.GameObject, ChatChannel.Syndicate, ChatModifier.None, $"We have intercepted the code for the nuclear weapon: <b>{AntagManager.SyndiNukeCode}</b>.", Loudness.LOUD); AntagManager.TryInstallPDAUplink(player, initialTC, true); }
/// <summary> /// Server-side only. For use when a player has only joined (as a JoinedViewer) and /// is not in control of any mobs. Spawns the player with the specified occupation / settings /// and transfers the viewer to control the new player. /// </summary> /// <param name="forViewer">viewer who should control the player</param> /// <param name="occupation">occupation to spawn as</param> /// <param name="characterSettings">settings to use for the character</param> /// <returns></returns> public static void ServerSpawnPlayer(JoinedViewer forViewer, Occupation occupation, CharacterSettings characterSettings) { NetworkConnection conn = forViewer.connectionToClient; var newPlayer = ServerSpawnInternal(conn, occupation, characterSettings, null); if (newPlayer) { if (occupation.JobType == JobType.SYNDICATE) { //Check to see if there is a nuke and communicate the nuke code: Nuke nuke = Object.FindObjectOfType <Nuke>(); if (nuke != null) { UpdateChatMessage.Send(newPlayer, ChatChannel.Syndicate, ChatModifier.None, "We have intercepted the code for the nuclear weapon: " + nuke.NukeCode); } } GameManager.Instance.CheckAntags(); if (occupation.JobType != JobType.SYNDICATE && occupation.JobType != JobType.AI) { SecurityRecordsManager.Instance.AddRecord(newPlayer.GetComponent <PlayerScript>(), occupation.JobType); } } }
public override bool Interact(GameObject originator, Vector3 position, string hand) { if (!CanUse(originator, hand, position, false)) { return(false); } if (!isServer) { //ask server to perform the interaction InteractMessage.Send(gameObject, position, hand); return(true); } if (!allowSell && deniedMessage != null && !GameData.Instance.testServer && !GameData.IsHeadlessServer) { UpdateChatMessage.Send(originator, ChatChannel.Examine, deniedMessage); } else if (allowSell) { allowSell = false; if (!GameData.Instance.testServer && !GameData.IsHeadlessServer) { UpdateChatMessage.Send(originator, ChatChannel.Examine, interactionMessage); } ServerVendorInteraction(position); StartCoroutine(VendorInputCoolDown()); } return(true); }
public static void AddWarningMsgFromServer(GameObject recipient, string msg) { if (!IsServer()) { return; } UpdateChatMessage.Send(recipient, ChatChannel.Warning, ChatModifier.None, msg); }
/// <summary> /// Used on the server to send examine messages to a player /// Server only /// </summary> /// <param name="recipient">The player object to send the message too</param> /// <param name="msg">The examine message</param> public static void AddExamineMsgFromServer(GameObject recipient, string msg) { if (!IsServer()) { return; } UpdateChatMessage.Send(recipient, ChatChannel.Examine, ChatModifier.None, msg, Loudness.NORMAL); }
public override GameObject ServerSpawn(PlayerSpawnRequest spawnRequest) { var newPlayer = PlayerSpawn.ServerSpawnPlayer(spawnRequest); UpdateChatMessage.Send(newPlayer, ChatChannel.System, ChatModifier.None, "<color=red>As a member of the Cargonian Members Federation you have been ordered to help in the efforts to secede from the rest of the station.</color>"); // spawn them normally, with their preferred occupation return(newPlayer); }
/// <summary> /// Called when the remote signaler receives a signal. Puts a little message in chat if you're holding it. /// </summary> /// <param name="signal"></param> public void ServerReceiveSignal(RadioSignal signal) { if (pickupable.ItemSlot != null && pickupable.ItemSlot.Player != null) { UpdateChatMessage.Send(pickupable.ItemSlot.Player.gameObject, ChatChannel.Examine, ChatModifier.None, "You feel your signaler vibrate."); } hackDevice.SendOutputSignal(); }
public override GameObject ServerSpawn(PlayerSpawnRequest spawnRequest) { var newPlayer = PlayerSpawn.ServerSpawnPlayer(spawnRequest); UpdateChatMessage.Send(newPlayer, ChatChannel.System, ChatModifier.None, "<color=red>Something has awoken in you. You feel the urgent need to rebel with your brothers against this station.</color>"); // spawn them normally, with their preferred occupation return(newPlayer); }
private void PropagateChatToClients(ChatEvent chatEvent) { List <ConnectedPlayer> players; if (chatEvent.matrix != MatrixInfo.Invalid) { //get players only on provided matrix players = PlayerList.Instance.GetPlayersOnMatrix(chatEvent.matrix); } else { players = PlayerList.Instance.InGamePlayers; } //Local chat range checks: if (chatEvent.channels == ChatChannel.Local || chatEvent.channels == ChatChannel.Combat) { // var speaker = PlayerList.Instance.Get(chatEvent.speaker); RaycastHit2D hit; LayerMask layerMask = 1 << 9; //Walls layer for (int i = 0; i < players.Count(); i++) { if (Vector2.Distance(chatEvent.position, //speaker.GameObject.transform.position, players[i].GameObject.transform.position) > 14f) { //Player in the list is too far away for local chat, remove them: players.Remove(players[i]); } else { //within range, but check if they are in another room or hiding behind a wall if (Physics2D.Linecast(chatEvent.position, //speaker.GameObject.transform.position, players[i].GameObject.transform.position, layerMask)) { //if it hit a wall remove that player players.Remove(players[i]); } } } } for (var i = 0; i < players.Count; i++) { ChatChannel channels = players[i].Script.GetAvailableChannelsMask(false) & chatEvent.channels; UpdateChatMessage.Send(players[i].GameObject, channels, chatEvent.message); } if (RconManager.Instance != null) { string name = ""; if ((namelessChannels & chatEvent.channels) != chatEvent.channels) { name = "<b>[" + chatEvent.channels + "]</b> "; } RconManager.AddChatLog(name + chatEvent.message); } }
public static UpdateChatMessage Send(GameObject recipient, ChatChannel channels, string message) { UpdateChatMessage msg = new UpdateChatMessage { Recipient = recipient.GetComponent <NetworkIdentity>().netId, Channels = channels, ChatMessageText = message }; msg.SendTo(recipient); return(msg); }
public override void AfterSpawn(ConnectedPlayer player) { UpdateChatMessage.Send(player.GameObject, ChatChannel.Local, ChatModifier.Whisper, "I can't believe we managed to break out of a Nanotrasen superjail! Sadly though," + " our work is not done. The emergency teleport at the station logs everyone who uses it," + " and where they went. It won't be long until Centcom tracks where we've gone off to." + " I need to move in the shadows and keep out of sight," + " I'm not going back."); _ = StationWarning(player.Script.playerName); }
public void HugMobByIndex(string index) { var mob = GetMob(index); if (mob) { SoundManager.PlayNetworkedAtPos("Notice1", Provider.transform.position); //Get mob's gameobject and do something good to it UpdateChatMessage.Send(mob.TrackedObject, ChatChannel.Common, "You feel like you're being hugged by something invisible"); } }
/// <summary> /// Special set up instructions when spawning as a special role /// </summary> void CheckForSpecialRoleTypes() { if (playerScript.mind.jobType == JobType.SYNDICATE) { //Check to see if there is a nuke and communicate the nuke code: Nuke nuke = FindObjectOfType <Nuke>(); if (nuke != null) { UpdateChatMessage.Send(gameObject, ChatChannel.Syndicate, "We have intercepted the code for the nuclear weapon: " + nuke.NukeCode); } } }
private void PropagateChatToClients(ChatEvent chatEvent) { PlayerScript[] players = FindObjectsOfType <PlayerScript>(); for (int i = 0; i < players.Length; i++) { //Make sure we're not sending to inactive players if (players[i].playerMove.allowInput) { ChatChannel channels = players[i].GetAvailableChannels(false) & chatEvent.channels; UpdateChatMessage.Send(players[i].gameObject, channels, chatEvent.message); } } }
public override bool Interact(GameObject originator, Vector3 position, string hand) { if (!CanUse(originator, hand, position, false)) { return(false); } if (!isServer) { return(true); } UpdateChatMessage.Send(originator, ChatChannel.Examine, Message); return(true); }
protected override void Setup() { //Check to see if there is a nuke and communicate the nuke code: NukeTarget = FindObjectOfType <Nuke>(); if (NukeTarget == null) { Logger.LogWarning("Unable to setup nuke objective, no nuke found in scene!", Category.Antags); } else { UpdateChatMessage.Send(Owner.body.gameObject, ChatChannel.Syndicate, ChatModifier.None, "We have intercepted the code for the nuclear weapon: " + NukeTarget.NukeCode); } }
private void PropagateChatToClients(ChatEvent chatEvent) { PlayerScript[] players = FindObjectsOfType <PlayerScript>(); for (int i = 0; i < players.Length; i++) { //First check if the players object is owned by a client //by checking if the inputController is enabled: if (players[i].inputController.enabled) { ChatChannel channels = players[i].GetAvailableChannels(false) & chatEvent.channels; UpdateChatMessage.Send(players[i].gameObject, channels, chatEvent.message); } } }
public override void AfterSpawn(ConnectedPlayer player) { // add any NuclearOperative specific logic here //send the code: //Check to see if there is a nuke and communicate the nuke code: Nuke nuke = FindObjectOfType <Nuke>(); if (nuke != null) { UpdateChatMessage.Send(player.GameObject, ChatChannel.Syndicate, ChatModifier.None, $"We have intercepted the code for the nuclear weapon: <b>{nuke.NukeCode}</b>."); } AntagManager.TryInstallPDAUplink(player, initialTC); }
public override GameObject ServerSpawn(PlayerSpawnRequest spawnRequest) { var newPlayer = PlayerSpawn.ServerSpawnPlayer(spawnRequest.JoinedViewer, AntagOccupation, spawnRequest.CharacterSettings); UpdateChatMessage.Send(newPlayer, ChatChannel.Local, ChatModifier.Whisper, "I can't believe we managed to break out of a Nanotrasen superjail! Sadly though," + " our work is not done. The emergency teleport at the station logs everyone who uses it," + " and where they went. It won't be long until Centcom tracks where we've gone off to." + " I need to move in the shadows and keep out of sight," + " I'm not going back."); _ = StationWarning(newPlayer.Player().Name); return(newPlayer); }
// Interaction when clicking the bin protected override void ServerPerformInteraction(HandApply interaction) { var handObj = interaction.HandObject; if (handObj == null) { var pna = interaction.Performer.GetComponent <PlayerNetworkActions>(); // Pen comes out before the paper if (storedPen) { UpdateChatMessage.Send(interaction.Performer, ChatChannel.Examine, "You take the pen out of the paper bin."); InventoryManager.EquipInInvSlot(pna.Inventory[pna.activeHand], GetStoredPen()); return; } // Player is picking up a piece of paper if (!HasPaper()) { UpdateChatMessage.Send(interaction.Performer, ChatChannel.Examine, "The paper bin is empty!"); return; } UpdateChatMessage.Send(interaction.Performer, ChatChannel.Examine, "You take the paper out of the paper bin."); InventoryManager.EquipInInvSlot(pna.Inventory[pna.activeHand], GetPaperFromStack()); } else { // Player is adding a piece of paper or a pen var slot = InventoryManager.GetSlotFromOriginatorHand(interaction.Performer, interaction.HandSlot.equipSlot); handObj.GetComponent <Pickupable>().DisappearObject(slot); if (handObj.GetComponent <Pen>()) { SyncStoredPen(handObj); UpdateChatMessage.Send(interaction.Performer, ChatChannel.Examine, "You put the pen in the paper bin."); return; } UpdateChatMessage.Send(interaction.Performer, ChatChannel.Examine, "You put the paper in the paper bin."); AddPaperToStack(handObj); } }
// add any NuclearOperative specific logic here public override GameObject ServerSpawn(PlayerSpawnRequest spawnRequest) { //spawn as a nuke op regardless of the requested occupation var newPlayer = PlayerSpawn.ServerSpawnPlayer(spawnRequest.JoinedViewer, AntagOccupation, spawnRequest.CharacterSettings); //send the code: //Check to see if there is a nuke and communicate the nuke code: Nuke nuke = Object.FindObjectOfType <Nuke>(); if (nuke != null) { UpdateChatMessage.Send(newPlayer, ChatChannel.Syndicate, ChatModifier.None, "We have intercepted the code for the nuclear weapon: " + nuke.NukeCode); } return(newPlayer); }
public override ModuleSignal ClosedInteraction(HandApply interaction) { if (Validations.HasUsedActiveWelder(interaction)) { TryWeld(interaction); return(ModuleSignal.Break); } if (isWelded) { UpdateChatMessage.Send( interaction.Performer, ChatChannel.Examine, ChatModifier.None, "The door is welded shut."); } return(ModuleSignal.Continue); }
public override bool Interact(GameObject originator, Vector3 position, string hand) { if (!CanUse(originator, hand, position, false)) { return(false); } if (!isServer) { //ask server to perform the interaction InteractMessage.Send(gameObject, position, hand); return(true); } container.Opened = !container.Opened; string msg = container.Opened ? $"The valve is open, outputting at {container.ReleasePressure} kPa." : "The valve is closed."; UpdateChatMessage.Send(originator, ChatChannel.Examine, msg); return(true); }
public void PlayerFound(PlayerHealth Playerhealth, GameObject originator) { string ToShow = (Playerhealth.name + " is " + Playerhealth.ConsciousState.ToString() + "\n" + "OverallHealth = " + Playerhealth.OverallHealth.ToString() + " Blood level = " + Playerhealth.bloodSystem.BloodLevel.ToString() + "\n" + "Blood levels = " + Playerhealth.CalculateOverallBloodLossDamage() + "\n"); string StringBuffer = ""; float TotalBruteDamage = 0; float TotalBurnDamage = 0; foreach (BodyPartBehaviour BodyPart in Playerhealth.BodyParts) { StringBuffer += BodyPart.Type.ToString() + "\t"; StringBuffer += BodyPart.BruteDamage.ToString() + "\t"; TotalBruteDamage += BodyPart.BruteDamage; StringBuffer += BodyPart.BurnDamage.ToString(); TotalBurnDamage += BodyPart.BurnDamage; StringBuffer += "\n"; } ToShow = ToShow + "Overall, Brute " + TotalBruteDamage.ToString() + " Burn " + TotalBurnDamage.ToString() + " OxyLoss " + Playerhealth.bloodSystem.OxygenDamage.ToString() + "\n" + "Body Part, Brute, Burn \n" + StringBuffer; UpdateChatMessage.Send(originator, ChatChannel.Examine, ToShow); }
private void PropagateChatToClients(ChatEvent chatEvent) { var players = PlayerList.Instance.InGamePlayers; //Local chat range checks: if (chatEvent.channels == ChatChannel.Local || chatEvent.channels == ChatChannel.Combat) { // var speaker = PlayerList.Instance.Get(chatEvent.speaker); RaycastHit2D hit; LayerMask layerMask = 1 << 9; //Walls layer for (int i = 0; i < players.Count(); i++) { if (Vector2.Distance(chatEvent.position, //speaker.GameObject.transform.position, players[i].GameObject.transform.position) > 14f) { //Player in the list is too far away for local chat, remove them: players.Remove(players[i]); } else { //within range, but check if they are in another room or hiding behind a wall if (Physics2D.Linecast(chatEvent.position, //speaker.GameObject.transform.position, players[i].GameObject.transform.position, layerMask)) { //if it hit a wall remove that player players.Remove(players[i]); } } } } for (var i = 0; i < players.Count; i++) { var playerScript = players[i].GameObject.GetComponent <PlayerScript>(); ChatChannel channels = playerScript.GetAvailableChannelsMask(false) & chatEvent.channels; UpdateChatMessage.Send(players[i].GameObject, channels, chatEvent.message); } }
public void PropagateChatToClients(ChatEvent chatEvent) { List <ConnectedPlayer> players = PlayerList.Instance.AllPlayers; //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); } } //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: var mobAi = coll.GetComponent <MobAI>(); if (mobAi != null) { mobAi.LocalChatReceived(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, 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, chatEvent.messageOthers, chatEvent.originator, chatEvent.speaker, chatEvent.stripTags); } } if (rconManager != null) { string name = ""; if ((namelessChannels & chatEvent.channels) != chatEvent.channels) { name = "<b>[" + chatEvent.channels + "]</b> "; } RconManager.AddChatLog(name + chatEvent.message); } }