Add virtual chat API methods in Shared (#40895)

* move chat stuff to shared

* refactor: using cleanup +whitespaces + xml-doc

* review

---------

Co-authored-by: pa.pecherskij <pa.pecherskij@interfax.ru>
This commit is contained in:
slarticodefast
2025-10-19 21:08:27 +02:00
committed by GitHub
parent 1541c107e5
commit 1469b9484d
26 changed files with 248 additions and 153 deletions

View File

@@ -8,7 +8,9 @@ using Content.Shared.Speech;
using Content.Shared.Whitelist;
using Robust.Shared.Audio;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Console;
using Robust.Shared.Network;
using Robust.Shared.Player;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
using Robust.Shared.Utility;
@@ -322,6 +324,132 @@ public abstract partial class SharedChatSystem : EntitySystem
NetUserId? author = null
)
{ }
/// <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>
/// <param name="hideLog">Whether or not this message should appear in the adminlog window.</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>
/// <param name="checkRadioPrefix">Whether or not <paramref name="message"/> should be parsed with consideration of radio channel prefix text at start the start.</param>
/// <param name="ignoreActionBlocker">If set to true, action blocker will not be considered for whether an entity can send this message.</param>
public virtual void TrySendInGameICMessage(
EntityUid source,
string message,
InGameICChatType desiredType,
bool hideChat,
bool hideLog = false,
IConsoleShell? shell = null,
ICommonSession? player = null,
string? nameOverride = null,
bool checkRadioPrefix = true,
bool ignoreActionBlocker = false)
{ }
/// <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="hideLog">Disables the admin log for this message if true. Used for entities that are not players, like vendors, cloning, etc.</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>
/// <param name="ignoreActionBlocker">If set to true, action blocker will not be considered for whether an entity can send this message.</param>
public virtual void TrySendInGameICMessage(
EntityUid source,
string message,
InGameICChatType desiredType,
ChatTransmitRange range,
bool hideLog = false,
IConsoleShell? shell = null,
ICommonSession? player = null,
string? nameOverride = null,
bool checkRadioPrefix = true,
bool ignoreActionBlocker = false
)
{ }
/// <summary>
/// Sends an out-of-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="type">The chat type.</param>
/// <param name="hideChat">Whether or not to show the message in the chat window.</param>
/// <param name="shell"></param>
/// <param name="player">The player doing the speaking.</param>
public virtual void TrySendInGameOOCMessage(
EntityUid source,
string message,
InGameOOCChatType type,
bool hideChat,
IConsoleShell? shell = null,
ICommonSession? player = null
)
{ }
/// <summary>
/// Dispatches an announcement to all.
/// </summary>
/// <param name="message">The contents of the message.</param>
/// <param name="sender">The sender (Communications Console in Communications Console Announcement).</param>
/// <param name="playSound">Play the announcement sound.</param>
/// <param name="announcementSound">Sound to play.</param>
/// <param name="colorOverride">Optional color for the announcement message.</param>
public virtual void DispatchGlobalAnnouncement(
string message,
string? sender = null,
bool playSound = true,
SoundSpecifier? announcementSound = null,
Color? colorOverride = null
)
{ }
/// <summary>
/// Dispatches an announcement to players selected by filter.
/// </summary>
/// <param name="filter">Filter to select players who will recieve the announcement.</param>
/// <param name="message">The contents of the message.</param>
/// <param name="source">The entity making the announcement (used to determine the station).</param>
/// <param name="sender">The sender (Communications Console in Communications Console Announcement).</param>
/// <param name="playSound">Play the announcement sound.</param>
/// <param name="announcementSound">Sound to play.</param>
/// <param name="colorOverride">Optional color for the announcement message.</param>
public virtual void DispatchFilteredAnnouncement(
Filter filter,
string message,
EntityUid? source = null,
string? sender = null,
bool playSound = true,
SoundSpecifier? announcementSound = null,
Color? colorOverride = null)
{ }
/// <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="announcementSound">Sound to play.</param>
/// <param name="colorOverride">Optional color for the announcement message.</param>
public virtual void DispatchStationAnnouncement(
EntityUid source,
string message,
string? sender = null,
bool playDefaultSound = true,
SoundSpecifier? announcementSound = null,
Color? colorOverride = null)
{ }
}
/// <summary>
@@ -338,3 +466,23 @@ public enum ChatTransmitRange : byte
/// Ghosts can't hear or see it at all. Regular players can if in-range.
NoGhosts
}
/// <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
}