DetGadget hat fixes (#35658)
* """Refactors""" extraction code, fixes bug with labeled items * second line of fixes * Enhance label handling and add label retrieval method (its more preformant I swear) * Cleanup --------- Co-authored-by: beck-thompson <beck314159@hotmail.com>
This commit is contained in:
@@ -48,13 +48,15 @@ namespace Content.Server.Explosion.EntitySystems
|
||||
return;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(component.KeyPhrase) && message.Contains(component.KeyPhrase, StringComparison.InvariantCultureIgnoreCase))
|
||||
if (!string.IsNullOrWhiteSpace(component.KeyPhrase) && message.IndexOf(component.KeyPhrase, StringComparison.InvariantCultureIgnoreCase) is var index and >= 0 )
|
||||
{
|
||||
_adminLogger.Add(LogType.Trigger, LogImpact.Medium,
|
||||
$"A voice-trigger on {ToPrettyString(ent):entity} was triggered by {ToPrettyString(args.Source):speaker} speaking the key-phrase {component.KeyPhrase}.");
|
||||
Trigger(ent, args.Source);
|
||||
|
||||
var voice = new VoiceTriggeredEvent(args.Source, message);
|
||||
var messageWithoutPhrase = message.Remove(index, component.KeyPhrase.Length).Trim();
|
||||
|
||||
var voice = new VoiceTriggeredEvent(args.Source, message, messageWithoutPhrase);
|
||||
RaiseLocalEvent(ent, ref voice);
|
||||
}
|
||||
}
|
||||
@@ -147,5 +149,6 @@ namespace Content.Server.Explosion.EntitySystems
|
||||
/// </summary>
|
||||
/// <param name="Source"> The EntityUid of the entity sending the message</param>
|
||||
/// <param name="Message"> The contents of the message</param>
|
||||
/// <param name="MessageWithoutPhrase"> The message without the phrase that triggered it.</param>
|
||||
[ByRefEvent]
|
||||
public readonly record struct VoiceTriggeredEvent(EntityUid Source, string? Message);
|
||||
public readonly record struct VoiceTriggeredEvent(EntityUid Source, string Message, string MessageWithoutPhrase);
|
||||
|
||||
Reference in New Issue
Block a user