Emags (#6738)
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
using Content.Server.Access.Components;
|
||||
using Content.Server.Access.Systems;
|
||||
using Content.Server.Storage.Components;
|
||||
using Content.Shared.Emag.Systems;
|
||||
using Content.Shared.Emag.Components;
|
||||
using Content.Shared.Access.Components;
|
||||
using Content.Shared.Access.Systems;
|
||||
using Content.Shared.Examine;
|
||||
@@ -33,6 +35,7 @@ namespace Content.Server.Lock
|
||||
SubscribeLocalEvent<LockComponent, ActivateInWorldEvent>(OnActivated);
|
||||
SubscribeLocalEvent<LockComponent, ExaminedEvent>(OnExamined);
|
||||
SubscribeLocalEvent<LockComponent, GetVerbsEvent<AlternativeVerb>>(AddToggleLockVerb);
|
||||
SubscribeLocalEvent<LockComponent, GotEmaggedEvent>(OnEmagged);
|
||||
}
|
||||
|
||||
private void OnStartup(EntityUid uid, LockComponent lockComp, ComponentStartup args)
|
||||
@@ -182,5 +185,23 @@ namespace Content.Server.Lock
|
||||
// TODO VERB ICONS need padlock open/close icons.
|
||||
args.Verbs.Add(verb);
|
||||
}
|
||||
|
||||
private void OnEmagged(EntityUid uid, LockComponent component, GotEmaggedEvent args)
|
||||
{
|
||||
if (component.Locked == true)
|
||||
{
|
||||
if (component.UnlockSound != null)
|
||||
{
|
||||
SoundSystem.Play(Filter.Pvs(component.Owner), component.UnlockSound.GetSound(), component.Owner, AudioParams.Default.WithVolume(-5));
|
||||
}
|
||||
|
||||
if (EntityManager.TryGetComponent(component.Owner, out AppearanceComponent? appearanceComp))
|
||||
{
|
||||
appearanceComp.SetData(StorageVisuals.Locked, false);
|
||||
}
|
||||
EntityManager.RemoveComponent<LockComponent>(uid); //Literally destroys the lock as a tell it was emagged
|
||||
args.Handled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user