Add voice locks to various hidden syndicate items (#39310)
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Trigger.Components.Effects;
|
||||
|
||||
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
|
||||
public sealed partial class LockOnTriggerComponent : BaseXOnTriggerComponent
|
||||
{
|
||||
[DataField, AutoNetworkedField]
|
||||
public LockAction LockOnTrigger = LockAction.Toggle;
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public enum LockAction
|
||||
{
|
||||
Lock = 0,
|
||||
Unlock = 1,
|
||||
Toggle = 2,
|
||||
}
|
||||
@@ -44,4 +44,52 @@ public sealed partial class TriggerOnVoiceComponent : BaseTriggerOnXComponent
|
||||
/// </summary>
|
||||
[DataField, AutoNetworkedField]
|
||||
public int MaxLength = 50;
|
||||
|
||||
/// <summary>
|
||||
/// When examining the item, should it show information about what word is recorded?
|
||||
/// </summary>
|
||||
[DataField, AutoNetworkedField]
|
||||
public bool ShowExamine = true;
|
||||
|
||||
/// <summary>
|
||||
/// Should there be verbs that allow re-recording of the trigger word?
|
||||
/// </summary>
|
||||
[DataField, AutoNetworkedField]
|
||||
public bool ShowVerbs = true;
|
||||
|
||||
/// <summary>
|
||||
/// The verb text that is shown when you can start recording a message.
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public LocId StartRecordingVerb = "trigger-on-voice-record";
|
||||
|
||||
/// <summary>
|
||||
/// The verb text that is shown when you can stop recording a message.
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public LocId StopRecordingVerb = "trigger-on-voice-stop";
|
||||
|
||||
/// <summary>
|
||||
/// Tooltip that appears when hovering over the stop or start recording verbs.
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public LocId? RecordingVerbMessage;
|
||||
|
||||
/// <summary>
|
||||
/// The verb text that is shown when you can clear a recording.
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public LocId ClearRecordingVerb = "trigger-on-voice-clear";
|
||||
|
||||
/// <summary>
|
||||
/// The loc string that is shown when inspecting an uninitialized voice trigger.
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public LocId? InspectUninitializedLoc = "trigger-on-voice-uninitialized";
|
||||
|
||||
/// <summary>
|
||||
/// The loc string to use when inspecting voice trigger. Will also include the triggering phrase
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public LocId? InspectInitializedLoc = "trigger-on-voice-examine";
|
||||
}
|
||||
|
||||
35
Content.Shared/Trigger/Systems/LockOnTriggerSystem.cs
Normal file
35
Content.Shared/Trigger/Systems/LockOnTriggerSystem.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using Content.Shared.Lock;
|
||||
using Content.Shared.Trigger.Components.Effects;
|
||||
|
||||
namespace Content.Shared.Trigger.Systems;
|
||||
|
||||
public sealed class LockOnTriggerSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly LockSystem _lock = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<LockOnTriggerComponent, TriggerEvent>(OnTrigger);
|
||||
}
|
||||
|
||||
private void OnTrigger(Entity<LockOnTriggerComponent> ent, ref TriggerEvent args)
|
||||
{
|
||||
if (args.Key != null && !ent.Comp.KeysIn.Contains(args.Key))
|
||||
return;
|
||||
|
||||
switch (ent.Comp.LockOnTrigger)
|
||||
{
|
||||
case LockAction.Lock:
|
||||
_lock.Lock(ent.Owner, args.User);
|
||||
break;
|
||||
case LockAction.Unlock:
|
||||
_lock.Unlock(ent, args.User);
|
||||
break;
|
||||
case LockAction.Toggle:
|
||||
_lock.ToggleLock(ent, args.User);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -25,15 +25,21 @@ public sealed partial class TriggerSystem
|
||||
RemCompDeferred<ActiveListenerComponent>(ent);
|
||||
}
|
||||
|
||||
private void OnVoiceExamine(Entity<TriggerOnVoiceComponent> ent, ref ExaminedEvent args)
|
||||
private void OnVoiceExamine(EntityUid uid, TriggerOnVoiceComponent component, ExaminedEvent args)
|
||||
{
|
||||
if (args.IsInDetailsRange)
|
||||
if (!args.IsInDetailsRange || !component.ShowExamine)
|
||||
return;
|
||||
|
||||
if (component.InspectUninitializedLoc != null && string.IsNullOrWhiteSpace(component.KeyPhrase))
|
||||
{
|
||||
args.PushText(string.IsNullOrWhiteSpace(ent.Comp.KeyPhrase)
|
||||
? Loc.GetString("trigger-on-voice-uninitialized")
|
||||
: Loc.GetString("trigger-on-voice-examine", ("keyphrase", ent.Comp.KeyPhrase)));
|
||||
args.PushText(Loc.GetString(component.InspectUninitializedLoc));
|
||||
}
|
||||
else if (component.InspectInitializedLoc != null && !string.IsNullOrWhiteSpace(component.KeyPhrase))
|
||||
{
|
||||
args.PushText(Loc.GetString(component.InspectInitializedLoc.Value, ("keyphrase", component.KeyPhrase)));
|
||||
}
|
||||
}
|
||||
|
||||
private void OnListen(Entity<TriggerOnVoiceComponent> ent, ref ListenEvent args)
|
||||
{
|
||||
var component = ent.Comp;
|
||||
@@ -71,13 +77,13 @@ public sealed partial class TriggerSystem
|
||||
|
||||
private void OnVoiceGetAltVerbs(Entity<TriggerOnVoiceComponent> ent, ref GetVerbsEvent<AlternativeVerb> args)
|
||||
{
|
||||
if (!args.CanInteract || !args.CanAccess)
|
||||
if (!args.CanInteract || !args.CanAccess || !ent.Comp.ShowVerbs)
|
||||
return;
|
||||
|
||||
var user = args.User;
|
||||
args.Verbs.Add(new AlternativeVerb
|
||||
{
|
||||
Text = Loc.GetString(ent.Comp.IsRecording ? "trigger-on-voice-stop" : "trigger-on-voice-record"),
|
||||
Text = Loc.GetString(ent.Comp.IsRecording ? ent.Comp.StopRecordingVerb : ent.Comp.StartRecordingVerb),
|
||||
Act = () =>
|
||||
{
|
||||
if (ent.Comp.IsRecording)
|
||||
@@ -93,7 +99,7 @@ public sealed partial class TriggerSystem
|
||||
|
||||
args.Verbs.Add(new AlternativeVerb
|
||||
{
|
||||
Text = Loc.GetString("trigger-on-voice-clear"),
|
||||
Text = Loc.GetString(ent.Comp.ClearRecordingVerb),
|
||||
Act = () =>
|
||||
{
|
||||
ClearRecording(ent);
|
||||
|
||||
Reference in New Issue
Block a user