fix: fix some bugs with keyhole system (#120)

This commit is contained in:
ThereDrD0
2024-02-24 23:42:44 +03:00
committed by GitHub
parent 2a5ce01ce4
commit 9bb4aa37cd
3 changed files with 15 additions and 5 deletions

View File

@@ -10,6 +10,9 @@ using Robust.Shared.Random;
namespace Content.Server._White.Keyhole;
// TODO: Исправить, что дверь на замке можно разобрать через ее id: DoorGraph
// TODO: Исправить, что при прерывании закрытия девственной двери форма замка принимает форму ключа, хотя закрытия не произошло
public sealed partial class KeyholeSystem : EntitySystem
{
@@ -66,7 +69,7 @@ public sealed partial class KeyholeSystem : EntitySystem
private void OnDoAfter(EntityUid uid, KeyholeComponent component, KeyInsertDoAfterEvent args)
{
if (args.Handled || args.Cancelled)
if (args.Handled || args.Cancelled || IsStateChanging(uid))
return;
Lock(uid, component, args.User);
@@ -74,6 +77,12 @@ public sealed partial class KeyholeSystem : EntitySystem
args.Handled = true;
}
private bool IsStateChanging(EntityUid uid)
{
return TryComp<DoorComponent>(uid, out var doorComponent) &&
(doorComponent.State == DoorState.Closing || doorComponent.State == DoorState.Opening);
}
private void Lock(EntityUid uid, KeyholeComponent component, EntityUid user)
{
var sound = component.Locked ? component.UnlockSound : component.LockSound;