Files
ss14-wega/Content.Shared/Lock/BypassLock/Systems/BypassLockSystem.MobState.cs
Sir Warock 7540c8f152 Pry open critical Borgs (#42319)
* One commit ops

* Please the maintainer gods

* More requested changes

* review

* actually this is probably a good idea

---------

Co-authored-by: ScarKy0 <scarky0@onet.eu>
2026-01-13 22:08:45 +00:00

42 lines
1.7 KiB
C#

using Content.Shared.Lock.BypassLock.Components;
using Content.Shared.Mobs.Components;
namespace Content.Shared.Lock.BypassLock.Systems;
public sealed partial class BypassLockSystem
{
private void InitializeMobStateLockSystem()
{
SubscribeLocalEvent<BypassLockRequiresMobStateComponent, ForceOpenLockAttemptEvent>(OnForceOpenLockAttempt);
SubscribeLocalEvent<BypassLockRequiresMobStateComponent, CheckBypassLockVerbRequirements>(OnGetVerb);
}
private void OnForceOpenLockAttempt(Entity<BypassLockRequiresMobStateComponent> target, ref ForceOpenLockAttemptEvent args)
{
if (!TryComp<MobStateComponent>(target, out var mobState))
return;
args.CanForceOpen &= target.Comp.RequiredMobState.Contains(mobState.CurrentState);
}
private void OnGetVerb(Entity<BypassLockRequiresMobStateComponent> target, ref CheckBypassLockVerbRequirements args)
{
if (!TryComp<MobStateComponent>(target, out var mobState))
return;
// Only show disabled verb on a too healthy target when they have the right tool.
if (!target.Comp.RequiredMobState.Contains(mobState.CurrentState) && args.RightTool)
{
args.Verb.Disabled = true;
args.Verb.Message = Loc.GetString("bypass-lock-disabled-healthy");
}
// Show verb of using the wrong tool when the target is critical.
else if (target.Comp.RequiredMobState.Contains(mobState.CurrentState) && !args.RightTool)
{
args.ShowVerb = true;
args.Verb.Disabled = true;
args.Verb.Message = Loc.GetString("bypass-lock-disabled-wrong-tool", ("quality", args.ToolQuality.ToString().ToLower()));
}
}
}