using Robust.Shared.Audio; using Robust.Shared.GameStates; using Robust.Shared.Serialization; namespace Content.Shared.Lock; /// /// Allows locking/unlocking, with access determined by AccessReader /// [RegisterComponent, NetworkedComponent] [Access(typeof(LockSystem))] [AutoGenerateComponentState] public sealed partial class LockComponent : Component { /// /// Whether or not the lock is locked. /// [DataField("locked"), ViewVariables(VVAccess.ReadWrite)] [AutoNetworkedField] public bool Locked = true; /// /// Whether or not the lock is toggled by simply clicking. /// [DataField("lockOnClick"), ViewVariables(VVAccess.ReadWrite)] [AutoNetworkedField] public bool LockOnClick; /// /// The sound played when unlocked. /// [DataField("unlockingSound"), ViewVariables(VVAccess.ReadWrite)] public SoundSpecifier UnlockSound = new SoundPathSpecifier("/Audio/Machines/door_lock_off.ogg") { Params = AudioParams.Default.WithVolume(-5f), }; /// /// The sound played when locked. /// [DataField("lockingSound"), ViewVariables(VVAccess.ReadWrite)] public SoundSpecifier LockSound = new SoundPathSpecifier("/Audio/Machines/door_lock_on.ogg") { Params = AudioParams.Default.WithVolume(-5f) }; /// /// Whether or not an emag disables it. /// [DataField("breakOnEmag")] [AutoNetworkedField] public bool BreakOnEmag = true; } /// /// Event raised on the lock when a toggle is attempted. /// Can be cancelled to prevent it. /// [ByRefEvent] public record struct LockToggleAttemptEvent(EntityUid User, bool Silent = false, bool Cancelled = false); /// /// Event raised on a lock after it has been toggled. /// [ByRefEvent] public readonly record struct LockToggledEvent(bool Locked);