diff --git a/Content.Client/GameObjects/Components/Storage/ClientStorageComponent.cs b/Content.Client/GameObjects/Components/Storage/ClientStorageComponent.cs index 9df61aa0b3..e2c9d7b021 100644 --- a/Content.Client/GameObjects/Components/Storage/ClientStorageComponent.cs +++ b/Content.Client/GameObjects/Components/Storage/ClientStorageComponent.cs @@ -11,6 +11,8 @@ using Robust.Shared.Utility; using System; using System.Collections.Generic; using Robust.Client.Interfaces.Graphics; +using Robust.Shared.Serialization; +using Robust.Shared.ViewVariables; namespace Content.Client.GameObjects.Components.Storage { @@ -24,6 +26,9 @@ namespace Content.Client.GameObjects.Components.Storage private int StorageCapacityMax; private StorageWindow Window; + [ViewVariables] private string _closedState; + [ViewVariables] private string _openState; + public bool Open { get => _open; @@ -48,6 +53,14 @@ namespace Content.Client.GameObjects.Components.Storage base.OnRemove(); } + public override void ExposeData(ObjectSerializer serializer) + { + base.ExposeData(serializer); + + serializer.DataField(ref _closedState, "state_door_closed", null); + serializer.DataField(ref _openState, "state_door_open", null); + } + /// public override void HandleComponentState(ComponentState curState, ComponentState nextState) { @@ -127,7 +140,7 @@ namespace Content.Client.GameObjects.Components.Storage var baseName = spriteComp.LayerGetState(0).Name; - var stateId = open ? $"{baseName}_open" : $"{baseName}_door"; + var stateId = open ? _openState ?? $"{baseName}_open" : _closedState ?? $"{baseName}_door"; if (spriteComp.BaseRSI.TryGetState(stateId, out _)) spriteComp.LayerSetState(1, stateId); diff --git a/Content.Server/GameObjects/Components/EntityStorageComponent.cs b/Content.Server/GameObjects/Components/EntityStorageComponent.cs index cf508b37bd..28c22739cf 100644 --- a/Content.Server/GameObjects/Components/EntityStorageComponent.cs +++ b/Content.Server/GameObjects/Components/EntityStorageComponent.cs @@ -25,8 +25,13 @@ namespace Content.Server.GameObjects.Components { base.Initialize(); Contents = ContainerManagerComponent.Ensure($"{typeof(EntityStorageComponent).FullName}{Owner.Uid.ToString()}", Owner); - StorageComponent = Owner.AddComponent(); - StorageComponent.Initialize(); + if (!Owner.TryGetComponent(out StorageComponent)) + { + StorageComponent = Owner.AddComponent(); + // TODO: This is a terrible hack. + // Components should not need to be manually initialized in Initialize(). + StorageComponent.Initialize(); + } entityQuery = new IntersectingEntityQuery(Owner); } diff --git a/Resources/Prototypes/Entities/closet.yml b/Resources/Prototypes/Entities/closet.yml index 2f102c1969..db3324d9af 100644 --- a/Resources/Prototypes/Entities/closet.yml +++ b/Resources/Prototypes/Entities/closet.yml @@ -11,7 +11,7 @@ - type: Icon sprite: Buildings/closet.rsi - state: generic + state: generic_door - type: Clickable - type: BoundingBox @@ -23,8 +23,83 @@ mass: 25 Anchored: false - type: EntityStorage + - type: Storage + state_door_open: generic_open + state_door_closed: generic_door - type: PlaceableSurface placement: snap: - - Wall \ No newline at end of file + - Wall + +- type: entity + id: locker_tool + name: Tool Locker + parent: locker_generic + components: + - type: Sprite + sprite: Buildings/closet.rsi + layers: + - state: eng + - state: eng_tool_door + + - type: Storage + state_door_closed: eng_tool_door + state_door_open: eng_open + + - type: Icon + state: eng_tool_door + +- type: entity + id: locker_electrical_supplies + name: Electrical Supplies Locker + parent: locker_generic + components: + - type: Sprite + sprite: Buildings/closet.rsi + layers: + - state: eng + - state: eng_elec_door + + - type: Storage + state_door_closed: eng_elec_door + state_door_open: eng_open + + - type: Icon + state: eng_elec_door + +- type: entity + id: locker_welding_supplies + name: Welding Supplies Locker + parent: locker_generic + components: + - type: Sprite + sprite: Buildings/closet.rsi + layers: + - state: eng + - state: eng_weld_door + + - type: Storage + state_door_closed: eng_weld_door + state_door_open: eng_open + + - type: Icon + state: eng_weld_door + +- type: entity + id: locker_radiation_suit + name: Radiation Suit Locker + parent: locker_generic + components: + - type: Sprite + sprite: Buildings/closet.rsi + layers: + - state: eng + - state: eng_rad_door + + - type: Storage + state_door_closed: eng_rad_door + state_door_open: eng_open + + - type: Icon + state: eng_rad_door diff --git a/Resources/Textures/Buildings/closet.rsi/eng.png b/Resources/Textures/Buildings/closet.rsi/eng.png new file mode 100644 index 0000000000..2eaee7a97c Binary files /dev/null and b/Resources/Textures/Buildings/closet.rsi/eng.png differ diff --git a/Resources/Textures/Buildings/closet.rsi/eng_elec_door.png b/Resources/Textures/Buildings/closet.rsi/eng_elec_door.png new file mode 100644 index 0000000000..13b47e2533 Binary files /dev/null and b/Resources/Textures/Buildings/closet.rsi/eng_elec_door.png differ diff --git a/Resources/Textures/Buildings/closet.rsi/eng_open.png b/Resources/Textures/Buildings/closet.rsi/eng_open.png new file mode 100644 index 0000000000..535f4a7527 Binary files /dev/null and b/Resources/Textures/Buildings/closet.rsi/eng_open.png differ diff --git a/Resources/Textures/Buildings/closet.rsi/eng_rad_door.png b/Resources/Textures/Buildings/closet.rsi/eng_rad_door.png new file mode 100644 index 0000000000..f05348177c Binary files /dev/null and b/Resources/Textures/Buildings/closet.rsi/eng_rad_door.png differ diff --git a/Resources/Textures/Buildings/closet.rsi/eng_tool_door.png b/Resources/Textures/Buildings/closet.rsi/eng_tool_door.png new file mode 100644 index 0000000000..6a79b6a186 Binary files /dev/null and b/Resources/Textures/Buildings/closet.rsi/eng_tool_door.png differ diff --git a/Resources/Textures/Buildings/closet.rsi/eng_weld_door.png b/Resources/Textures/Buildings/closet.rsi/eng_weld_door.png new file mode 100644 index 0000000000..8d8729d153 Binary files /dev/null and b/Resources/Textures/Buildings/closet.rsi/eng_weld_door.png differ diff --git a/Resources/Textures/Buildings/closet.rsi/meta.json b/Resources/Textures/Buildings/closet.rsi/meta.json index 49576de12f..f10c112ecd 100644 --- a/Resources/Textures/Buildings/closet.rsi/meta.json +++ b/Resources/Textures/Buildings/closet.rsi/meta.json @@ -24,6 +24,42 @@ "select": [], "flags": {}, "directions": 1 + }, + { + "name": "eng", + "select": [], + "flags": {}, + "directions": 1 + }, + { + "name": "eng_open", + "select": [], + "flags": {}, + "directions": 1 + }, + { + "name": "eng_tool_door", + "select": [], + "flags": {}, + "directions": 1 + }, + { + "name": "eng_rad_door", + "select": [], + "flags": {}, + "directions": 1 + }, + { + "name": "eng_elec_door", + "select": [], + "flags": {}, + "directions": 1 + }, + { + "name": "eng_weld_door", + "select": [], + "flags": {}, + "directions": 1 } ] -} \ No newline at end of file +}