Fix sloshing electricity & enable SpeechVerb masking (#24238)
* Implemented electricity speech verb masking * Handle speech verb override elsewhere in the system, even though we're not using it * Fix that protoId business * No nullable component fields * Use ProtoId, and try going back to a nullable. Specifiy DataFields on VoiceMaskComponent.
This commit is contained in:
@@ -19,6 +19,7 @@ using Content.Shared.Interaction;
|
||||
using Content.Shared.Mobs.Systems;
|
||||
using Content.Shared.Players;
|
||||
using Content.Shared.Radio;
|
||||
using Content.Shared.Speech;
|
||||
using Robust.Server.Player;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Audio.Systems;
|
||||
@@ -389,6 +390,8 @@ public sealed partial class ChatSystem : SharedChatSystem
|
||||
if (message.Length == 0)
|
||||
return;
|
||||
|
||||
var speech = GetSpeechVerb(source, message);
|
||||
|
||||
// get the entity's apparent name (if no override provided).
|
||||
string name;
|
||||
if (nameOverride != null)
|
||||
@@ -400,10 +403,12 @@ public sealed partial class ChatSystem : SharedChatSystem
|
||||
var nameEv = new TransformSpeakerNameEvent(source, Name(source));
|
||||
RaiseLocalEvent(source, nameEv);
|
||||
name = nameEv.Name;
|
||||
// Check for a speech verb override
|
||||
if (nameEv.SpeechVerb != null && _prototypeManager.TryIndex<SpeechVerbPrototype>(nameEv.SpeechVerb, out var proto))
|
||||
speech = proto;
|
||||
}
|
||||
|
||||
name = FormattedMessage.EscapeText(name);
|
||||
var speech = GetSpeechVerb(source, message);
|
||||
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))),
|
||||
@@ -872,11 +877,13 @@ public sealed class TransformSpeakerNameEvent : EntityEventArgs
|
||||
{
|
||||
public EntityUid Sender;
|
||||
public string Name;
|
||||
public string? SpeechVerb;
|
||||
|
||||
public TransformSpeakerNameEvent(EntityUid sender, string name)
|
||||
public TransformSpeakerNameEvent(EntityUid sender, string name, string? speechVerb = null)
|
||||
{
|
||||
Sender = sender;
|
||||
Name = name;
|
||||
SpeechVerb = speechVerb;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ using Content.Shared.Chat;
|
||||
using Content.Shared.Database;
|
||||
using Content.Shared.Radio;
|
||||
using Content.Shared.Radio.Components;
|
||||
using Content.Shared.Speech;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Network;
|
||||
using Robust.Shared.Player;
|
||||
@@ -79,7 +80,17 @@ public sealed class RadioSystem : EntitySystem
|
||||
|
||||
name = FormattedMessage.EscapeText(name);
|
||||
|
||||
var speech = _chat.GetSpeechVerb(messageSource, message);
|
||||
SpeechVerbPrototype speech;
|
||||
if (mask != null
|
||||
&& mask.Enabled
|
||||
&& mask.SpeechVerb != null
|
||||
&& _prototype.TryIndex<SpeechVerbPrototype>(mask.SpeechVerb, out var proto))
|
||||
{
|
||||
speech = proto;
|
||||
}
|
||||
else
|
||||
speech = _chat.GetSpeechVerb(messageSource, message);
|
||||
|
||||
var content = escapeMarkup
|
||||
? FormattedMessage.EscapeText(message)
|
||||
: message;
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
using System.Text;
|
||||
|
||||
using Content.Server.Speech.Components;
|
||||
using Content.Server.Chat.Systems;
|
||||
using Content.Server.Speech.EntitySystems;
|
||||
using Content.Server.VoiceMask;
|
||||
using Content.Server.Wires;
|
||||
using Content.Shared.Speech;
|
||||
@@ -18,7 +15,13 @@ public sealed partial class ListenWireAction : BaseToggleWireAction
|
||||
/// <summary>
|
||||
/// Length of the gibberish string sent when pulsing the wire
|
||||
/// </summary>
|
||||
private int _noiseLength = 16;
|
||||
private const int NoiseLength = 16;
|
||||
|
||||
/// <summary>
|
||||
/// Identifier of the SpeechVerbPrototype to use when pulsing the wire
|
||||
/// </summary>
|
||||
[ValidatePrototypeId<SpeechVerbPrototype>]
|
||||
private const string SpeechVerb = "Electricity";
|
||||
public override Color Color { get; set; } = Color.Green;
|
||||
public override string Name { get; set; } = "wire-name-listen";
|
||||
|
||||
@@ -75,19 +78,22 @@ public sealed partial class ListenWireAction : BaseToggleWireAction
|
||||
// Save the user's existing voicemask if they have one
|
||||
var oldEnabled = true;
|
||||
var oldVoiceName = Loc.GetString("wire-listen-pulse-error-name");
|
||||
string? oldSpeechVerb = null;
|
||||
if (EntityManager.TryGetComponent<VoiceMaskComponent>(user, out var oldMask))
|
||||
{
|
||||
oldEnabled = oldMask.Enabled;
|
||||
oldVoiceName = oldMask.VoiceName;
|
||||
oldSpeechVerb = oldMask.SpeechVerb;
|
||||
}
|
||||
|
||||
// Give the user a temporary voicemask component
|
||||
var mask = EntityManager.EnsureComponent<VoiceMaskComponent>(user);
|
||||
mask.Enabled = true;
|
||||
mask.VoiceName = Loc.GetString("wire-listen-pulse-identifier");
|
||||
mask.SpeechVerb = SpeechVerb;
|
||||
|
||||
var chars = Loc.GetString("wire-listen-pulse-characters").ToCharArray();
|
||||
var noiseMsg = _chat.BuildGibberishString(chars, _noiseLength);
|
||||
var noiseMsg = _chat.BuildGibberishString(chars, NoiseLength);
|
||||
|
||||
var attemptEv = new ListenAttemptEvent(wire.Owner);
|
||||
EntityManager.EventBus.RaiseLocalEvent(wire.Owner, attemptEv);
|
||||
@@ -104,6 +110,7 @@ public sealed partial class ListenWireAction : BaseToggleWireAction
|
||||
{
|
||||
mask.Enabled = oldEnabled;
|
||||
mask.VoiceName = oldVoiceName;
|
||||
mask.SpeechVerb = oldSpeechVerb;
|
||||
}
|
||||
|
||||
base.Pulse(user, wire);
|
||||
|
||||
@@ -1,9 +1,23 @@
|
||||
using Content.Shared.Speech;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Server.VoiceMask;
|
||||
|
||||
[RegisterComponent]
|
||||
public sealed partial class VoiceMaskComponent : Component
|
||||
{
|
||||
[ViewVariables(VVAccess.ReadWrite)] public bool Enabled = true;
|
||||
[DataField]
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public bool Enabled = true;
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite)] public string VoiceName = "Unknown";
|
||||
[DataField]
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public string VoiceName = "Unknown";
|
||||
|
||||
/// <summary>
|
||||
/// If EnableSpeechVerbModification is true, overrides the speech verb used when this entity speaks.
|
||||
/// </summary>
|
||||
[DataField]
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public ProtoId<SpeechVerbPrototype>? SpeechVerb;
|
||||
}
|
||||
|
||||
@@ -66,6 +66,8 @@ public sealed partial class VoiceMaskSystem : EntitySystem
|
||||
*/
|
||||
|
||||
args.Name = component.VoiceName;
|
||||
if (component.SpeechVerb != null)
|
||||
args.SpeechVerb = component.SpeechVerb;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -113,3 +113,7 @@ chat-speech-verb-ghost-1 = complains
|
||||
chat-speech-verb-ghost-2 = breathes
|
||||
chat-speech-verb-ghost-3 = hums
|
||||
chat-speech-verb-ghost-4 = mutters
|
||||
|
||||
chat-speech-verb-electricity-1 = crackles
|
||||
chat-speech-verb-electricity-2 = buzzes
|
||||
chat-speech-verb-electricity-3 = screeches
|
||||
|
||||
@@ -121,3 +121,10 @@
|
||||
- chat-speech-verb-ghost-3
|
||||
- chat-speech-verb-ghost-4
|
||||
- chat-speech-verb-mumble
|
||||
|
||||
- type: speechVerb
|
||||
id: Electricity
|
||||
speechVerbStrings:
|
||||
- chat-speech-verb-electricity-1
|
||||
- chat-speech-verb-electricity-2
|
||||
- chat-speech-verb-electricity-3
|
||||
|
||||
Reference in New Issue
Block a user