[tweak] brig timers now announce

# Conflicts:
#	Content.Server/DeviceLinking/Systems/SignalTimerSystem.cs
#	Content.Server/MachineLinking/Components/SignalTimerComponent.cs
#	Resources/Prototypes/Entities/Structures/Wallmounts/timer.yml
This commit is contained in:
rhailrake
2023-04-26 02:58:31 +06:00
committed by Remuchi
parent f42c361c89
commit 83160bb89f
5 changed files with 61 additions and 44 deletions

View File

@@ -1,4 +1,3 @@
using System.Collections.Frozen;
using Content.Shared.Popups;
using Content.Shared.Radio;
using Content.Shared.Speech;
@@ -37,7 +36,7 @@ public abstract class SharedChatSystem : EntitySystem
/// <summary>
/// Cache of the keycodes for faster lookup.
/// </summary>
private FrozenDictionary<char, RadioChannelPrototype> _keyCodes = default!;
private readonly Dictionary<char, RadioChannelPrototype> _keyCodes = new();
public override void Initialize()
{
@@ -83,7 +82,7 @@ public abstract class SharedChatSystem : EntitySystem
SpeechVerbPrototype? current = null;
foreach (var (str, id) in speech.SuffixSpeechVerbs)
{
var proto = _prototypeManager.Index<SpeechVerbPrototype>(id);
var proto = _prototypeManager.Index(id);
if (message.EndsWith(Loc.GetString(str)) && proto.Priority >= (current?.Priority ?? 0))
{
current = proto;
@@ -91,7 +90,7 @@ public abstract class SharedChatSystem : EntitySystem
}
// if no applicable suffix verb return the normal one used by the entity
return current ?? _prototypeManager.Index<SpeechVerbPrototype>(speech.SpeechVerb);
return current ?? _prototypeManager.Index(speech.SpeechVerb);
}
/// <summary>
@@ -166,33 +165,4 @@ public abstract class SharedChatSystem : EntitySystem
message = char.ToUpper(message[0]) + message.Remove(0, 1);
return message;
}
public string SanitizeMessageCapitalizeTheWordI(string message, string theWordI = "i")
{
if (string.IsNullOrEmpty(message))
return message;
for
(
var index = message.IndexOf(theWordI);
index != -1;
index = message.IndexOf(theWordI, index + 1)
)
{
// Stops the code If It's tryIng to capItalIze the letter I In the mIddle of words
// Repeating the code twice is the simplest option
if (index + 1 < message.Length && char.IsLetter(message[index + 1]))
continue;
if (index - 1 >= 0 && char.IsLetter(message[index - 1]))
continue;
var beforeTarget = message.Substring(0, index);
var target = message.Substring(index, theWordI.Length);
var afterTarget = message.Substring(index + theWordI.Length);
message = beforeTarget + target.ToUpper() + afterTarget;
}
return message;
}
}