voicemask can select speech verb (#25768)
* add Name field to SpeechVerbPrototype * extra locale for voice mask ui * SpeechVerb ui and handling * raaaaaaaaa * reeeeeeeeal Co-authored-by: Tayrtahn <tayrtahn@gmail.com> * fix sort * did you hear john syndicate died of ligma * Update Content.Client/VoiceMask/VoiceMaskNameChangeWindow.xaml --------- Co-authored-by: deltanedas <@deltanedas:kde.org> Co-authored-by: Tayrtahn <tayrtahn@gmail.com> Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
This commit is contained in:
@@ -21,6 +21,7 @@ public sealed partial class VoiceMaskSystem
|
||||
|
||||
var comp = EnsureComp<VoiceMaskComponent>(user);
|
||||
comp.VoiceName = component.LastSetName;
|
||||
comp.SpeechVerb = component.LastSpeechVerb;
|
||||
|
||||
_actions.AddAction(user, ref component.ActionEntity, component.Action, uid);
|
||||
}
|
||||
@@ -30,15 +31,23 @@ public sealed partial class VoiceMaskSystem
|
||||
RemComp<VoiceMaskComponent>(args.Equipee);
|
||||
}
|
||||
|
||||
private void TrySetLastKnownName(EntityUid maskWearer, string lastName)
|
||||
private VoiceMaskerComponent? TryGetMask(EntityUid user)
|
||||
{
|
||||
if (!HasComp<VoiceMaskComponent>(maskWearer)
|
||||
|| !_inventory.TryGetSlotEntity(maskWearer, MaskSlot, out var maskEntity)
|
||||
|| !TryComp<VoiceMaskerComponent>(maskEntity, out var maskComp))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!HasComp<VoiceMaskComponent>(user) || !_inventory.TryGetSlotEntity(user, MaskSlot, out var maskEntity))
|
||||
return null;
|
||||
|
||||
maskComp.LastSetName = lastName;
|
||||
return CompOrNull<VoiceMaskerComponent>(maskEntity);
|
||||
}
|
||||
|
||||
private void TrySetLastKnownName(EntityUid user, string name)
|
||||
{
|
||||
if (TryGetMask(user) is {} comp)
|
||||
comp.LastSetName = name;
|
||||
}
|
||||
|
||||
private void TrySetLastSpeechVerb(EntityUid user, string? verb)
|
||||
{
|
||||
if (TryGetMask(user) is {} comp)
|
||||
comp.LastSpeechVerb = verb;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,9 +6,11 @@ using Content.Shared.Database;
|
||||
using Content.Shared.Inventory.Events;
|
||||
using Content.Shared.Popups;
|
||||
using Content.Shared.Preferences;
|
||||
using Content.Shared.Speech;
|
||||
using Content.Shared.VoiceMask;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Server.VoiceMask;
|
||||
|
||||
@@ -17,11 +19,13 @@ public sealed partial class VoiceMaskSystem : EntitySystem
|
||||
[Dependency] private readonly UserInterfaceSystem _uiSystem = default!;
|
||||
[Dependency] private readonly PopupSystem _popupSystem = default!;
|
||||
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
|
||||
[Dependency] private readonly IPrototypeManager _proto = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
SubscribeLocalEvent<VoiceMaskComponent, TransformSpeakerNameEvent>(OnSpeakerNameTransform);
|
||||
SubscribeLocalEvent<VoiceMaskComponent, VoiceMaskChangeNameMessage>(OnChangeName);
|
||||
SubscribeLocalEvent<VoiceMaskComponent, VoiceMaskChangeVerbMessage>(OnChangeVerb);
|
||||
SubscribeLocalEvent<VoiceMaskComponent, WearerMaskToggledEvent>(OnMaskToggled);
|
||||
SubscribeLocalEvent<VoiceMaskerComponent, GotEquippedEvent>(OnEquip);
|
||||
SubscribeLocalEvent<VoiceMaskerComponent, GotUnequippedEvent>(OnUnequip);
|
||||
@@ -55,6 +59,21 @@ public sealed partial class VoiceMaskSystem : EntitySystem
|
||||
UpdateUI(uid, component);
|
||||
}
|
||||
|
||||
private void OnChangeVerb(Entity<VoiceMaskComponent> ent, ref VoiceMaskChangeVerbMessage msg)
|
||||
{
|
||||
if (msg.Verb is {} id && !_proto.HasIndex<SpeechVerbPrototype>(id))
|
||||
return;
|
||||
|
||||
ent.Comp.SpeechVerb = msg.Verb;
|
||||
// verb is only important to metagamers so no need to log as opposed to name
|
||||
|
||||
_popupSystem.PopupEntity(Loc.GetString("voice-mask-popup-success"), ent, msg.Session);
|
||||
|
||||
TrySetLastSpeechVerb(ent, msg.Verb);
|
||||
|
||||
UpdateUI(ent, ent.Comp);
|
||||
}
|
||||
|
||||
private void OnSpeakerNameTransform(EntityUid uid, VoiceMaskComponent component, TransformSpeakerNameEvent args)
|
||||
{
|
||||
if (component.Enabled)
|
||||
@@ -95,6 +114,6 @@ public sealed partial class VoiceMaskSystem : EntitySystem
|
||||
}
|
||||
|
||||
if (_uiSystem.TryGetUi(owner, VoiceMaskUIKey.Key, out var bui))
|
||||
_uiSystem.SetUiState(bui, new VoiceMaskBuiState(component.VoiceName));
|
||||
_uiSystem.SetUiState(bui, new VoiceMaskBuiState(component.VoiceName, component.SpeechVerb));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,20 @@
|
||||
using Content.Shared.Speech;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
||||
|
||||
namespace Content.Server.VoiceMask;
|
||||
|
||||
[RegisterComponent]
|
||||
public sealed partial class VoiceMaskerComponent : Component
|
||||
{
|
||||
[ViewVariables(VVAccess.ReadWrite)] public string LastSetName = "Unknown";
|
||||
[DataField]
|
||||
public string LastSetName = "Unknown";
|
||||
|
||||
[DataField("action", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
|
||||
public string Action = "ActionChangeVoiceMask";
|
||||
[DataField]
|
||||
public ProtoId<SpeechVerbPrototype>? LastSpeechVerb;
|
||||
|
||||
[DataField("actionEntity")] public EntityUid? ActionEntity;
|
||||
[DataField]
|
||||
public EntProtoId Action = "ActionChangeVoiceMask";
|
||||
|
||||
[DataField]
|
||||
public EntityUid? ActionEntity;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user