using Content.Shared.CCVar;
using Content.Shared.Chat;
using Content.Shared.Database;
+using Content.Shared.Decals;
using Content.Shared.Ghost;
+using Content.Shared.Humanoid;
using Content.Shared.IdentityManagement;
using Content.Shared.Interaction;
using Content.Shared.Mobs.Systems;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Configuration;
using Robust.Shared.Console;
+using Robust.Shared.GameObjects.Components.Localization;
using Robust.Shared.Network;
using Robust.Shared.Player;
using Robust.Shared.Prototypes;
private bool _critLoocEnabled;
private readonly bool _adminLoocEnabled = true;
+ [ValidatePrototypeId<ColorPalettePrototype>]
+ private const string _chatNamePalette = "Material";
+ private string[] _chatNameColors = default!;
+
public override void Initialize()
{
base.Initialize();
_configurationManager.OnValueChanged(CCVars.CritLoocEnabled, OnCritLoocEnabledChanged, true);
SubscribeLocalEvent<GameRunLevelChangedEvent>(OnGameChange);
+
+ var nameColors = _prototypeManager.Index<ColorPalettePrototype>(_chatNamePalette).Colors.Values.ToArray();
+ _chatNameColors = new string[nameColors.Length];
+ for (var i = 0; i < nameColors.Length; i++)
+ {
+ _chatNameColors[i] = nameColors[i].ToHex();
+ }
}
public override void Shutdown()
}
name = FormattedMessage.EscapeText(name);
+
+ // color the name unless it's something like "the old man"
+ if (!TryComp<GrammarComponent>(source, out var grammar) || grammar.ProperNoun == true)
+ name = $"[color={GetNameColor(name)}]{name}[/color]";
+
var wrappedMessage = Loc.GetString(speech.Bold ? "chat-manager-entity-say-bold-wrap-message" : "chat-manager-entity-say-wrap-message",
("entityName", name),
("verb", Loc.GetString(_random.Pick(speech.SpeechVerbStrings))),
}
name = FormattedMessage.EscapeText(name);
+ // color the name unless it's something like "the old man"
+ if (!TryComp<GrammarComponent>(source, out var grammar) || grammar.ProperNoun == true)
+ name = $"[color={GetNameColor(name)}]{name}[/color]";
+
var wrappedMessage = Loc.GetString("chat-manager-entity-whisper-wrap-message",
("entityName", name), ("message", FormattedMessage.EscapeText(message)));
#region Utility
+ /// <summary>
+ /// Returns the chat name color for a mob
+ /// </summary>
+ /// <param name="name">Name of the mob</param>
+ /// <returns>Hex value of the color</returns>
+ public string GetNameColor(string name)
+ {
+ var colorIdx = Math.Abs(name.GetHashCode() % _chatNameColors.Length);
+ return _chatNameColors[colorIdx];
+ }
+
private enum MessageRangeCheckResult
{
Disallowed,
--- /dev/null
+- type: palette
+ id: Material
+ name: Material
+ colors:
+ red: "#a91409"
+ red-darken-2: "#a72323"
+ red-accent-2: "#9b0000"
+ purple: "#7d1f8d"
+ purple-accent-2: "#8d03a5"
+ purple-accent-4: "#8800cc"
+ blue: "#0a6ab6"
+ blue-lighten-2: "#08528d"
+ blue-darken-2: "#145ea8"
+ cyan: "#0096aa"
+ cyan-lighten-2: "#198896"
+ cyan-darken-2: "#007986"
+ cyan-accent-2: "#00bebe"
+ cyan-accent-4: "#0093aa"
+ teal: "#00786d"
+ teal-lighten-2: "#3b8f89"
+ teal-accent-2: "#009076"
+ teal-accent-4: "#009984"
+ green: "#3d8c40"
+ green-darken-2: "#2d7230"
+ green-accent-2: "#0e885b"
+ green-accent-4: "#00a042"
+ lime: "#737a15"
+ lime-darken-2: "#8c9022"
+ lime-accent-2: "#737c00"
+ lime-accent-4: "#8bbb00"
+ amber: "#967000"
+ amber-lighten-2: "#755900"
+ amber-darken-2: "#cc8000"
+ amber-accent-2: "#7c6200"
+ amber-accent-4: "#996700"
\ No newline at end of file