From 6e5680b3c278f96f657eceb3a2db1c592b6e397f Mon Sep 17 00:00:00 2001 From: Pieter-Jan Briers Date: Fri, 26 Apr 2019 23:44:26 +0200 Subject: [PATCH] Engineering lockers. (#210) * Import Eris engineering locker sprites. * Allow customizing ClientStorageComponent open/close states better. * EntityStorage does not blow up if Storage is also defined in prototype. * Engineering styled lockers. --- .../Storage/ClientStorageComponent.cs | 15 +++- .../Components/EntityStorageComponent.cs | 9 +- Resources/Prototypes/Entities/closet.yml | 79 +++++++++++++++++- .../Textures/Buildings/closet.rsi/eng.png | Bin 0 -> 178 bytes .../Buildings/closet.rsi/eng_elec_door.png | Bin 0 -> 203 bytes .../Buildings/closet.rsi/eng_open.png | Bin 0 -> 158 bytes .../Buildings/closet.rsi/eng_rad_door.png | Bin 0 -> 215 bytes .../Buildings/closet.rsi/eng_tool_door.png | Bin 0 -> 208 bytes .../Buildings/closet.rsi/eng_weld_door.png | Bin 0 -> 205 bytes .../Textures/Buildings/closet.rsi/meta.json | 38 ++++++++- 10 files changed, 135 insertions(+), 6 deletions(-) create mode 100644 Resources/Textures/Buildings/closet.rsi/eng.png create mode 100644 Resources/Textures/Buildings/closet.rsi/eng_elec_door.png create mode 100644 Resources/Textures/Buildings/closet.rsi/eng_open.png create mode 100644 Resources/Textures/Buildings/closet.rsi/eng_rad_door.png create mode 100644 Resources/Textures/Buildings/closet.rsi/eng_tool_door.png create mode 100644 Resources/Textures/Buildings/closet.rsi/eng_weld_door.png 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 0000000000000000000000000000000000000000..2eaee7a97caf429617b21c6c1c38072ed5d39350 GIT binary patch literal 178 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnF3?v&v(vJfv(Ey(i*8>L*$jhr2xoX|pX1k-s zz{JA#)$Qhw9RiPm3K&a*{DK)Ap4~_Ta=blV978lFCMPg3IjR~6q%<%liW?ZTaJNV{ zJ8E$<9n4Hf;1cI(W!lle<L*$jhr2xoX|pX8Y=P z^Ntn+6ARk~tV|n$3K&a*{DK)Ap4~_Ta#B29978lFCMQT(D5N}MVma5v!FV}9fx}JI z!&R6g*j3oW>H4H;ZFy}{vm6B47D`-O#L=O-kXxcvt5s_u2g^#fm5(kr9W6enr?*Ul x$+0tO)smGQtjsEmp#t_Co(jA?0!&L7859$=oj%RTa|7DP;OXk;vd$@?2>^KBJGTG; literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..535f4a752779b64a2630e737888d9fabbf9b2930 GIT binary patch literal 158 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnF3?v&v(vJfv{s5m4*8>L*m{{2EXfY^q)smN2 zf2QWS0w~2;666=m;PC858jxe_>EaloF)=woqQxOVz}LYuGJwVPzzvU+0-*L*$jhr2xoX|pX8Y=P z^Ntn+6ARk~tV|n$3K&a*{DK)Ap4~_Tatb_M978lF9zC<0x50qNH85?#0`?TP4i4@K zoHCZS3itjgf5?2a!@=w5+oC6Xmi=5`##f#_|KRD^D-41e5d~^8TrwSob$K3EybNs1 z?mFze$SXESU^3&vPp1#eU%a+o@ds1I>lN>u?ulIZoW@#lI^a5Ms-kwJ!Ky{9K)V?{ MUHx3vIVCg!0K$e%9smFU literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..6a79b6a186e0676b0924e994b0523ec99615ca1e GIT binary patch literal 208 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnF3?v&v(vJfv(Ey(i*8>L*$jhr2xoX|pX8Y=P z^Ntn+6ARk~tV|n$3K&a*{DK)Ap4~_Taxy(#978lFCMQT(D5N}MVma5v!FV}9fx}HS zz*(5X%T<`eo7Y*`!`n$Tz&qGgki*M)v#O5h;V2PCL)8+-#R^LUR6`iADyY^(ZK%+@ zarCIj)x^%ERZCWKurjMKh6>nocq;Jn2rw;SWMH<@)>RKG-wd>r!PC{xWt~$(696i6 BI6nXY literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..8d8729d1534945902713a66a11c6f848d31a1cc0 GIT binary patch literal 205 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnF3?v&v(vJfv(Ey(i*8>L*$jhr2xoX|pX8Y=P z^Ntn+6ARk~tV|n$3K&a*{DK)Ap4~_Ta?(6q978lFCMQT(D5N}MVma5v!FV}9fx}JI zBiL2YgPAErG%<07mQ(Ykpo?cXlr