Files
tbd-station-14/Content.Shared/Chat/MsgChatMessage.cs
Visne 9b94d5c195 Added nullable to most Content.Shared files (#3238)
* Add nullable to some Content.Shared files.

* Use [NotNullWhen(true)]

* Undo adding now redundant !'s

* Forgot one

* Add a ton more nullable

* You can guess

* Fix some issues

* It actually compiles now

* Auto stash before merge of "null2" and "origin/master"

* I lied

* enable annotations -> enable

* Revert ActionBlockerSystem.cs to original

* Fix ActionBlockerSystem.cs

* More nullable

* Undo some added exclamation marks

* Fix issues

* Update Content.Shared/Maps/ContentTileDefinition.cs

Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>

* Resolve some issues

* Remove unused method

* Fix more issues

* Fix more issues

* Fix more issues

* Fix more issues

* Fix issue, rollback SharedGhostComponent.cs

* Update submodule

* Fix issue, invert some if-statements to reduce nesting

* Revert RobustToolbox

* FIx things broken by merge

* Some fixes

- Replaced with string.Empty
- Remove some exclamation marks
- Revert file

* Some fixes

* Trivial #nullable enable

* Fix null ables

Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
Co-authored-by: Metal Gear Sloth <metalgearsloth@gmail.com>
2021-02-27 14:12:09 +11:00

88 lines
2.7 KiB
C#

#nullable enable
using JetBrains.Annotations;
using Lidgren.Network;
using Robust.Shared.GameObjects;
using Robust.Shared.Maths;
using Robust.Shared.Network;
namespace Content.Shared.Chat
{
/// <summary>
/// Sent from server to client to notify the client about a new chat message.
/// </summary>
[UsedImplicitly]
public sealed class MsgChatMessage : NetMessage
{
#region REQUIRED
public const MsgGroups GROUP = MsgGroups.Command;
public const string NAME = nameof(MsgChatMessage);
public MsgChatMessage(INetChannel channel) : base(NAME, GROUP) { }
#endregion
/// <summary>
/// The channel the message is on. This can also change whether certain params are used.
/// </summary>
public ChatChannel Channel { get; set; }
/// <summary>
/// The actual message contents.
/// </summary>
public string Message { get; set; } = string.Empty;
/// <summary>
/// What to "wrap" the message contents with. Example is stuff like 'Joe says: "{0}"'
/// </summary>
public string MessageWrap { get; set; } = string.Empty;
/// <summary>
/// The sending entity.
/// Only applies to <see cref="ChatChannel.Local"/>, <see cref="ChatChannel.Dead"/> and <see cref="ChatChannel.Emotes"/>.
/// </summary>
public EntityUid SenderEntity { get; set; }
/// <summary>
/// The override color of the message
/// </summary>
public Color MessageColorOverride { get; set; } = Color.Transparent;
public override void ReadFromBuffer(NetIncomingMessage buffer)
{
Channel = (ChatChannel) buffer.ReadInt16();
Message = buffer.ReadString();
MessageWrap = buffer.ReadString();
switch (Channel)
{
case ChatChannel.Local:
case ChatChannel.Dead:
case ChatChannel.AdminChat:
case ChatChannel.Emotes:
SenderEntity = buffer.ReadEntityUid();
break;
}
MessageColorOverride = buffer.ReadColor();
}
public override void WriteToBuffer(NetOutgoingMessage buffer)
{
buffer.Write((short)Channel);
buffer.Write(Message);
buffer.Write(MessageWrap);
switch (Channel)
{
case ChatChannel.Local:
case ChatChannel.Dead:
case ChatChannel.AdminChat:
case ChatChannel.Emotes:
buffer.Write(SenderEntity);
break;
}
buffer.Write(MessageColorOverride);
}
}
}