Locksystem cleanup (#13409)
This commit is contained in:
@@ -22,6 +22,8 @@ namespace Content.Server.Lock
|
|||||||
{
|
{
|
||||||
[Dependency] private readonly AccessReaderSystem _accessReader = default!;
|
[Dependency] private readonly AccessReaderSystem _accessReader = default!;
|
||||||
[Dependency] private readonly SharedPopupSystem _sharedPopupSystem = default!;
|
[Dependency] private readonly SharedPopupSystem _sharedPopupSystem = default!;
|
||||||
|
[Dependency] private readonly SharedAppearanceSystem _appearanceSystem = default!;
|
||||||
|
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
@@ -39,7 +41,7 @@ namespace Content.Server.Lock
|
|||||||
{
|
{
|
||||||
if (EntityManager.TryGetComponent(lockComp.Owner, out AppearanceComponent? appearance))
|
if (EntityManager.TryGetComponent(lockComp.Owner, out AppearanceComponent? appearance))
|
||||||
{
|
{
|
||||||
appearance.SetData(StorageVisuals.CanLock, true);
|
_appearanceSystem.SetData(uid, StorageVisuals.CanLock, true, appearance);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,17 +93,17 @@ namespace Content.Server.Lock
|
|||||||
if (!HasUserAccess(uid, user, quiet: false))
|
if (!HasUserAccess(uid, user, quiet: false))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
lockComp.Owner.PopupMessage(user, Loc.GetString("lock-comp-do-lock-success", ("entityName", EntityManager.GetComponent<MetaDataComponent>(lockComp.Owner).EntityName)));
|
_sharedPopupSystem.PopupEntity(Loc.GetString("lock-comp-do-lock-success", ("entityName", EntityManager.GetComponent<MetaDataComponent>(uid).EntityName)), uid, user);
|
||||||
lockComp.Locked = true;
|
lockComp.Locked = true;
|
||||||
|
|
||||||
if(lockComp.LockSound != null)
|
if(lockComp.LockSound != null)
|
||||||
{
|
{
|
||||||
SoundSystem.Play(lockComp.LockSound.GetSound(), Filter.Pvs(lockComp.Owner), lockComp.Owner, AudioParams.Default.WithVolume(-5));
|
_audio.PlayPvs(_audio.GetSound(lockComp.LockSound), uid, AudioParams.Default.WithVolume(-5));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (EntityManager.TryGetComponent(lockComp.Owner, out AppearanceComponent? appearanceComp))
|
if (EntityManager.TryGetComponent(uid, out AppearanceComponent? appearanceComp))
|
||||||
{
|
{
|
||||||
appearanceComp.SetData(StorageVisuals.Locked, true);
|
_appearanceSystem.SetData(uid, StorageVisuals.Locked, true, appearanceComp);
|
||||||
}
|
}
|
||||||
|
|
||||||
RaiseLocalEvent(lockComp.Owner, new LockToggledEvent(true), true);
|
RaiseLocalEvent(lockComp.Owner, new LockToggledEvent(true), true);
|
||||||
@@ -114,18 +116,21 @@ namespace Content.Server.Lock
|
|||||||
if (!Resolve(uid, ref lockComp))
|
if (!Resolve(uid, ref lockComp))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (user is {Valid: true})
|
if (user is { Valid: true })
|
||||||
lockComp.Owner.PopupMessage(user.Value, Loc.GetString("lock-comp-do-unlock-success", ("entityName", EntityManager.GetComponent<MetaDataComponent>(lockComp.Owner).EntityName)));
|
{
|
||||||
|
_sharedPopupSystem.PopupEntity(Loc.GetString("lock-comp-do-unlock-success", ("entityName", EntityManager.GetComponent<MetaDataComponent>(uid).EntityName)), uid, user.Value);
|
||||||
|
}
|
||||||
|
|
||||||
lockComp.Locked = false;
|
lockComp.Locked = false;
|
||||||
|
|
||||||
if (lockComp.UnlockSound != null)
|
if (lockComp.UnlockSound != null)
|
||||||
{
|
{
|
||||||
SoundSystem.Play(lockComp.UnlockSound.GetSound(), Filter.Pvs(lockComp.Owner), lockComp.Owner, AudioParams.Default.WithVolume(-5));
|
_audio.PlayPvs(_audio.GetSound(lockComp.UnlockSound), uid, AudioParams.Default.WithVolume(-5));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (EntityManager.TryGetComponent(lockComp.Owner, out AppearanceComponent? appearanceComp))
|
if (EntityManager.TryGetComponent(lockComp.Owner, out AppearanceComponent? appearanceComp))
|
||||||
{
|
{
|
||||||
appearanceComp.SetData(StorageVisuals.Locked, false);
|
_appearanceSystem.SetData(uid, StorageVisuals.Locked, false, appearanceComp);
|
||||||
}
|
}
|
||||||
|
|
||||||
RaiseLocalEvent(lockComp.Owner, new LockToggledEvent(false), true);
|
RaiseLocalEvent(lockComp.Owner, new LockToggledEvent(false), true);
|
||||||
@@ -168,7 +173,7 @@ namespace Content.Server.Lock
|
|||||||
if (!_accessReader.IsAllowed(user, reader))
|
if (!_accessReader.IsAllowed(user, reader))
|
||||||
{
|
{
|
||||||
if (!quiet)
|
if (!quiet)
|
||||||
reader.Owner.PopupMessage(user, Loc.GetString("lock-comp-has-user-access-fail"));
|
_sharedPopupSystem.PopupEntity(Loc.GetString("lock-comp-has-user-access-fail"), uid, user);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -191,16 +196,16 @@ namespace Content.Server.Lock
|
|||||||
|
|
||||||
private void OnEmagged(EntityUid uid, LockComponent component, GotEmaggedEvent args)
|
private void OnEmagged(EntityUid uid, LockComponent component, GotEmaggedEvent args)
|
||||||
{
|
{
|
||||||
if (component.Locked == true)
|
if (component.Locked)
|
||||||
{
|
{
|
||||||
if (component.UnlockSound != null)
|
if (component.UnlockSound != null)
|
||||||
{
|
{
|
||||||
SoundSystem.Play(component.UnlockSound.GetSound(), Filter.Pvs(component.Owner), component.Owner, AudioParams.Default.WithVolume(-5));
|
_audio.PlayPvs(_audio.GetSound(component.UnlockSound), uid, AudioParams.Default.WithVolume(-5));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (EntityManager.TryGetComponent(component.Owner, out AppearanceComponent? appearanceComp))
|
if (EntityManager.TryGetComponent(component.Owner, out AppearanceComponent? appearanceComp))
|
||||||
{
|
{
|
||||||
appearanceComp.SetData(StorageVisuals.Locked, false);
|
_appearanceSystem.SetData(uid, StorageVisuals.Locked, false, appearanceComp);
|
||||||
}
|
}
|
||||||
EntityManager.RemoveComponent<LockComponent>(uid); //Literally destroys the lock as a tell it was emagged
|
EntityManager.RemoveComponent<LockComponent>(uid); //Literally destroys the lock as a tell it was emagged
|
||||||
args.Handled = true;
|
args.Handled = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user