2022-05-12 05:05:16 -07:00
using System.Linq ;
2022-03-30 22:21:58 -07:00
using System.Text ;
using Content.Server.Administration.Logs ;
using Content.Server.Administration.Managers ;
using Content.Server.Chat.Managers ;
2022-06-20 16:59:04 -04:00
using Content.Server.GameTicking ;
2022-03-30 22:21:58 -07:00
using Content.Server.Ghost.Components ;
using Content.Server.Players ;
using Content.Server.Popups ;
2022-06-03 21:37:35 +10:00
using Content.Server.Station.Components ;
using Content.Server.Station.Systems ;
2022-03-30 22:21:58 -07:00
using Content.Shared.ActionBlocker ;
using Content.Shared.CCVar ;
using Content.Shared.Chat ;
using Content.Shared.Database ;
2022-07-13 22:23:55 -07:00
using Content.Shared.IdentityManagement ;
2022-03-30 22:21:58 -07:00
using Content.Shared.Inventory ;
2023-01-13 16:57:10 -08:00
using Content.Shared.Mobs.Systems ;
2022-11-23 00:52:19 +13:00
using Content.Shared.Radio ;
2022-08-07 20:21:56 -03:00
using Robust.Server.GameObjects ;
2022-03-30 22:21:58 -07:00
using Robust.Server.Player ;
2022-06-03 21:37:35 +10:00
using Robust.Shared.Audio ;
2022-03-30 22:21:58 -07:00
using Robust.Shared.Configuration ;
using Robust.Shared.Console ;
using Robust.Shared.Network ;
using Robust.Shared.Player ;
using Robust.Shared.Players ;
2022-06-23 20:11:03 +10:00
using Robust.Shared.Prototypes ;
2022-03-30 22:21:58 -07:00
using Robust.Shared.Random ;
2022-11-23 00:52:19 +13:00
using Robust.Shared.Replays ;
2022-03-30 22:21:58 -07:00
using Robust.Shared.Utility ;
2022-06-23 20:11:03 +10:00
namespace Content.Server.Chat.Systems ;
2022-03-30 22:21:58 -07:00
/// <summary>
/// ChatSystem is responsible for in-simulation chat handling, such as whispering, speaking, emoting, etc.
/// ChatSystem depends on ChatManager to actually send the messages.
/// </summary>
2022-06-23 20:11:03 +10:00
public sealed partial class ChatSystem : SharedChatSystem
2022-03-30 22:21:58 -07:00
{
2022-11-23 00:52:19 +13:00
[Dependency] private readonly IReplayRecordingManager _replay = default ! ;
2022-03-30 22:21:58 -07:00
[Dependency] private readonly IConfigurationManager _configurationManager = default ! ;
[Dependency] private readonly IChatManager _chatManager = default ! ;
[Dependency] private readonly IChatSanitizationManager _sanitizer = default ! ;
[Dependency] private readonly IAdminManager _adminManager = default ! ;
[Dependency] private readonly IPlayerManager _playerManager = default ! ;
2022-06-23 20:11:03 +10:00
[Dependency] private readonly IPrototypeManager _prototypeManager = default ! ;
2022-03-30 22:21:58 -07:00
[Dependency] private readonly IRobustRandom _random = default ! ;
2022-05-28 23:41:17 -07:00
[Dependency] private readonly IAdminLogManager _adminLogger = default ! ;
2022-03-30 22:21:58 -07:00
[Dependency] private readonly ActionBlockerSystem _actionBlocker = default ! ;
[Dependency] private readonly InventorySystem _inventory = default ! ;
[Dependency] private readonly PopupSystem _popup = default ! ;
2022-06-03 21:37:35 +10:00
[Dependency] private readonly StationSystem _stationSystem = default ! ;
2022-07-26 09:58:19 -04:00
[Dependency] private readonly MobStateSystem _mobStateSystem = default ! ;
2023-01-25 17:29:41 +01:00
[Dependency] private readonly SharedAudioSystem _audio = default ! ;
2022-03-30 22:21:58 -07:00
2022-11-15 17:09:27 +13:00
public const int VoiceRange = 10 ; // how far voice goes in world units
public const int WhisperRange = 2 ; // how far whisper goes in world units
public const string DefaultAnnouncementSound = "/Audio/Announcements/announce.ogg" ;
2022-03-30 22:21:58 -07:00
private bool _loocEnabled = true ;
2022-07-26 09:58:19 -04:00
private bool _deadLoocEnabled = false ;
2022-03-30 22:21:58 -07:00
private readonly bool _adminLoocEnabled = true ;
public override void Initialize ( )
{
2023-01-25 17:29:41 +01:00
base . Initialize ( ) ;
InitializeEmotes ( ) ;
2022-03-30 22:21:58 -07:00
_configurationManager . OnValueChanged ( CCVars . LoocEnabled , OnLoocEnabledChanged , true ) ;
2022-07-26 09:58:19 -04:00
_configurationManager . OnValueChanged ( CCVars . DeadLoocEnabled , OnDeadLoocEnabledChanged , true ) ;
2022-06-20 16:59:04 -04:00
SubscribeLocalEvent < GameRunLevelChangedEvent > ( OnGameChange ) ;
2022-03-30 22:21:58 -07:00
}
public override void Shutdown ( )
{
2023-01-25 17:29:41 +01:00
base . Shutdown ( ) ;
ShutdownEmotes ( ) ;
2022-03-30 22:21:58 -07:00
_configurationManager . UnsubValueChanged ( CCVars . LoocEnabled , OnLoocEnabledChanged ) ;
2023-02-28 08:15:48 -08:00
_configurationManager . UnsubValueChanged ( CCVars . DeadLoocEnabled , OnDeadLoocEnabledChanged ) ;
2022-03-30 22:21:58 -07:00
}
private void OnLoocEnabledChanged ( bool val )
{
if ( _loocEnabled = = val ) return ;
_loocEnabled = val ;
_chatManager . DispatchServerAnnouncement (
Loc . GetString ( val ? "chat-manager-looc-chat-enabled-message" : "chat-manager-looc-chat-disabled-message" ) ) ;
}
2022-07-26 09:58:19 -04:00
private void OnDeadLoocEnabledChanged ( bool val )
{
if ( _deadLoocEnabled = = val ) return ;
_deadLoocEnabled = val ;
_chatManager . DispatchServerAnnouncement (
Loc . GetString ( val ? "chat-manager-dead-looc-chat-enabled-message" : "chat-manager-dead-looc-chat-disabled-message" ) ) ;
}
2022-06-20 16:59:04 -04:00
private void OnGameChange ( GameRunLevelChangedEvent ev )
{
Northstar Gloves (#16021)
* Added Gloves of North Star, no sprite or talking yet...
* Added sprites for the gloves of the north star...
* Replaced more placeholder sprites for northstar gloves...
* Added gloves of the north star to uplink...
* Added speech on hit, not yet configureable
* Not functional yet, but a step in the right direction I hope...
* IT WORKS!!
* Licensing and cleanup
* Reduced attack speed, changed from chat to popup, added some admin logging. It was causing too much adminlog spam otherwise
* Reorganized some files, final build??
* Changed the adminlog type from Verb to new type ItemConfigure
* More cleanup, fix sprite reference maybe
* Keronshb's suggestions, fixed some stuff, made hit sound use the meaty punch sfx
* Adds support for hiding speak/whisper/emote from adminlogs, makes northstar speak again!
* Some file shuffling, some of Keronshb's requests. Might appear a bit funky in github because vscode kept duplicating files for some reason and I had to delete them
* Made it work with the latest changes on Master
* Final? cleanup, upped dmg to 8, made ui not activate on activateinhand, instead you need to right click
* Set value to 0 credits, that's all
* Well that was much easier than I made it out to be. Now you can only activate the gloves with right click, no more mispredicts.
* Update MeleeWeaponSystem.cs
Iunno why this got changed in the first place, but I'm changin it back
* emptycommit
* emptycommit
* The tiny fixening
2023-05-23 11:12:30 -07:00
switch ( ev . New )
2023-02-28 08:15:48 -08:00
{
case GameRunLevel . InRound :
Northstar Gloves (#16021)
* Added Gloves of North Star, no sprite or talking yet...
* Added sprites for the gloves of the north star...
* Replaced more placeholder sprites for northstar gloves...
* Added gloves of the north star to uplink...
* Added speech on hit, not yet configureable
* Not functional yet, but a step in the right direction I hope...
* IT WORKS!!
* Licensing and cleanup
* Reduced attack speed, changed from chat to popup, added some admin logging. It was causing too much adminlog spam otherwise
* Reorganized some files, final build??
* Changed the adminlog type from Verb to new type ItemConfigure
* More cleanup, fix sprite reference maybe
* Keronshb's suggestions, fixed some stuff, made hit sound use the meaty punch sfx
* Adds support for hiding speak/whisper/emote from adminlogs, makes northstar speak again!
* Some file shuffling, some of Keronshb's requests. Might appear a bit funky in github because vscode kept duplicating files for some reason and I had to delete them
* Made it work with the latest changes on Master
* Final? cleanup, upped dmg to 8, made ui not activate on activateinhand, instead you need to right click
* Set value to 0 credits, that's all
* Well that was much easier than I made it out to be. Now you can only activate the gloves with right click, no more mispredicts.
* Update MeleeWeaponSystem.cs
Iunno why this got changed in the first place, but I'm changin it back
* emptycommit
* emptycommit
* The tiny fixening
2023-05-23 11:12:30 -07:00
if ( ! _configurationManager . GetCVar ( CCVars . OocEnableDuringRound ) )
2023-02-28 08:15:48 -08:00
_configurationManager . SetCVar ( CCVars . OocEnabled , false ) ;
break ;
case GameRunLevel . PostRound :
Northstar Gloves (#16021)
* Added Gloves of North Star, no sprite or talking yet...
* Added sprites for the gloves of the north star...
* Replaced more placeholder sprites for northstar gloves...
* Added gloves of the north star to uplink...
* Added speech on hit, not yet configureable
* Not functional yet, but a step in the right direction I hope...
* IT WORKS!!
* Licensing and cleanup
* Reduced attack speed, changed from chat to popup, added some admin logging. It was causing too much adminlog spam otherwise
* Reorganized some files, final build??
* Changed the adminlog type from Verb to new type ItemConfigure
* More cleanup, fix sprite reference maybe
* Keronshb's suggestions, fixed some stuff, made hit sound use the meaty punch sfx
* Adds support for hiding speak/whisper/emote from adminlogs, makes northstar speak again!
* Some file shuffling, some of Keronshb's requests. Might appear a bit funky in github because vscode kept duplicating files for some reason and I had to delete them
* Made it work with the latest changes on Master
* Final? cleanup, upped dmg to 8, made ui not activate on activateinhand, instead you need to right click
* Set value to 0 credits, that's all
* Well that was much easier than I made it out to be. Now you can only activate the gloves with right click, no more mispredicts.
* Update MeleeWeaponSystem.cs
Iunno why this got changed in the first place, but I'm changin it back
* emptycommit
* emptycommit
* The tiny fixening
2023-05-23 11:12:30 -07:00
if ( ! _configurationManager . GetCVar ( CCVars . OocEnableDuringRound ) )
2023-02-28 08:15:48 -08:00
_configurationManager . SetCVar ( CCVars . OocEnabled , true ) ;
break ;
}
2022-06-20 16:59:04 -04:00
}
2022-11-15 17:09:27 +13:00
/// <summary>
/// Sends an in-character chat message to relevant clients.
/// </summary>
/// <param name="source">The entity that is speaking</param>
/// <param name="message">The message being spoken or emoted</param>
/// <param name="desiredType">The chat type</param>
/// <param name="hideChat">Whether or not this message should appear in the chat window</param>
Northstar Gloves (#16021)
* Added Gloves of North Star, no sprite or talking yet...
* Added sprites for the gloves of the north star...
* Replaced more placeholder sprites for northstar gloves...
* Added gloves of the north star to uplink...
* Added speech on hit, not yet configureable
* Not functional yet, but a step in the right direction I hope...
* IT WORKS!!
* Licensing and cleanup
* Reduced attack speed, changed from chat to popup, added some admin logging. It was causing too much adminlog spam otherwise
* Reorganized some files, final build??
* Changed the adminlog type from Verb to new type ItemConfigure
* More cleanup, fix sprite reference maybe
* Keronshb's suggestions, fixed some stuff, made hit sound use the meaty punch sfx
* Adds support for hiding speak/whisper/emote from adminlogs, makes northstar speak again!
* Some file shuffling, some of Keronshb's requests. Might appear a bit funky in github because vscode kept duplicating files for some reason and I had to delete them
* Made it work with the latest changes on Master
* Final? cleanup, upped dmg to 8, made ui not activate on activateinhand, instead you need to right click
* Set value to 0 credits, that's all
* Well that was much easier than I made it out to be. Now you can only activate the gloves with right click, no more mispredicts.
* Update MeleeWeaponSystem.cs
Iunno why this got changed in the first place, but I'm changin it back
* emptycommit
* emptycommit
* The tiny fixening
2023-05-23 11:12:30 -07:00
/// <param name="hideLog">Whether or not this message should appear in the adminlog window</param>
2022-11-15 17:09:27 +13:00
/// <param name="shell"></param>
/// <param name="player">The player doing the speaking</param>
/// <param name="nameOverride">The name to use for the speaking entity. Usually this should just be modified via <see cref="TransformSpeakerNameEvent"/>. If this is set, the event will not get raised.</param>
Northstar Gloves (#16021)
* Added Gloves of North Star, no sprite or talking yet...
* Added sprites for the gloves of the north star...
* Replaced more placeholder sprites for northstar gloves...
* Added gloves of the north star to uplink...
* Added speech on hit, not yet configureable
* Not functional yet, but a step in the right direction I hope...
* IT WORKS!!
* Licensing and cleanup
* Reduced attack speed, changed from chat to popup, added some admin logging. It was causing too much adminlog spam otherwise
* Reorganized some files, final build??
* Changed the adminlog type from Verb to new type ItemConfigure
* More cleanup, fix sprite reference maybe
* Keronshb's suggestions, fixed some stuff, made hit sound use the meaty punch sfx
* Adds support for hiding speak/whisper/emote from adminlogs, makes northstar speak again!
* Some file shuffling, some of Keronshb's requests. Might appear a bit funky in github because vscode kept duplicating files for some reason and I had to delete them
* Made it work with the latest changes on Master
* Final? cleanup, upped dmg to 8, made ui not activate on activateinhand, instead you need to right click
* Set value to 0 credits, that's all
* Well that was much easier than I made it out to be. Now you can only activate the gloves with right click, no more mispredicts.
* Update MeleeWeaponSystem.cs
Iunno why this got changed in the first place, but I'm changin it back
* emptycommit
* emptycommit
* The tiny fixening
2023-05-23 11:12:30 -07:00
public void TrySendInGameICMessage ( EntityUid source , string message , InGameICChatType desiredType , bool hideChat , bool hideLog = false ,
2023-05-04 20:08:08 +01:00
IConsoleShell ? shell = null , IPlayerSession ? player = null , string? nameOverride = null , bool checkRadioPrefix = true )
{
Northstar Gloves (#16021)
* Added Gloves of North Star, no sprite or talking yet...
* Added sprites for the gloves of the north star...
* Replaced more placeholder sprites for northstar gloves...
* Added gloves of the north star to uplink...
* Added speech on hit, not yet configureable
* Not functional yet, but a step in the right direction I hope...
* IT WORKS!!
* Licensing and cleanup
* Reduced attack speed, changed from chat to popup, added some admin logging. It was causing too much adminlog spam otherwise
* Reorganized some files, final build??
* Changed the adminlog type from Verb to new type ItemConfigure
* More cleanup, fix sprite reference maybe
* Keronshb's suggestions, fixed some stuff, made hit sound use the meaty punch sfx
* Adds support for hiding speak/whisper/emote from adminlogs, makes northstar speak again!
* Some file shuffling, some of Keronshb's requests. Might appear a bit funky in github because vscode kept duplicating files for some reason and I had to delete them
* Made it work with the latest changes on Master
* Final? cleanup, upped dmg to 8, made ui not activate on activateinhand, instead you need to right click
* Set value to 0 credits, that's all
* Well that was much easier than I made it out to be. Now you can only activate the gloves with right click, no more mispredicts.
* Update MeleeWeaponSystem.cs
Iunno why this got changed in the first place, but I'm changin it back
* emptycommit
* emptycommit
* The tiny fixening
2023-05-23 11:12:30 -07:00
TrySendInGameICMessage ( source , message , desiredType , hideChat ? ChatTransmitRange . HideChat : ChatTransmitRange . Normal , hideLog , shell , player , nameOverride , checkRadioPrefix ) ;
2023-05-04 20:08:08 +01:00
}
/// <summary>
/// Sends an in-character chat message to relevant clients.
/// </summary>
/// <param name="source">The entity that is speaking</param>
/// <param name="message">The message being spoken or emoted</param>
/// <param name="desiredType">The chat type</param>
/// <param name="range">Conceptual range of transmission, if it shows in the chat window, if it shows to far-away ghosts or ghosts at all...</param>
/// <param name="shell"></param>
/// <param name="player">The player doing the speaking</param>
/// <param name="nameOverride">The name to use for the speaking entity. Usually this should just be modified via <see cref="TransformSpeakerNameEvent"/>. If this is set, the event will not get raised.</param>
Northstar Gloves (#16021)
* Added Gloves of North Star, no sprite or talking yet...
* Added sprites for the gloves of the north star...
* Replaced more placeholder sprites for northstar gloves...
* Added gloves of the north star to uplink...
* Added speech on hit, not yet configureable
* Not functional yet, but a step in the right direction I hope...
* IT WORKS!!
* Licensing and cleanup
* Reduced attack speed, changed from chat to popup, added some admin logging. It was causing too much adminlog spam otherwise
* Reorganized some files, final build??
* Changed the adminlog type from Verb to new type ItemConfigure
* More cleanup, fix sprite reference maybe
* Keronshb's suggestions, fixed some stuff, made hit sound use the meaty punch sfx
* Adds support for hiding speak/whisper/emote from adminlogs, makes northstar speak again!
* Some file shuffling, some of Keronshb's requests. Might appear a bit funky in github because vscode kept duplicating files for some reason and I had to delete them
* Made it work with the latest changes on Master
* Final? cleanup, upped dmg to 8, made ui not activate on activateinhand, instead you need to right click
* Set value to 0 credits, that's all
* Well that was much easier than I made it out to be. Now you can only activate the gloves with right click, no more mispredicts.
* Update MeleeWeaponSystem.cs
Iunno why this got changed in the first place, but I'm changin it back
* emptycommit
* emptycommit
* The tiny fixening
2023-05-23 11:12:30 -07:00
public void TrySendInGameICMessage ( EntityUid source , string message , InGameICChatType desiredType , ChatTransmitRange range , bool hideLog = false ,
2022-11-23 00:52:19 +13:00
IConsoleShell ? shell = null , IPlayerSession ? player = null , string? nameOverride = null , bool checkRadioPrefix = true )
2022-03-30 22:21:58 -07:00
{
if ( HasComp < GhostComponent > ( source ) )
{
// Ghosts can only send dead chat messages, so we'll forward it to InGame OOC.
2023-05-04 20:08:08 +01:00
TrySendInGameOOCMessage ( source , message , InGameOOCChatType . Dead , range = = ChatTransmitRange . HideChat , shell , player ) ;
2022-03-30 22:21:58 -07:00
return ;
}
2022-04-01 00:08:26 -07:00
// Sus
if ( player ? . AttachedEntity is { Valid : true } entity & & source ! = entity )
{
return ;
}
2022-03-30 22:21:58 -07:00
if ( ! CanSendInGame ( message , shell , player ) )
return ;
2023-02-19 06:27:56 +13:00
if ( desiredType = = InGameICChatType . Speak & & message . StartsWith ( LocalPrefix ) )
{
// prevent radios and remove prefix.
checkRadioPrefix = false ;
message = message [ 1. . ] ;
}
2022-04-24 20:15:40 -04:00
bool shouldCapitalize = ( desiredType ! = InGameICChatType . Emote ) ;
2022-08-31 13:42:46 +01:00
bool shouldPunctuate = _configurationManager . GetCVar ( CCVars . ChatPunctuation ) ;
2022-04-24 20:15:40 -04:00
2022-08-31 13:42:46 +01:00
message = SanitizeInGameICMessage ( source , message , out var emoteStr , shouldCapitalize , shouldPunctuate ) ;
2022-03-30 22:21:58 -07:00
2022-04-01 00:08:26 -07:00
// Was there an emote in the message? If so, send it.
2022-03-30 22:21:58 -07:00
if ( player ! = null & & emoteStr ! = message & & emoteStr ! = null )
{
2023-05-04 20:08:08 +01:00
SendEntityEmote ( source , emoteStr , range , nameOverride ) ;
2022-03-30 22:21:58 -07:00
}
2022-04-01 20:09:54 -07:00
// This can happen if the entire string is sanitized out.
if ( string . IsNullOrEmpty ( message ) )
return ;
2022-12-14 12:24:49 +11:00
// This message may have a radio prefix, and should then be whispered to the resolved radio channel
if ( checkRadioPrefix )
{
2023-02-19 06:27:56 +13:00
if ( TryProccessRadioMessage ( source , message , out var modMessage , out var channel ) )
2022-12-14 12:24:49 +11:00
{
2023-05-04 20:08:08 +01:00
SendEntityWhisper ( source , modMessage , range , channel , nameOverride ) ;
2022-12-14 12:24:49 +11:00
return ;
}
}
2022-03-30 22:21:58 -07:00
// Otherwise, send whatever type.
switch ( desiredType )
{
case InGameICChatType . Speak :
Northstar Gloves (#16021)
* Added Gloves of North Star, no sprite or talking yet...
* Added sprites for the gloves of the north star...
* Replaced more placeholder sprites for northstar gloves...
* Added gloves of the north star to uplink...
* Added speech on hit, not yet configureable
* Not functional yet, but a step in the right direction I hope...
* IT WORKS!!
* Licensing and cleanup
* Reduced attack speed, changed from chat to popup, added some admin logging. It was causing too much adminlog spam otherwise
* Reorganized some files, final build??
* Changed the adminlog type from Verb to new type ItemConfigure
* More cleanup, fix sprite reference maybe
* Keronshb's suggestions, fixed some stuff, made hit sound use the meaty punch sfx
* Adds support for hiding speak/whisper/emote from adminlogs, makes northstar speak again!
* Some file shuffling, some of Keronshb's requests. Might appear a bit funky in github because vscode kept duplicating files for some reason and I had to delete them
* Made it work with the latest changes on Master
* Final? cleanup, upped dmg to 8, made ui not activate on activateinhand, instead you need to right click
* Set value to 0 credits, that's all
* Well that was much easier than I made it out to be. Now you can only activate the gloves with right click, no more mispredicts.
* Update MeleeWeaponSystem.cs
Iunno why this got changed in the first place, but I'm changin it back
* emptycommit
* emptycommit
* The tiny fixening
2023-05-23 11:12:30 -07:00
SendEntitySpeak ( source , message , range , nameOverride , hideLog ) ;
2022-03-30 22:21:58 -07:00
break ;
case InGameICChatType . Whisper :
Northstar Gloves (#16021)
* Added Gloves of North Star, no sprite or talking yet...
* Added sprites for the gloves of the north star...
* Replaced more placeholder sprites for northstar gloves...
* Added gloves of the north star to uplink...
* Added speech on hit, not yet configureable
* Not functional yet, but a step in the right direction I hope...
* IT WORKS!!
* Licensing and cleanup
* Reduced attack speed, changed from chat to popup, added some admin logging. It was causing too much adminlog spam otherwise
* Reorganized some files, final build??
* Changed the adminlog type from Verb to new type ItemConfigure
* More cleanup, fix sprite reference maybe
* Keronshb's suggestions, fixed some stuff, made hit sound use the meaty punch sfx
* Adds support for hiding speak/whisper/emote from adminlogs, makes northstar speak again!
* Some file shuffling, some of Keronshb's requests. Might appear a bit funky in github because vscode kept duplicating files for some reason and I had to delete them
* Made it work with the latest changes on Master
* Final? cleanup, upped dmg to 8, made ui not activate on activateinhand, instead you need to right click
* Set value to 0 credits, that's all
* Well that was much easier than I made it out to be. Now you can only activate the gloves with right click, no more mispredicts.
* Update MeleeWeaponSystem.cs
Iunno why this got changed in the first place, but I'm changin it back
* emptycommit
* emptycommit
* The tiny fixening
2023-05-23 11:12:30 -07:00
SendEntityWhisper ( source , message , range , null , nameOverride , hideLog ) ;
2022-03-30 22:21:58 -07:00
break ;
case InGameICChatType . Emote :
Northstar Gloves (#16021)
* Added Gloves of North Star, no sprite or talking yet...
* Added sprites for the gloves of the north star...
* Replaced more placeholder sprites for northstar gloves...
* Added gloves of the north star to uplink...
* Added speech on hit, not yet configureable
* Not functional yet, but a step in the right direction I hope...
* IT WORKS!!
* Licensing and cleanup
* Reduced attack speed, changed from chat to popup, added some admin logging. It was causing too much adminlog spam otherwise
* Reorganized some files, final build??
* Changed the adminlog type from Verb to new type ItemConfigure
* More cleanup, fix sprite reference maybe
* Keronshb's suggestions, fixed some stuff, made hit sound use the meaty punch sfx
* Adds support for hiding speak/whisper/emote from adminlogs, makes northstar speak again!
* Some file shuffling, some of Keronshb's requests. Might appear a bit funky in github because vscode kept duplicating files for some reason and I had to delete them
* Made it work with the latest changes on Master
* Final? cleanup, upped dmg to 8, made ui not activate on activateinhand, instead you need to right click
* Set value to 0 credits, that's all
* Well that was much easier than I made it out to be. Now you can only activate the gloves with right click, no more mispredicts.
* Update MeleeWeaponSystem.cs
Iunno why this got changed in the first place, but I'm changin it back
* emptycommit
* emptycommit
* The tiny fixening
2023-05-23 11:12:30 -07:00
SendEntityEmote ( source , message , range , nameOverride , hideLog ) ;
2022-03-30 22:21:58 -07:00
break ;
}
}
public void TrySendInGameOOCMessage ( EntityUid source , string message , InGameOOCChatType type , bool hideChat ,
IConsoleShell ? shell = null , IPlayerSession ? player = null )
{
if ( ! CanSendInGame ( message , shell , player ) )
return ;
// It doesn't make any sense for a non-player to send in-game OOC messages, whereas non-players may be sending
// in-game IC messages.
if ( player ? . AttachedEntity is not { Valid : true } entity | | source ! = entity )
return ;
message = SanitizeInGameOOCMessage ( message ) ;
2022-07-26 09:58:19 -04:00
var sendType = type ;
// If dead player LOOC is disabled, unless you are an aghost, send dead messages to dead chat
if ( ! _adminManager . IsAdmin ( player ) & & ! _deadLoocEnabled & &
( HasComp < GhostComponent > ( source ) | | _mobStateSystem . IsDead ( source ) ) )
sendType = InGameOOCChatType . Dead ;
switch ( sendType )
2022-03-30 22:21:58 -07:00
{
case InGameOOCChatType . Dead :
SendDeadChat ( source , player , message , hideChat ) ;
break ;
case InGameOOCChatType . Looc :
SendLOOC ( source , player , message , hideChat ) ;
break ;
}
}
2022-06-03 21:37:35 +10:00
#region Announcements
/// <summary>
2022-07-04 16:00:51 +10:00
/// Dispatches an announcement to all.
2022-06-03 21:37:35 +10:00
/// </summary>
/// <param name="message">The contents of the message</param>
/// <param name="sender">The sender (Communications Console in Communications Console Announcement)</param>
2022-07-15 12:16:41 +03:00
/// <param name="playSound">Play the announcement sound</param>
2022-06-03 21:37:35 +10:00
/// <param name="colorOverride">Optional color for the announcement message</param>
2022-07-04 16:00:51 +10:00
public void DispatchGlobalAnnouncement ( string message , string sender = "Central Command" ,
2022-07-15 12:16:41 +03:00
bool playSound = true , SoundSpecifier ? announcementSound = null , Color ? colorOverride = null )
2022-06-03 21:37:35 +10:00
{
2022-10-18 19:59:09 +13:00
var wrappedMessage = Loc . GetString ( "chat-manager-sender-announcement-wrap-message" , ( "sender" , sender ) , ( "message" , FormattedMessage . EscapeText ( message ) ) ) ;
2022-11-23 00:52:19 +13:00
_chatManager . ChatMessageToAll ( ChatChannel . Radio , message , wrappedMessage , default , false , true , colorOverride ) ;
2022-07-15 12:16:41 +03:00
if ( playSound )
2022-06-03 21:37:35 +10:00
{
2022-07-15 12:16:41 +03:00
SoundSystem . Play ( announcementSound ? . GetSound ( ) ? ? DefaultAnnouncementSound , Filter . Broadcast ( ) , AudioParams . Default . WithVolume ( - 2f ) ) ;
2022-06-03 21:37:35 +10:00
}
_adminLogger . Add ( LogType . Chat , LogImpact . Low , $"Global station announcement from {sender}: {message}" ) ;
}
/// <summary>
/// Dispatches an announcement on a specific station
/// </summary>
/// <param name="source">The entity making the announcement (used to determine the station)</param>
/// <param name="message">The contents of the message</param>
/// <param name="sender">The sender (Communications Console in Communications Console Announcement)</param>
/// <param name="playDefaultSound">Play the announcement sound</param>
/// <param name="colorOverride">Optional color for the announcement message</param>
2022-07-15 12:16:41 +03:00
public void DispatchStationAnnouncement ( EntityUid source , string message , string sender = "Central Command" ,
bool playDefaultSound = true , SoundSpecifier ? announcementSound = null , Color ? colorOverride = null )
2022-06-03 21:37:35 +10:00
{
2022-10-18 19:59:09 +13:00
var wrappedMessage = Loc . GetString ( "chat-manager-sender-announcement-wrap-message" , ( "sender" , sender ) , ( "message" , FormattedMessage . EscapeText ( message ) ) ) ;
2022-06-03 21:37:35 +10:00
var station = _stationSystem . GetOwningStation ( source ) ;
2022-06-04 19:09:04 +10:00
if ( station = = null )
2022-06-03 21:37:35 +10:00
{
2022-06-04 19:09:04 +10:00
// you can't make a station announcement without a station
return ;
2022-06-03 21:37:35 +10:00
}
2022-06-04 19:09:04 +10:00
if ( ! EntityManager . TryGetComponent < StationDataComponent > ( station , out var stationDataComp ) ) return ;
2022-07-04 16:00:51 +10:00
var filter = _stationSystem . GetInStation ( stationDataComp ) ;
2022-06-03 21:37:35 +10:00
2022-11-23 00:52:19 +13:00
_chatManager . ChatMessageToManyFiltered ( filter , ChatChannel . Radio , message , wrappedMessage , source , false , true , colorOverride ) ;
2022-06-03 21:37:35 +10:00
if ( playDefaultSound )
{
2022-07-15 12:16:41 +03:00
SoundSystem . Play ( announcementSound ? . GetSound ( ) ? ? DefaultAnnouncementSound , filter , AudioParams . Default . WithVolume ( - 2f ) ) ;
2022-06-03 21:37:35 +10:00
}
_adminLogger . Add ( LogType . Chat , LogImpact . Low , $"Station Announcement on {station} from {sender}: {message}" ) ;
}
#endregion
2022-03-30 22:21:58 -07:00
#region Private API
Northstar Gloves (#16021)
* Added Gloves of North Star, no sprite or talking yet...
* Added sprites for the gloves of the north star...
* Replaced more placeholder sprites for northstar gloves...
* Added gloves of the north star to uplink...
* Added speech on hit, not yet configureable
* Not functional yet, but a step in the right direction I hope...
* IT WORKS!!
* Licensing and cleanup
* Reduced attack speed, changed from chat to popup, added some admin logging. It was causing too much adminlog spam otherwise
* Reorganized some files, final build??
* Changed the adminlog type from Verb to new type ItemConfigure
* More cleanup, fix sprite reference maybe
* Keronshb's suggestions, fixed some stuff, made hit sound use the meaty punch sfx
* Adds support for hiding speak/whisper/emote from adminlogs, makes northstar speak again!
* Some file shuffling, some of Keronshb's requests. Might appear a bit funky in github because vscode kept duplicating files for some reason and I had to delete them
* Made it work with the latest changes on Master
* Final? cleanup, upped dmg to 8, made ui not activate on activateinhand, instead you need to right click
* Set value to 0 credits, that's all
* Well that was much easier than I made it out to be. Now you can only activate the gloves with right click, no more mispredicts.
* Update MeleeWeaponSystem.cs
Iunno why this got changed in the first place, but I'm changin it back
* emptycommit
* emptycommit
* The tiny fixening
2023-05-23 11:12:30 -07:00
private void SendEntitySpeak ( EntityUid source , string originalMessage , ChatTransmitRange range , string? nameOverride , bool hideLog = false )
2022-03-30 22:21:58 -07:00
{
2022-07-26 16:49:23 -07:00
if ( ! _actionBlocker . CanSpeak ( source ) )
return ;
2022-03-30 22:21:58 -07:00
2022-12-14 12:24:49 +11:00
var message = TransformSpeech ( source , originalMessage ) ;
2022-08-02 15:46:10 +02:00
if ( message . Length = = 0 )
return ;
2022-11-15 17:09:27 +13:00
// get the entity's apparent name (if no override provided).
string name ;
if ( nameOverride ! = null )
{
name = nameOverride ;
}
else
{
var nameEv = new TransformSpeakerNameEvent ( source , Name ( source ) ) ;
RaiseLocalEvent ( source , nameEv ) ;
name = nameEv . Name ;
}
name = FormattedMessage . EscapeText ( name ) ;
2022-10-18 19:59:09 +13:00
var wrappedMessage = Loc . GetString ( "chat-manager-entity-say-wrap-message" ,
( "entityName" , name ) , ( "message" , FormattedMessage . EscapeText ( message ) ) ) ;
2022-03-30 22:21:58 -07:00
2023-05-04 20:08:08 +01:00
SendInVoiceRange ( ChatChannel . Local , message , wrappedMessage , source , range ) ;
2022-03-30 22:21:58 -07:00
2022-12-14 12:24:49 +11:00
var ev = new EntitySpokeEvent ( source , message , null , null ) ;
2022-11-15 17:09:27 +13:00
RaiseLocalEvent ( source , ev , true ) ;
2022-06-27 15:56:38 +12:00
2022-08-07 20:21:56 -03:00
// To avoid logging any messages sent by entities that are not players, like vendors, cloning, etc.
Northstar Gloves (#16021)
* Added Gloves of North Star, no sprite or talking yet...
* Added sprites for the gloves of the north star...
* Replaced more placeholder sprites for northstar gloves...
* Added gloves of the north star to uplink...
* Added speech on hit, not yet configureable
* Not functional yet, but a step in the right direction I hope...
* IT WORKS!!
* Licensing and cleanup
* Reduced attack speed, changed from chat to popup, added some admin logging. It was causing too much adminlog spam otherwise
* Reorganized some files, final build??
* Changed the adminlog type from Verb to new type ItemConfigure
* More cleanup, fix sprite reference maybe
* Keronshb's suggestions, fixed some stuff, made hit sound use the meaty punch sfx
* Adds support for hiding speak/whisper/emote from adminlogs, makes northstar speak again!
* Some file shuffling, some of Keronshb's requests. Might appear a bit funky in github because vscode kept duplicating files for some reason and I had to delete them
* Made it work with the latest changes on Master
* Final? cleanup, upped dmg to 8, made ui not activate on activateinhand, instead you need to right click
* Set value to 0 credits, that's all
* Well that was much easier than I made it out to be. Now you can only activate the gloves with right click, no more mispredicts.
* Update MeleeWeaponSystem.cs
Iunno why this got changed in the first place, but I'm changin it back
* emptycommit
* emptycommit
* The tiny fixening
2023-05-23 11:12:30 -07:00
// Also doesn't log if hideLog is true.
if ( ! HasComp < ActorComponent > ( source ) | | hideLog = = true )
2022-08-07 20:21:56 -03:00
return ;
2022-06-27 15:56:38 +12:00
if ( originalMessage = = message )
2023-02-11 13:26:44 -06:00
{
if ( name ! = Name ( source ) )
_adminLogger . Add ( LogType . Chat , LogImpact . Low , $"Say from {ToPrettyString(source):user} as {name}: {originalMessage}." ) ;
else
_adminLogger . Add ( LogType . Chat , LogImpact . Low , $"Say from {ToPrettyString(source):user}: {originalMessage}." ) ;
}
2022-06-27 15:56:38 +12:00
else
2023-02-11 13:26:44 -06:00
{
if ( name ! = Name ( source ) )
_adminLogger . Add ( LogType . Chat , LogImpact . Low ,
$"Say from {ToPrettyString(source):user} as {name}, original: {originalMessage}, transformed: {message}." ) ;
else
_adminLogger . Add ( LogType . Chat , LogImpact . Low ,
$"Say from {ToPrettyString(source):user}, original: {originalMessage}, transformed: {message}." ) ;
}
2022-03-30 22:21:58 -07:00
}
Northstar Gloves (#16021)
* Added Gloves of North Star, no sprite or talking yet...
* Added sprites for the gloves of the north star...
* Replaced more placeholder sprites for northstar gloves...
* Added gloves of the north star to uplink...
* Added speech on hit, not yet configureable
* Not functional yet, but a step in the right direction I hope...
* IT WORKS!!
* Licensing and cleanup
* Reduced attack speed, changed from chat to popup, added some admin logging. It was causing too much adminlog spam otherwise
* Reorganized some files, final build??
* Changed the adminlog type from Verb to new type ItemConfigure
* More cleanup, fix sprite reference maybe
* Keronshb's suggestions, fixed some stuff, made hit sound use the meaty punch sfx
* Adds support for hiding speak/whisper/emote from adminlogs, makes northstar speak again!
* Some file shuffling, some of Keronshb's requests. Might appear a bit funky in github because vscode kept duplicating files for some reason and I had to delete them
* Made it work with the latest changes on Master
* Final? cleanup, upped dmg to 8, made ui not activate on activateinhand, instead you need to right click
* Set value to 0 credits, that's all
* Well that was much easier than I made it out to be. Now you can only activate the gloves with right click, no more mispredicts.
* Update MeleeWeaponSystem.cs
Iunno why this got changed in the first place, but I'm changin it back
* emptycommit
* emptycommit
* The tiny fixening
2023-05-23 11:12:30 -07:00
private void SendEntityWhisper ( EntityUid source , string originalMessage , ChatTransmitRange range , RadioChannelPrototype ? channel , string? nameOverride , bool hideLog = false )
2022-03-30 22:21:58 -07:00
{
2022-07-26 16:49:23 -07:00
if ( ! _actionBlocker . CanSpeak ( source ) )
return ;
2022-03-30 22:21:58 -07:00
2022-06-29 15:13:01 +12:00
var message = TransformSpeech ( source , originalMessage ) ;
if ( message . Length = = 0 )
return ;
2022-03-30 22:21:58 -07:00
var obfuscatedMessage = ObfuscateMessageReadability ( message , 0.2f ) ;
2022-11-15 17:09:27 +13:00
// get the entity's apparent name (if no override provided).
string name ;
if ( nameOverride ! = null )
{
name = nameOverride ;
}
else
{
var nameEv = new TransformSpeakerNameEvent ( source , Name ( source ) ) ;
RaiseLocalEvent ( source , nameEv ) ;
name = nameEv . Name ;
}
name = FormattedMessage . EscapeText ( name ) ;
2022-03-30 22:21:58 -07:00
2022-11-23 00:52:19 +13:00
var wrappedMessage = Loc . GetString ( "chat-manager-entity-whisper-wrap-message" ,
( "entityName" , name ) , ( "message" , FormattedMessage . EscapeText ( message ) ) ) ;
var wrappedobfuscatedMessage = Loc . GetString ( "chat-manager-entity-whisper-wrap-message" ,
( "entityName" , name ) , ( "message" , FormattedMessage . EscapeText ( obfuscatedMessage ) ) ) ;
2022-11-15 17:09:27 +13:00
foreach ( var ( session , data ) in GetRecipients ( source , VoiceRange ) )
2022-03-30 22:21:58 -07:00
{
if ( session . AttachedEntity is not { Valid : true } playerEntity )
continue ;
2023-05-04 20:08:08 +01:00
if ( MessageRangeCheck ( session , data , range ) ! = MessageRangeCheckResult . Full )
2022-11-15 17:09:27 +13:00
continue ; // Won't get logged to chat, and ghosts are too far away to see the pop-up, so we just won't send it to them.
2022-03-30 22:21:58 -07:00
2022-11-15 17:09:27 +13:00
if ( data . Range < = WhisperRange )
2023-05-04 20:08:08 +01:00
_chatManager . ChatMessageToOne ( ChatChannel . Whisper , message , wrappedMessage , source , false , session . ConnectedClient ) ;
2022-03-30 22:21:58 -07:00
else
2023-05-04 20:08:08 +01:00
_chatManager . ChatMessageToOne ( ChatChannel . Whisper , obfuscatedMessage , wrappedobfuscatedMessage , source , false , session . ConnectedClient ) ;
2022-03-30 22:21:58 -07:00
}
2023-06-19 05:23:31 +12:00
_replay . RecordServerMessage ( new ChatMessage ( ChatChannel . Whisper , message , wrappedMessage , source , MessageRangeHideChatForReplay ( range ) ) ) ;
2022-11-23 00:52:19 +13:00
2022-11-15 17:09:27 +13:00
var ev = new EntitySpokeEvent ( source , message , channel , obfuscatedMessage ) ;
RaiseLocalEvent ( source , ev , true ) ;
Northstar Gloves (#16021)
* Added Gloves of North Star, no sprite or talking yet...
* Added sprites for the gloves of the north star...
* Replaced more placeholder sprites for northstar gloves...
* Added gloves of the north star to uplink...
* Added speech on hit, not yet configureable
* Not functional yet, but a step in the right direction I hope...
* IT WORKS!!
* Licensing and cleanup
* Reduced attack speed, changed from chat to popup, added some admin logging. It was causing too much adminlog spam otherwise
* Reorganized some files, final build??
* Changed the adminlog type from Verb to new type ItemConfigure
* More cleanup, fix sprite reference maybe
* Keronshb's suggestions, fixed some stuff, made hit sound use the meaty punch sfx
* Adds support for hiding speak/whisper/emote from adminlogs, makes northstar speak again!
* Some file shuffling, some of Keronshb's requests. Might appear a bit funky in github because vscode kept duplicating files for some reason and I had to delete them
* Made it work with the latest changes on Master
* Final? cleanup, upped dmg to 8, made ui not activate on activateinhand, instead you need to right click
* Set value to 0 credits, that's all
* Well that was much easier than I made it out to be. Now you can only activate the gloves with right click, no more mispredicts.
* Update MeleeWeaponSystem.cs
Iunno why this got changed in the first place, but I'm changin it back
* emptycommit
* emptycommit
* The tiny fixening
2023-05-23 11:12:30 -07:00
if ( ! hideLog )
if ( originalMessage = = message )
{
if ( name ! = Name ( source ) )
_adminLogger . Add ( LogType . Chat , LogImpact . Low , $"Whisper from {ToPrettyString(source):user} as {name}: {originalMessage}." ) ;
else
_adminLogger . Add ( LogType . Chat , LogImpact . Low , $"Whisper from {ToPrettyString(source):user}: {originalMessage}." ) ;
}
2023-02-11 13:26:44 -06:00
else
Northstar Gloves (#16021)
* Added Gloves of North Star, no sprite or talking yet...
* Added sprites for the gloves of the north star...
* Replaced more placeholder sprites for northstar gloves...
* Added gloves of the north star to uplink...
* Added speech on hit, not yet configureable
* Not functional yet, but a step in the right direction I hope...
* IT WORKS!!
* Licensing and cleanup
* Reduced attack speed, changed from chat to popup, added some admin logging. It was causing too much adminlog spam otherwise
* Reorganized some files, final build??
* Changed the adminlog type from Verb to new type ItemConfigure
* More cleanup, fix sprite reference maybe
* Keronshb's suggestions, fixed some stuff, made hit sound use the meaty punch sfx
* Adds support for hiding speak/whisper/emote from adminlogs, makes northstar speak again!
* Some file shuffling, some of Keronshb's requests. Might appear a bit funky in github because vscode kept duplicating files for some reason and I had to delete them
* Made it work with the latest changes on Master
* Final? cleanup, upped dmg to 8, made ui not activate on activateinhand, instead you need to right click
* Set value to 0 credits, that's all
* Well that was much easier than I made it out to be. Now you can only activate the gloves with right click, no more mispredicts.
* Update MeleeWeaponSystem.cs
Iunno why this got changed in the first place, but I'm changin it back
* emptycommit
* emptycommit
* The tiny fixening
2023-05-23 11:12:30 -07:00
{
if ( name ! = Name ( source ) )
_adminLogger . Add ( LogType . Chat , LogImpact . Low ,
2023-02-11 13:26:44 -06:00
$"Whisper from {ToPrettyString(source):user} as {name}, original: {originalMessage}, transformed: {message}." ) ;
Northstar Gloves (#16021)
* Added Gloves of North Star, no sprite or talking yet...
* Added sprites for the gloves of the north star...
* Replaced more placeholder sprites for northstar gloves...
* Added gloves of the north star to uplink...
* Added speech on hit, not yet configureable
* Not functional yet, but a step in the right direction I hope...
* IT WORKS!!
* Licensing and cleanup
* Reduced attack speed, changed from chat to popup, added some admin logging. It was causing too much adminlog spam otherwise
* Reorganized some files, final build??
* Changed the adminlog type from Verb to new type ItemConfigure
* More cleanup, fix sprite reference maybe
* Keronshb's suggestions, fixed some stuff, made hit sound use the meaty punch sfx
* Adds support for hiding speak/whisper/emote from adminlogs, makes northstar speak again!
* Some file shuffling, some of Keronshb's requests. Might appear a bit funky in github because vscode kept duplicating files for some reason and I had to delete them
* Made it work with the latest changes on Master
* Final? cleanup, upped dmg to 8, made ui not activate on activateinhand, instead you need to right click
* Set value to 0 credits, that's all
* Well that was much easier than I made it out to be. Now you can only activate the gloves with right click, no more mispredicts.
* Update MeleeWeaponSystem.cs
Iunno why this got changed in the first place, but I'm changin it back
* emptycommit
* emptycommit
* The tiny fixening
2023-05-23 11:12:30 -07:00
else
_adminLogger . Add ( LogType . Chat , LogImpact . Low ,
2023-02-11 13:26:44 -06:00
$"Whisper from {ToPrettyString(source):user}, original: {originalMessage}, transformed: {message}." ) ;
Northstar Gloves (#16021)
* Added Gloves of North Star, no sprite or talking yet...
* Added sprites for the gloves of the north star...
* Replaced more placeholder sprites for northstar gloves...
* Added gloves of the north star to uplink...
* Added speech on hit, not yet configureable
* Not functional yet, but a step in the right direction I hope...
* IT WORKS!!
* Licensing and cleanup
* Reduced attack speed, changed from chat to popup, added some admin logging. It was causing too much adminlog spam otherwise
* Reorganized some files, final build??
* Changed the adminlog type from Verb to new type ItemConfigure
* More cleanup, fix sprite reference maybe
* Keronshb's suggestions, fixed some stuff, made hit sound use the meaty punch sfx
* Adds support for hiding speak/whisper/emote from adminlogs, makes northstar speak again!
* Some file shuffling, some of Keronshb's requests. Might appear a bit funky in github because vscode kept duplicating files for some reason and I had to delete them
* Made it work with the latest changes on Master
* Final? cleanup, upped dmg to 8, made ui not activate on activateinhand, instead you need to right click
* Set value to 0 credits, that's all
* Well that was much easier than I made it out to be. Now you can only activate the gloves with right click, no more mispredicts.
* Update MeleeWeaponSystem.cs
Iunno why this got changed in the first place, but I'm changin it back
* emptycommit
* emptycommit
* The tiny fixening
2023-05-23 11:12:30 -07:00
}
2022-03-30 22:21:58 -07:00
}
Northstar Gloves (#16021)
* Added Gloves of North Star, no sprite or talking yet...
* Added sprites for the gloves of the north star...
* Replaced more placeholder sprites for northstar gloves...
* Added gloves of the north star to uplink...
* Added speech on hit, not yet configureable
* Not functional yet, but a step in the right direction I hope...
* IT WORKS!!
* Licensing and cleanup
* Reduced attack speed, changed from chat to popup, added some admin logging. It was causing too much adminlog spam otherwise
* Reorganized some files, final build??
* Changed the adminlog type from Verb to new type ItemConfigure
* More cleanup, fix sprite reference maybe
* Keronshb's suggestions, fixed some stuff, made hit sound use the meaty punch sfx
* Adds support for hiding speak/whisper/emote from adminlogs, makes northstar speak again!
* Some file shuffling, some of Keronshb's requests. Might appear a bit funky in github because vscode kept duplicating files for some reason and I had to delete them
* Made it work with the latest changes on Master
* Final? cleanup, upped dmg to 8, made ui not activate on activateinhand, instead you need to right click
* Set value to 0 credits, that's all
* Well that was much easier than I made it out to be. Now you can only activate the gloves with right click, no more mispredicts.
* Update MeleeWeaponSystem.cs
Iunno why this got changed in the first place, but I'm changin it back
* emptycommit
* emptycommit
* The tiny fixening
2023-05-23 11:12:30 -07:00
private void SendEntityEmote ( EntityUid source , string action , ChatTransmitRange range , string? nameOverride , bool hideLog = false , bool checkEmote = true )
2022-03-30 22:21:58 -07:00
{
if ( ! _actionBlocker . CanEmote ( source ) ) return ;
2022-11-15 17:09:27 +13:00
// get the entity's apparent name (if no override provided).
string name = FormattedMessage . EscapeText ( nameOverride ? ? Identity . Name ( source , EntityManager ) ) ;
2022-10-18 19:59:09 +13:00
2022-07-13 22:23:55 -07:00
// Emotes use Identity.Name, since it doesn't actually involve your voice at all.
2022-10-18 19:59:09 +13:00
var wrappedMessage = Loc . GetString ( "chat-manager-entity-me-wrap-message" ,
( "entityName" , name ) ,
2022-11-15 17:09:27 +13:00
( "message" , FormattedMessage . EscapeText ( action ) ) ) ;
2022-03-30 22:21:58 -07:00
2023-01-25 17:29:41 +01:00
if ( checkEmote )
TryEmoteChatInput ( source , action ) ;
2023-05-04 20:08:08 +01:00
SendInVoiceRange ( ChatChannel . Emotes , action , wrappedMessage , source , range ) ;
Northstar Gloves (#16021)
* Added Gloves of North Star, no sprite or talking yet...
* Added sprites for the gloves of the north star...
* Replaced more placeholder sprites for northstar gloves...
* Added gloves of the north star to uplink...
* Added speech on hit, not yet configureable
* Not functional yet, but a step in the right direction I hope...
* IT WORKS!!
* Licensing and cleanup
* Reduced attack speed, changed from chat to popup, added some admin logging. It was causing too much adminlog spam otherwise
* Reorganized some files, final build??
* Changed the adminlog type from Verb to new type ItemConfigure
* More cleanup, fix sprite reference maybe
* Keronshb's suggestions, fixed some stuff, made hit sound use the meaty punch sfx
* Adds support for hiding speak/whisper/emote from adminlogs, makes northstar speak again!
* Some file shuffling, some of Keronshb's requests. Might appear a bit funky in github because vscode kept duplicating files for some reason and I had to delete them
* Made it work with the latest changes on Master
* Final? cleanup, upped dmg to 8, made ui not activate on activateinhand, instead you need to right click
* Set value to 0 credits, that's all
* Well that was much easier than I made it out to be. Now you can only activate the gloves with right click, no more mispredicts.
* Update MeleeWeaponSystem.cs
Iunno why this got changed in the first place, but I'm changin it back
* emptycommit
* emptycommit
* The tiny fixening
2023-05-23 11:12:30 -07:00
if ( ! hideLog )
if ( name ! = Name ( source ) )
_adminLogger . Add ( LogType . Chat , LogImpact . Low , $"Emote from {ToPrettyString(source):user} as {name}: {action}" ) ;
else
_adminLogger . Add ( LogType . Chat , LogImpact . Low , $"Emote from {ToPrettyString(source):user}: {action}" ) ;
2022-03-30 22:21:58 -07:00
}
// ReSharper disable once InconsistentNaming
private void SendLOOC ( EntityUid source , IPlayerSession player , string message , bool hideChat )
{
2022-10-18 19:59:09 +13:00
var name = FormattedMessage . EscapeText ( Identity . Name ( source , EntityManager ) ) ;
2022-03-30 22:21:58 -07:00
if ( _adminManager . IsAdmin ( player ) )
{
if ( ! _adminLoocEnabled ) return ;
}
else if ( ! _loocEnabled ) return ;
2022-10-18 19:59:09 +13:00
var wrappedMessage = Loc . GetString ( "chat-manager-entity-looc-wrap-message" ,
( "entityName" , name ) ,
( "message" , FormattedMessage . EscapeText ( message ) ) ) ;
2022-03-30 22:21:58 -07:00
2023-05-04 20:08:08 +01:00
SendInVoiceRange ( ChatChannel . LOOC , message , wrappedMessage , source , hideChat ? ChatTransmitRange . HideChat : ChatTransmitRange . Normal ) ;
2022-05-28 23:41:17 -07:00
_adminLogger . Add ( LogType . Chat , LogImpact . Low , $"LOOC from {player:Player}: {message}" ) ;
2022-03-30 22:21:58 -07:00
}
private void SendDeadChat ( EntityUid source , IPlayerSession player , string message , bool hideChat )
{
var clients = GetDeadChatClients ( ) ;
var playerName = Name ( source ) ;
2022-10-18 19:59:09 +13:00
string wrappedMessage ;
2022-03-30 22:21:58 -07:00
if ( _adminManager . IsAdmin ( player ) )
{
2022-10-18 19:59:09 +13:00
wrappedMessage = Loc . GetString ( "chat-manager-send-admin-dead-chat-wrap-message" ,
2022-03-30 22:21:58 -07:00
( "adminChannelName" , Loc . GetString ( "chat-manager-admin-channel-name" ) ) ,
2022-10-18 19:59:09 +13:00
( "userName" , player . ConnectedClient . UserName ) ,
( "message" , FormattedMessage . EscapeText ( message ) ) ) ;
2022-08-07 20:21:56 -03:00
_adminLogger . Add ( LogType . Chat , LogImpact . Low , $"Admin dead chat from {player:Player}: {message}" ) ;
2022-03-30 22:21:58 -07:00
}
else
{
2022-10-18 19:59:09 +13:00
wrappedMessage = Loc . GetString ( "chat-manager-send-dead-chat-wrap-message" ,
2022-03-30 22:21:58 -07:00
( "deadChannelName" , Loc . GetString ( "chat-manager-dead-channel-name" ) ) ,
2022-10-18 19:59:09 +13:00
( "playerName" , ( playerName ) ) ,
( "message" , FormattedMessage . EscapeText ( message ) ) ) ;
2022-08-07 20:21:56 -03:00
_adminLogger . Add ( LogType . Chat , LogImpact . Low , $"Dead chat from {player:Player}: {message}" ) ;
2022-03-30 22:21:58 -07:00
}
2022-11-23 00:52:19 +13:00
_chatManager . ChatMessageToMany ( ChatChannel . Dead , message , wrappedMessage , source , hideChat , false , clients . ToList ( ) ) ;
2022-08-07 20:21:56 -03:00
2022-03-30 22:21:58 -07:00
}
#endregion
#region Utility
2023-05-04 20:08:08 +01:00
private enum MessageRangeCheckResult {
Disallowed ,
HideChat ,
Full
}
/// <summary>
/// If hideChat should be set as far as replays are concerned.
/// </summary>
private bool MessageRangeHideChatForReplay ( ChatTransmitRange range )
{
return range = = ChatTransmitRange . HideChat ;
}
/// <summary>
/// Checks if a target as returned from GetRecipients should receive the message.
/// Keep in mind data.Range is -1 for out of range observers.
/// </summary>
private MessageRangeCheckResult MessageRangeCheck ( ICommonSession session , ICChatRecipientData data , ChatTransmitRange range )
{
var initialResult = MessageRangeCheckResult . Full ;
switch ( range )
{
case ChatTransmitRange . Normal :
initialResult = MessageRangeCheckResult . Full ;
break ;
case ChatTransmitRange . GhostRangeLimit :
initialResult = ( data . Observer & & data . Range < 0 & & ! _adminManager . IsAdmin ( ( IPlayerSession ) session ) ) ? MessageRangeCheckResult . HideChat : MessageRangeCheckResult . Full ;
break ;
case ChatTransmitRange . HideChat :
initialResult = MessageRangeCheckResult . HideChat ;
break ;
case ChatTransmitRange . NoGhosts :
initialResult = ( data . Observer & & ! _adminManager . IsAdmin ( ( IPlayerSession ) session ) ) ? MessageRangeCheckResult . Disallowed : MessageRangeCheckResult . Full ;
break ;
}
var insistHideChat = data . HideChatOverride ? ? false ;
var insistNoHideChat = ! ( data . HideChatOverride ? ? true ) ;
if ( insistHideChat & & initialResult = = MessageRangeCheckResult . Full )
return MessageRangeCheckResult . HideChat ;
if ( insistNoHideChat & & initialResult = = MessageRangeCheckResult . HideChat )
return MessageRangeCheckResult . Full ;
return initialResult ;
}
2022-03-30 22:21:58 -07:00
/// <summary>
/// Sends a chat message to the given players in range of the source entity.
/// </summary>
2023-05-04 20:08:08 +01:00
private void SendInVoiceRange ( ChatChannel channel , string message , string wrappedMessage , EntityUid source , ChatTransmitRange range )
2022-03-30 22:21:58 -07:00
{
2022-11-15 17:09:27 +13:00
foreach ( var ( session , data ) in GetRecipients ( source , VoiceRange ) )
{
2023-05-04 20:08:08 +01:00
var entRange = MessageRangeCheck ( session , data , range ) ;
if ( entRange = = MessageRangeCheckResult . Disallowed )
continue ;
var entHideChat = entRange = = MessageRangeCheckResult . HideChat ;
2022-11-15 17:09:27 +13:00
_chatManager . ChatMessageToOne ( channel , message , wrappedMessage , source , entHideChat , session . ConnectedClient ) ;
}
2022-11-23 00:52:19 +13:00
2023-06-19 05:23:31 +12:00
_replay . RecordServerMessage ( new ChatMessage ( channel , message , wrappedMessage , source , MessageRangeHideChatForReplay ( range ) ) ) ;
2022-03-30 22:21:58 -07:00
}
/// <summary>
/// Returns true if the given player is 'allowed' to send the given message, false otherwise.
/// </summary>
private bool CanSendInGame ( string message , IConsoleShell ? shell = null , IPlayerSession ? player = null )
{
// Non-players don't have to worry about these restrictions.
if ( player = = null )
return true ;
2023-06-18 11:33:19 -07:00
var mindContainerComponent = player . ContentData ( ) ? . Mind ;
2022-03-30 22:21:58 -07:00
2023-06-18 11:33:19 -07:00
if ( mindContainerComponent = = null )
2022-03-30 22:21:58 -07:00
{
shell ? . WriteError ( "You don't have a mind!" ) ;
return false ;
}
if ( player . AttachedEntity is not { Valid : true } _ )
{
shell ? . WriteError ( "You don't have an entity!" ) ;
return false ;
}
return ! _chatManager . MessageCharacterLimit ( player , message ) ;
}
// ReSharper disable once InconsistentNaming
2022-08-31 13:42:46 +01:00
private string SanitizeInGameICMessage ( EntityUid source , string message , out string? emoteStr , bool capitalize = true , bool punctuate = false )
2022-03-30 22:21:58 -07:00
{
var newMessage = message . Trim ( ) ;
2022-04-24 20:15:40 -04:00
if ( capitalize )
2022-08-31 13:42:46 +01:00
newMessage = SanitizeMessageCapital ( newMessage ) ;
if ( punctuate )
newMessage = SanitizeMessagePeriod ( newMessage ) ;
2022-03-30 22:21:58 -07:00
_sanitizer . TrySanitizeOutSmilies ( newMessage , source , out newMessage , out emoteStr ) ;
return newMessage ;
}
private string SanitizeInGameOOCMessage ( string message )
{
var newMessage = message . Trim ( ) ;
newMessage = FormattedMessage . EscapeText ( newMessage ) ;
return newMessage ;
}
2022-08-02 15:46:10 +02:00
public string TransformSpeech ( EntityUid sender , string message )
2022-03-30 22:21:58 -07:00
{
var ev = new TransformSpeechEvent ( sender , message ) ;
RaiseLocalEvent ( ev ) ;
return ev . Message ;
}
private IEnumerable < INetChannel > GetDeadChatClients ( )
{
return Filter . Empty ( )
2022-07-04 16:00:51 +10:00
. AddWhereAttachedEntity ( HasComp < GhostComponent > )
2022-03-30 22:21:58 -07:00
. Recipients
. Union ( _adminManager . ActiveAdmins )
. Select ( p = > p . ConnectedClient ) ;
}
2022-08-31 13:42:46 +01:00
private string SanitizeMessagePeriod ( string message )
{
if ( string . IsNullOrEmpty ( message ) )
return message ;
// Adds a period if the last character is a letter.
if ( char . IsLetter ( message [ ^ 1 ] ) )
message + = "." ;
return message ;
}
2022-11-15 17:09:27 +13:00
/// <summary>
/// Returns list of players and ranges for all players withing some range. Also returns observers with a range of -1.
/// </summary>
private Dictionary < ICommonSession , ICChatRecipientData > GetRecipients ( EntityUid source , float voiceRange )
2022-03-30 22:21:58 -07:00
{
2022-11-15 17:09:27 +13:00
// TODO proper speech occlusion
var recipients = new Dictionary < ICommonSession , ICChatRecipientData > ( ) ;
2022-03-30 22:21:58 -07:00
var ghosts = GetEntityQuery < GhostComponent > ( ) ;
var xforms = GetEntityQuery < TransformComponent > ( ) ;
var transformSource = xforms . GetComponent ( source ) ;
var sourceMapId = transformSource . MapID ;
var sourceCoords = transformSource . Coordinates ;
foreach ( var player in _playerManager . Sessions )
{
if ( player . AttachedEntity is not { Valid : true } playerEntity )
continue ;
var transformEntity = xforms . GetComponent ( playerEntity ) ;
2022-11-15 17:09:27 +13:00
if ( transformEntity . MapID ! = sourceMapId )
2022-03-30 22:21:58 -07:00
continue ;
2022-11-15 17:09:27 +13:00
var observer = ghosts . HasComponent ( playerEntity ) ;
// even if they are an observer, in some situations we still need the range
if ( sourceCoords . TryDistance ( EntityManager , transformEntity . Coordinates , out var distance ) & & distance < voiceRange )
{
recipients . Add ( player , new ICChatRecipientData ( distance , observer ) ) ;
continue ;
}
if ( observer )
recipients . Add ( player , new ICChatRecipientData ( - 1 , true ) ) ;
2022-03-30 22:21:58 -07:00
}
2022-11-15 17:09:27 +13:00
RaiseLocalEvent ( new ExpandICChatRecipientstEvent ( source , voiceRange , recipients ) ) ;
return recipients ;
}
public readonly record struct ICChatRecipientData ( float Range , bool Observer , bool? HideChatOverride = null )
{
2022-03-30 22:21:58 -07:00
}
private string ObfuscateMessageReadability ( string message , float chance )
{
var modifiedMessage = new StringBuilder ( message ) ;
for ( var i = 0 ; i < message . Length ; i + + )
{
if ( char . IsWhiteSpace ( ( modifiedMessage [ i ] ) ) )
{
continue ;
}
if ( _random . Prob ( 1 - chance ) )
{
modifiedMessage [ i ] = '~' ;
}
}
return modifiedMessage . ToString ( ) ;
}
#endregion
}
2022-11-15 17:09:27 +13:00
/// <summary>
/// This event is raised before chat messages are sent out to clients. This enables some systems to send the chat
/// messages to otherwise out-of view entities (e.g. for multiple viewports from cameras).
/// </summary>
2023-01-19 03:56:45 +01:00
public record ExpandICChatRecipientstEvent ( EntityUid Source , float VoiceRange , Dictionary < ICommonSession , ChatSystem . ICChatRecipientData > Recipients )
2022-11-15 17:09:27 +13:00
{
}
2022-09-28 19:22:27 -07:00
public sealed class TransformSpeakerNameEvent : EntityEventArgs
{
public EntityUid Sender ;
public string Name ;
public TransformSpeakerNameEvent ( EntityUid sender , string name )
{
Sender = sender ;
Name = name ;
}
}
2022-03-30 22:21:58 -07:00
/// <summary>
Northstar Gloves (#16021)
* Added Gloves of North Star, no sprite or talking yet...
* Added sprites for the gloves of the north star...
* Replaced more placeholder sprites for northstar gloves...
* Added gloves of the north star to uplink...
* Added speech on hit, not yet configureable
* Not functional yet, but a step in the right direction I hope...
* IT WORKS!!
* Licensing and cleanup
* Reduced attack speed, changed from chat to popup, added some admin logging. It was causing too much adminlog spam otherwise
* Reorganized some files, final build??
* Changed the adminlog type from Verb to new type ItemConfigure
* More cleanup, fix sprite reference maybe
* Keronshb's suggestions, fixed some stuff, made hit sound use the meaty punch sfx
* Adds support for hiding speak/whisper/emote from adminlogs, makes northstar speak again!
* Some file shuffling, some of Keronshb's requests. Might appear a bit funky in github because vscode kept duplicating files for some reason and I had to delete them
* Made it work with the latest changes on Master
* Final? cleanup, upped dmg to 8, made ui not activate on activateinhand, instead you need to right click
* Set value to 0 credits, that's all
* Well that was much easier than I made it out to be. Now you can only activate the gloves with right click, no more mispredicts.
* Update MeleeWeaponSystem.cs
Iunno why this got changed in the first place, but I'm changin it back
* emptycommit
* emptycommit
* The tiny fixening
2023-05-23 11:12:30 -07:00
/// Raised broadcast in order to transform speech.transmit
2022-03-30 22:21:58 -07:00
/// </summary>
public sealed class TransformSpeechEvent : EntityEventArgs
{
public EntityUid Sender ;
public string Message ;
public TransformSpeechEvent ( EntityUid sender , string message )
{
Sender = sender ;
Message = message ;
}
}
/// <summary>
/// Raised on an entity when it speaks, either through 'say' or 'whisper'.
/// </summary>
public sealed class EntitySpokeEvent : EntityEventArgs
{
2022-11-15 17:09:27 +13:00
public readonly EntityUid Source ;
public readonly string Message ;
public readonly string? ObfuscatedMessage ; // not null if this was a whisper
/// <summary>
/// If the entity was trying to speak into a radio, this was the channel they were trying to access. If a radio
/// message gets sent on this channel, this should be set to null to prevent duplicate messages.
/// </summary>
public RadioChannelPrototype ? Channel ;
2022-03-30 22:21:58 -07:00
2022-11-15 17:09:27 +13:00
public EntitySpokeEvent ( EntityUid source , string message , RadioChannelPrototype ? channel , string? obfuscatedMessage )
2022-03-30 22:21:58 -07:00
{
2022-11-15 17:09:27 +13:00
Source = source ;
2022-03-30 22:21:58 -07:00
Message = message ;
2022-11-15 17:09:27 +13:00
Channel = channel ;
ObfuscatedMessage = obfuscatedMessage ;
2022-03-30 22:21:58 -07:00
}
}
/// <summary>
/// InGame IC chat is for chat that is specifically ingame (not lobby) but is also in character, i.e. speaking.
/// </summary>
// ReSharper disable once InconsistentNaming
public enum InGameICChatType : byte
{
Speak ,
Emote ,
Whisper
}
/// <summary>
/// InGame OOC chat is for chat that is specifically ingame (not lobby) but is OOC, like deadchat or LOOC.
/// </summary>
public enum InGameOOCChatType : byte
{
Looc ,
Dead
}
2023-05-04 20:08:08 +01:00
/// <summary>
/// Controls transmission of chat.
/// </summary>
public enum ChatTransmitRange : byte
{
/// Acts normal, ghosts can hear across the map, etc.
Normal ,
/// Normal but ghosts are still range-limited.
GhostRangeLimit ,
/// Hidden from the chat window.
HideChat ,
/// Ghosts can't hear or see it at all. Regular players can if in-range.
NoGhosts
}