LockVisualizer (#25224)

* LockVisualizer

* Fix state

* Clean some code

* Make it component, fix tests fail

* Fix for StateUnlocked

Now it is possible to manually set the unlocked state and it will work!

* Optimize LockVisualizer, add check for unlocked state

* No todo I guess
This commit is contained in:
MilenVolf
2024-02-17 02:52:31 +03:00
committed by GitHub
parent 19a7b0592c
commit c7870882f6
27 changed files with 98 additions and 110 deletions

View File

@@ -7,11 +7,9 @@ using Content.Shared.Hands.Components;
using Content.Shared.IdentityManagement;
using Content.Shared.Interaction;
using Content.Shared.Popups;
using Content.Shared.Storage;
using Content.Shared.Storage.Components;
using Content.Shared.Verbs;
using JetBrains.Annotations;
using Robust.Shared.Audio;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Utility;
@@ -46,8 +44,7 @@ public sealed class LockSystem : EntitySystem
private void OnStartup(EntityUid uid, LockComponent lockComp, ComponentStartup args)
{
_appearanceSystem.SetData(uid, StorageVisuals.CanLock, true);
_appearanceSystem.SetData(uid, StorageVisuals.Locked, lockComp.Locked);
_appearanceSystem.SetData(uid, LockVisuals.Locked, lockComp.Locked);
}
private void OnActivated(EntityUid uid, LockComponent lockComp, ActivateInWorldEvent args)
@@ -124,7 +121,7 @@ public sealed class LockSystem : EntitySystem
_audio.PlayPredicted(lockComp.LockSound, uid, user);
lockComp.Locked = true;
_appearanceSystem.SetData(uid, StorageVisuals.Locked, true);
_appearanceSystem.SetData(uid, LockVisuals.Locked, true);
Dirty(uid, lockComp);
var ev = new LockToggledEvent(true);
@@ -155,7 +152,7 @@ public sealed class LockSystem : EntitySystem
_audio.PlayPredicted(lockComp.UnlockSound, uid, user);
lockComp.Locked = false;
_appearanceSystem.SetData(uid, StorageVisuals.Locked, false);
_appearanceSystem.SetData(uid, LockVisuals.Locked, false);
Dirty(uid, lockComp);
var ev = new LockToggledEvent(false);
@@ -250,7 +247,7 @@ public sealed class LockSystem : EntitySystem
if (!component.Locked || !component.BreakOnEmag)
return;
_audio.PlayPredicted(component.UnlockSound, uid, null);
_appearanceSystem.SetData(uid, StorageVisuals.Locked, false);
_appearanceSystem.SetData(uid, LockVisuals.Locked, false);
RemComp<LockComponent>(uid); //Literally destroys the lock as a tell it was emagged
args.Handled = true;
}