Add voice locks to various hidden syndicate items (#39310)
This commit is contained in:
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