diff --git a/Content.Client/Lock/Visualizers/LockVisualizerSystem.cs b/Content.Client/Lock/Visualizers/LockVisualizerSystem.cs new file mode 100644 index 0000000000..1329a69ad2 --- /dev/null +++ b/Content.Client/Lock/Visualizers/LockVisualizerSystem.cs @@ -0,0 +1,38 @@ +using Content.Shared.Storage; +using Content.Shared.Lock; +using Robust.Client.GameObjects; + +namespace Content.Client.Lock.Visualizers; + +public sealed class LockVisualizerSystem : VisualizerSystem +{ + protected override void OnAppearanceChange(EntityUid uid, LockVisualsComponent comp, ref AppearanceChangeEvent args) + { + if (args.Sprite == null + || !AppearanceSystem.TryGetData(uid, LockVisuals.Locked, out _, args.Component)) + return; + + // Lock state for the entity. + if (!AppearanceSystem.TryGetData(uid, LockVisuals.Locked, out var locked, args.Component)) + locked = true; + + var unlockedStateExist = args.Sprite.BaseRSI?.TryGetState(comp.StateUnlocked, out _); + + if (AppearanceSystem.TryGetData(uid, StorageVisuals.Open, out var open, args.Component)) + { + args.Sprite.LayerSetVisible(LockVisualLayers.Lock, !open); + } + else if (!(bool) unlockedStateExist!) + args.Sprite.LayerSetVisible(LockVisualLayers.Lock, locked); + + if (!open && (bool) unlockedStateExist!) + { + args.Sprite.LayerSetState(LockVisualLayers.Lock, locked ? comp.StateLocked : comp.StateUnlocked); + } + } +} + +public enum LockVisualLayers : byte +{ + Lock +} diff --git a/Content.Client/Lock/Visualizers/LockVisualsComponent.cs b/Content.Client/Lock/Visualizers/LockVisualsComponent.cs new file mode 100644 index 0000000000..93844d6d82 --- /dev/null +++ b/Content.Client/Lock/Visualizers/LockVisualsComponent.cs @@ -0,0 +1,20 @@ +namespace Content.Client.Lock.Visualizers; + +[RegisterComponent] +[Access(typeof(LockVisualizerSystem))] +public sealed partial class LockVisualsComponent : Component +{ + /// + /// The RSI state used for the lock indicator while the entity is locked. + /// + [DataField("stateLocked")] + [ViewVariables(VVAccess.ReadWrite)] + public string? StateLocked = "locked"; + + /// + /// The RSI state used for the lock indicator entity is unlocked. + /// + [DataField("stateUnlocked")] + [ViewVariables(VVAccess.ReadWrite)] + public string? StateUnlocked = "unlocked"; +} diff --git a/Content.Client/Singularity/Systems/EmitterSystem.cs b/Content.Client/Singularity/Systems/EmitterSystem.cs index 5eb80928d8..e3396d74a2 100644 --- a/Content.Client/Singularity/Systems/EmitterSystem.cs +++ b/Content.Client/Singularity/Systems/EmitterSystem.cs @@ -1,7 +1,5 @@ -using Content.Client.Storage.Visualizers; -using Content.Shared.Singularity.Components; +using Content.Shared.Singularity.Components; using Content.Shared.Singularity.EntitySystems; -using Content.Shared.Storage; using Robust.Client.GameObjects; namespace Content.Client.Singularity.Systems; @@ -21,14 +19,6 @@ public sealed class EmitterSystem : SharedEmitterSystem if (args.Sprite == null) return; - if (args.Sprite.LayerMapTryGet(StorageVisualLayers.Lock, out var lockLayer)) - { - if (!_appearance.TryGetData(uid, StorageVisuals.Locked, out var locked, args.Component)) - locked = false; - - args.Sprite.LayerSetVisible(lockLayer, locked); - } - if (!_appearance.TryGetData(uid, EmitterVisuals.VisualState, out var state, args.Component)) state = EmitterVisualState.Off; diff --git a/Content.Client/Storage/Visualizers/EntityStorageVisualizerSystem.cs b/Content.Client/Storage/Visualizers/EntityStorageVisualizerSystem.cs index 772f516a69..ee4f2fdfd6 100644 --- a/Content.Client/Storage/Visualizers/EntityStorageVisualizerSystem.cs +++ b/Content.Client/Storage/Visualizers/EntityStorageVisualizerSystem.cs @@ -70,25 +70,11 @@ public sealed class EntityStorageVisualizerSystem : VisualizerSystem(uid, StorageVisuals.CanLock, out var canLock, args.Component) && canLock) - { - if (!AppearanceSystem.TryGetData(uid, StorageVisuals.Locked, out var locked, args.Component)) - locked = true; - - args.Sprite.LayerSetVisible(StorageVisualLayers.Lock, !open); - if (!open) - { - args.Sprite.LayerSetState(StorageVisualLayers.Lock, locked ? comp.StateLocked : comp.StateUnlocked); - } - } } } public enum StorageVisualLayers : byte { Base, - Door, - Lock + Door } diff --git a/Content.Client/Storage/Visualizers/EntityStorageVisualsComponent.cs b/Content.Client/Storage/Visualizers/EntityStorageVisualsComponent.cs index dc171d6c54..2215d8cd70 100644 --- a/Content.Client/Storage/Visualizers/EntityStorageVisualsComponent.cs +++ b/Content.Client/Storage/Visualizers/EntityStorageVisualsComponent.cs @@ -32,20 +32,6 @@ public sealed partial class EntityStorageVisualsComponent : Component [ViewVariables(VVAccess.ReadWrite)] public string? StateDoorClosed; - /// - /// The RSI state used for the lock indicator while the storage is locked. - /// - [DataField("stateLocked")] - [ViewVariables(VVAccess.ReadWrite)] - public string? StateLocked = "locked"; - - /// - /// The RSI state used for the lock indicator while the storage is unlocked. - /// - [DataField("stateUnlocked")] - [ViewVariables(VVAccess.ReadWrite)] - public string? StateUnlocked = "unlocked"; - /// /// The drawdepth the object has when it's open /// diff --git a/Content.Server/Atmos/Piping/Unary/EntitySystems/GasCanisterSystem.cs b/Content.Server/Atmos/Piping/Unary/EntitySystems/GasCanisterSystem.cs index e1e7b2a701..64d02d793b 100644 --- a/Content.Server/Atmos/Piping/Unary/EntitySystems/GasCanisterSystem.cs +++ b/Content.Server/Atmos/Piping/Unary/EntitySystems/GasCanisterSystem.cs @@ -17,7 +17,6 @@ using Content.Shared.Hands.EntitySystems; using Content.Shared.Interaction; using Content.Shared.Lock; using Robust.Server.GameObjects; -using Robust.Shared.Audio; using Robust.Shared.Audio.Systems; using Robust.Shared.Containers; using Robust.Shared.Player; @@ -54,7 +53,6 @@ public sealed class GasCanisterSystem : EntitySystem SubscribeLocalEvent(OnHoldingTankEjectMessage); SubscribeLocalEvent(OnCanisterChangeReleasePressure); SubscribeLocalEvent(OnCanisterChangeReleaseValve); - SubscribeLocalEvent(OnLockToggled); } /// @@ -78,11 +76,6 @@ public sealed class GasCanisterSystem : EntitySystem { // Ensure container _slots.AddItemSlot(uid, comp.ContainerName, comp.GasTankSlot); - - if (TryComp(uid, out var lockComp)) - { - _appearance.SetData(uid, GasCanisterVisuals.Locked, lockComp.Locked); - } } private void DirtyUI(EntityUid uid, @@ -309,11 +302,6 @@ public sealed class GasCanisterSystem : EntitySystem args.GasMixtures = new Dictionary { {Name(uid), component.Air} }; } - private void OnLockToggled(EntityUid uid, GasCanisterComponent component, ref LockToggledEvent args) - { - _appearance.SetData(uid, GasCanisterVisuals.Locked, args.Locked); - } - /// /// Check if the canister is locked, playing its sound and popup if so. /// diff --git a/Content.Shared/Atmos/Piping/Binary/Components/SharedGasCanisterComponent.cs b/Content.Shared/Atmos/Piping/Binary/Components/SharedGasCanisterComponent.cs index 23300cb2a0..1203639e09 100644 --- a/Content.Shared/Atmos/Piping/Binary/Components/SharedGasCanisterComponent.cs +++ b/Content.Shared/Atmos/Piping/Binary/Components/SharedGasCanisterComponent.cs @@ -21,8 +21,7 @@ namespace Content.Shared.Atmos.Piping.Binary.Components public enum GasCanisterVisuals { PressureState, - TankInserted, - Locked + TankInserted } #endregion diff --git a/Content.Shared/Lock/LockComponent.cs b/Content.Shared/Lock/LockComponent.cs index b3c4659749..5587fc2698 100644 --- a/Content.Shared/Lock/LockComponent.cs +++ b/Content.Shared/Lock/LockComponent.cs @@ -113,3 +113,10 @@ public sealed partial class UnlockDoAfter : DoAfterEvent return this; } } + +[NetSerializable] +[Serializable] +public enum LockVisuals : byte +{ + Locked +} diff --git a/Content.Shared/Lock/LockSystem.cs b/Content.Shared/Lock/LockSystem.cs index e5f53b4080..a01c5ace4d 100644 --- a/Content.Shared/Lock/LockSystem.cs +++ b/Content.Shared/Lock/LockSystem.cs @@ -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(uid); //Literally destroys the lock as a tell it was emagged args.Handled = true; } diff --git a/Content.Shared/Security/DeployableBarrierVisuals.cs b/Content.Shared/Security/DeployableBarrierVisuals.cs deleted file mode 100644 index 147ae23bac..0000000000 --- a/Content.Shared/Security/DeployableBarrierVisuals.cs +++ /dev/null @@ -1,18 +0,0 @@ -using Robust.Shared.Serialization; - -namespace Content.Shared.Security -{ - [Serializable, NetSerializable] - public enum DeployableBarrierVisuals : byte - { - State - } - - - [Serializable, NetSerializable] - public enum DeployableBarrierState : byte - { - Idle, - Deployed - } -} diff --git a/Content.Shared/Security/Systems/DeployableBarrierSystem.cs b/Content.Shared/Security/Systems/DeployableBarrierSystem.cs index 9d021c5219..7b9ce841a9 100644 --- a/Content.Shared/Security/Systems/DeployableBarrierSystem.cs +++ b/Content.Shared/Security/Systems/DeployableBarrierSystem.cs @@ -8,7 +8,6 @@ namespace Content.Shared.Security.Systems; public sealed class DeployableBarrierSystem : EntitySystem { - [Dependency] private readonly SharedAppearanceSystem _appearance = default!; [Dependency] private readonly FixtureSystem _fixtures = default!; [Dependency] private readonly SharedPointLightSystem _pointLight = default!; [Dependency] private readonly SharedPhysicsSystem _physics = default!; @@ -55,9 +54,6 @@ public sealed class DeployableBarrierSystem : EntitySystem _physics.SetHard(uid, fixture, false); } - var state = isDeployed ? DeployableBarrierState.Deployed : DeployableBarrierState.Idle; - _appearance.SetData(uid, DeployableBarrierVisuals.State, state); - if (TryComp(uid, out SharedPullableComponent? pullable)) _pulling.TryStopPull(pullable); diff --git a/Content.Shared/Storage/StorageComponent.cs b/Content.Shared/Storage/StorageComponent.cs index fa06e333e8..35f7955349 100644 --- a/Content.Shared/Storage/StorageComponent.cs +++ b/Content.Shared/Storage/StorageComponent.cs @@ -207,8 +207,6 @@ namespace Content.Shared.Storage { Open, HasContents, - CanLock, - Locked, StorageUsed, Capacity } diff --git a/Resources/Prototypes/Entities/Objects/Specific/Security/barrier.yml b/Resources/Prototypes/Entities/Objects/Specific/Security/barrier.yml index 3a31edf7f1..9277497e4f 100644 --- a/Resources/Prototypes/Entities/Objects/Specific/Security/barrier.yml +++ b/Resources/Prototypes/Entities/Objects/Specific/Security/barrier.yml @@ -10,15 +10,11 @@ - type: Sprite sprite: Objects/Specific/Security/barrier.rsi layers: - - state: "idle" - map: ["deployableBarrierBase"] + - state: idle + - state: locked + map: ["enum.LockVisualLayers.Lock"] - type: Appearance - - type: GenericVisualizer - visuals: - enum.DeployableBarrierVisuals.State: - deployableBarrierBase: - enum.DeployableBarrierState.Idle: {state: "idle"} - enum.DeployableBarrierState.Deployed: {state: "deployed"} + - type: LockVisuals - type: InteractionOutline - type: Physics bodyType: Dynamic diff --git a/Resources/Prototypes/Entities/Objects/Specific/Xenoarchaeology/artifact_equipment.yml b/Resources/Prototypes/Entities/Objects/Specific/Xenoarchaeology/artifact_equipment.yml index 659145562f..531a530441 100644 --- a/Resources/Prototypes/Entities/Objects/Specific/Xenoarchaeology/artifact_equipment.yml +++ b/Resources/Prototypes/Entities/Objects/Specific/Xenoarchaeology/artifact_equipment.yml @@ -22,7 +22,7 @@ visible: false map: ["enum.WeldableLayers.BaseWelded"] - state: locked - map: ["enum.StorageVisualLayers.Lock"] + map: ["enum.LockVisualLayers.Lock"] shader: unshaded - type: InteractionOutline - type: Physics @@ -73,6 +73,7 @@ - type: EntityStorageVisuals stateDoorOpen: artifact_container_open stateDoorClosed: artifact_container_door + - type: LockVisuals - type: ItemSlots - type: ContainerContainer containers: diff --git a/Resources/Prototypes/Entities/Structures/Machines/anomaly_equipment.yml b/Resources/Prototypes/Entities/Structures/Machines/anomaly_equipment.yml index 2697e00a70..cc9f8035fe 100644 --- a/Resources/Prototypes/Entities/Structures/Machines/anomaly_equipment.yml +++ b/Resources/Prototypes/Entities/Structures/Machines/anomaly_equipment.yml @@ -140,7 +140,7 @@ - state: locked shader: unshaded visible: false - map: ["enum.StorageVisualLayers.Lock"] + map: ["enum.LockVisualLayers.Lock"] - type: Transform noRot: false - type: Fixtures @@ -203,6 +203,7 @@ enum.PowerDeviceVisualLayers.Powered: True: { visible: true } False: { visible: false } + - type: LockVisuals - type: DeviceNetwork deviceNetId: Wireless receiveFrequencyId: BasicDevice diff --git a/Resources/Prototypes/Entities/Structures/Power/Generation/Singularity/emitter.yml b/Resources/Prototypes/Entities/Structures/Power/Generation/Singularity/emitter.yml index e5604bea08..52698f62cc 100644 --- a/Resources/Prototypes/Entities/Structures/Power/Generation/Singularity/emitter.yml +++ b/Resources/Prototypes/Entities/Structures/Power/Generation/Singularity/emitter.yml @@ -31,10 +31,10 @@ shader: unshaded visible: false map: ["enum.EmitterVisualLayers.Lights"] - - state: lock + - state: locked shader: unshaded visible: false - map: ["enum.StorageVisualLayers.Lock"] + map: ["enum.LockVisualLayers.Lock"] - type: Emitter - type: Gun showExamineText: false @@ -83,6 +83,7 @@ - type: Appearance - type: Lock locked: false + - type: LockVisuals - type: AccessReader access: [[ "Engineering" ]] - type: Machine diff --git a/Resources/Prototypes/Entities/Structures/Storage/Canisters/gas_canisters.yml b/Resources/Prototypes/Entities/Structures/Storage/Canisters/gas_canisters.yml index 760eb31755..897b7be6ff 100644 --- a/Resources/Prototypes/Entities/Structures/Storage/Canisters/gas_canisters.yml +++ b/Resources/Prototypes/Entities/Structures/Storage/Canisters/gas_canisters.yml @@ -24,10 +24,10 @@ tankInserted: False: { state: can-open, visible: false } True: { state: can-open, visible: true } - enum.GasCanisterVisuals.Locked: + enum.LockVisuals.Locked: locked: - False: { state: can-unlocked, shader: "unshaded" } - True: { state: can-locked, shader: "unshaded" } + False: { state: unlocked, shader: "unshaded" } + True: { state: locked, shader: "unshaded" } enum.GasCanisterVisuals.PressureState: pressureLight: 0: { state: can-o0, shader: "unshaded" } diff --git a/Resources/Prototypes/Entities/Structures/Storage/Closets/Lockers/base_structurelockers.yml b/Resources/Prototypes/Entities/Structures/Storage/Closets/Lockers/base_structurelockers.yml index 4448d551e3..7ab24f6b5c 100644 --- a/Resources/Prototypes/Entities/Structures/Storage/Closets/Lockers/base_structurelockers.yml +++ b/Resources/Prototypes/Entities/Structures/Storage/Closets/Lockers/base_structurelockers.yml @@ -5,6 +5,7 @@ components: - type: AccessReader - type: Lock + - type: LockVisuals - type: Sprite sprite: Structures/Storage/closet.rsi noRot: true @@ -14,7 +15,7 @@ - state: generic_door map: ["enum.StorageVisualLayers.Door"] - state: locked - map: ["enum.StorageVisualLayers.Lock"] + map: ["enum.LockVisualLayers.Lock"] shader: unshaded - state: welded visible: false diff --git a/Resources/Prototypes/Entities/Structures/Storage/Closets/base_structureclosets.yml b/Resources/Prototypes/Entities/Structures/Storage/Closets/base_structureclosets.yml index d1a60566d4..46ec7cbf6a 100644 --- a/Resources/Prototypes/Entities/Structures/Storage/Closets/base_structureclosets.yml +++ b/Resources/Prototypes/Entities/Structures/Storage/Closets/base_structureclosets.yml @@ -180,6 +180,7 @@ components: - type: AccessReader - type: Lock + - type: LockVisuals - type: Sprite sprite: Structures/Storage/wall_locker.rsi layers: @@ -188,7 +189,7 @@ - state: generic_door map: ["enum.StorageVisualLayers.Door"] - state: locked - map: ["enum.StorageVisualLayers.Lock"] + map: ["enum.LockVisualLayers.Lock"] shader: unshaded - state: welded visible: false @@ -222,7 +223,7 @@ visible: false map: ["enum.WeldableLayers.BaseWelded"] - state: locked - map: ["enum.StorageVisualLayers.Lock"] + map: ["enum.LockVisualLayers.Lock"] shader: unshaded - type: MovedByPressure - type: DamageOnHighSpeedImpact @@ -282,7 +283,6 @@ - type: Appearance - type: EntityStorageVisuals stateBase: base - stateLocked: locked - stateUnlocked: unlocked stateDoorOpen: base stateDoorClosed: door + - type: LockVisuals diff --git a/Resources/Prototypes/Entities/Structures/Storage/Crates/base_structurecrates.yml b/Resources/Prototypes/Entities/Structures/Storage/Crates/base_structurecrates.yml index 76a88e7858..acf4fd2149 100644 --- a/Resources/Prototypes/Entities/Structures/Storage/Crates/base_structurecrates.yml +++ b/Resources/Prototypes/Entities/Structures/Storage/Crates/base_structurecrates.yml @@ -87,6 +87,7 @@ id: CrateBaseSecure components: - type: Lock + - type: LockVisuals - type: AccessReader - type: Icon sprite: Structures/Storage/Crates/secure.rsi @@ -101,7 +102,7 @@ visible: false map: ["enum.WeldableLayers.BaseWelded"] - state: locked - map: ["enum.StorageVisualLayers.Lock"] + map: ["enum.LockVisualLayers.Lock"] shader: unshaded - type: Damageable damageContainer: StructuralInorganic diff --git a/Resources/Textures/Objects/Specific/Security/barrier.rsi/deployed.png b/Resources/Textures/Objects/Specific/Security/barrier.rsi/locked.png similarity index 100% rename from Resources/Textures/Objects/Specific/Security/barrier.rsi/deployed.png rename to Resources/Textures/Objects/Specific/Security/barrier.rsi/locked.png diff --git a/Resources/Textures/Objects/Specific/Security/barrier.rsi/meta.json b/Resources/Textures/Objects/Specific/Security/barrier.rsi/meta.json index 8142924b68..5cd7cffb03 100644 --- a/Resources/Textures/Objects/Specific/Security/barrier.rsi/meta.json +++ b/Resources/Textures/Objects/Specific/Security/barrier.rsi/meta.json @@ -11,7 +11,7 @@ "name": "idle" }, { - "name": "deployed", + "name": "locked", "delays": [ [ 0.1, diff --git a/Resources/Textures/Structures/Power/Generation/Singularity/emitter.rsi/lock.png b/Resources/Textures/Structures/Power/Generation/Singularity/emitter.rsi/locked.png similarity index 100% rename from Resources/Textures/Structures/Power/Generation/Singularity/emitter.rsi/lock.png rename to Resources/Textures/Structures/Power/Generation/Singularity/emitter.rsi/locked.png diff --git a/Resources/Textures/Structures/Power/Generation/Singularity/emitter.rsi/meta.json b/Resources/Textures/Structures/Power/Generation/Singularity/emitter.rsi/meta.json index 0456b99ffa..5b5b51257a 100644 --- a/Resources/Textures/Structures/Power/Generation/Singularity/emitter.rsi/meta.json +++ b/Resources/Textures/Structures/Power/Generation/Singularity/emitter.rsi/meta.json @@ -34,7 +34,7 @@ ] }, { - "name": "lock", + "name": "locked", "directions": 4 }, { diff --git a/Resources/Textures/Structures/Storage/canister.rsi/can-locked.png b/Resources/Textures/Structures/Storage/canister.rsi/locked.png similarity index 100% rename from Resources/Textures/Structures/Storage/canister.rsi/can-locked.png rename to Resources/Textures/Structures/Storage/canister.rsi/locked.png diff --git a/Resources/Textures/Structures/Storage/canister.rsi/meta.json b/Resources/Textures/Structures/Storage/canister.rsi/meta.json index 7f9dfe2340..95d67cc8ae 100644 --- a/Resources/Textures/Structures/Storage/canister.rsi/meta.json +++ b/Resources/Textures/Structures/Storage/canister.rsi/meta.json @@ -23,10 +23,10 @@ "name": "can-connector" }, { - "name": "can-locked" + "name": "locked" }, { - "name": "can-unlocked" + "name": "unlocked" }, { "name": "can-o0", diff --git a/Resources/Textures/Structures/Storage/canister.rsi/can-unlocked.png b/Resources/Textures/Structures/Storage/canister.rsi/unlocked.png similarity index 100% rename from Resources/Textures/Structures/Storage/canister.rsi/can-unlocked.png rename to Resources/Textures/Structures/Storage/canister.rsi/unlocked.png