From 3dc303105429da582b7ca199cd3647debe8086d1 Mon Sep 17 00:00:00 2001 From: Acruid Date: Thu, 25 Oct 2018 17:35:34 -0700 Subject: [PATCH] World Storage (#112) * Added generic crate assets. Added open flag to StorageComponent. * StorageComponent door toggling works. * Door now updates based on if someone is subscribed to the Storage. * Added License to crate.rsi Fixed Icon of crate. * Added basic Locker. * Added Fire Extinguisher. * Added ability to close the storage UI by the server. Notify the server that the UI is closed, so that the player is unsubscribed from the storage. Unsubscribe the player from a storage if the player entity moves out of range. * Add check to make sure entity is on the same map as the storage. * Update Engine module. * Update Engine. --- .../Storage/ClientStorageComponent.cs | 50 ++++++++++++++- Content.Server/Content.Server.csproj | 1 + .../Items/Storage/ServerStorageComponent.cs | 50 +++++++++++++-- .../EntitySystems/StorageSystem.cs | 57 ++++++++++++++++++ .../Storage/SharedStorageComponent.cs | 23 +++++++ Resources/Prototypes/Entities/Container.yml | 24 ++++++++ Resources/Prototypes/Entities/Items.yml | 13 ++++ Resources/Prototypes/Entities/closet.yml | 24 ++++++++ .../Textures/Buildings/closet.rsi/generic.png | Bin 0 -> 178 bytes .../Buildings/closet.rsi/generic_door.png | Bin 0 -> 177 bytes .../Buildings/closet.rsi/generic_open.png | Bin 0 -> 165 bytes .../Textures/Buildings/closet.rsi/meta.json | 29 +++++++++ .../Textures/Buildings/crate.rsi/crate.png | Bin 0 -> 278 bytes .../Buildings/crate.rsi/crate_door.png | Bin 0 -> 183 bytes .../Buildings/crate.rsi/crate_open.png | Bin 0 -> 166 bytes .../Textures/Buildings/crate.rsi/meta.json | 29 +++++++++ .../Textures/Objects/fire_extinguisher.png | Bin 0 -> 230 bytes engine | 2 +- 18 files changed, 296 insertions(+), 6 deletions(-) create mode 100644 Content.Server/GameObjects/EntitySystems/StorageSystem.cs create mode 100644 Resources/Prototypes/Entities/Container.yml create mode 100644 Resources/Prototypes/Entities/closet.yml create mode 100644 Resources/Textures/Buildings/closet.rsi/generic.png create mode 100644 Resources/Textures/Buildings/closet.rsi/generic_door.png create mode 100644 Resources/Textures/Buildings/closet.rsi/generic_open.png create mode 100644 Resources/Textures/Buildings/closet.rsi/meta.json create mode 100644 Resources/Textures/Buildings/crate.rsi/crate.png create mode 100644 Resources/Textures/Buildings/crate.rsi/crate_door.png create mode 100644 Resources/Textures/Buildings/crate.rsi/crate_open.png create mode 100644 Resources/Textures/Buildings/crate.rsi/meta.json create mode 100644 Resources/Textures/Objects/fire_extinguisher.png diff --git a/Content.Client/GameObjects/Components/Storage/ClientStorageComponent.cs b/Content.Client/GameObjects/Components/Storage/ClientStorageComponent.cs index 72d3df22e4..9878fc0767 100644 --- a/Content.Client/GameObjects/Components/Storage/ClientStorageComponent.cs +++ b/Content.Client/GameObjects/Components/Storage/ClientStorageComponent.cs @@ -27,6 +27,16 @@ namespace Content.Client.GameObjects.Components.Storage private int StorageCapacityMax; private StorageWindow Window; + public bool Open + { + get => _open; + set + { + _open = value; + SetDoorSprite(_open); + } + } + public override void OnAdd() { base.OnAdd(); @@ -41,6 +51,17 @@ namespace Content.Client.GameObjects.Components.Storage base.OnRemove(); } + /// + public override void HandleComponentState(ComponentState state) + { + base.HandleComponentState(state); + + if (!(state is StorageComponentState storageState)) + return; + + Open = storageState.Open; + } + public override void HandleMessage(ComponentMessage message, INetChannel netChannel = null, IComponent component = null) { switch (message) @@ -54,7 +75,7 @@ namespace Content.Client.GameObjects.Components.Storage OpenUI(); break; case CloseStorageUIMessage msg: - // todo: close window/grey it out + CloseUI(); break; } } @@ -80,6 +101,11 @@ namespace Content.Client.GameObjects.Components.Storage Window.Open(); } + private void CloseUI() + { + Window.Close(); + } + /// /// Function for clicking one of the stored entity buttons in the UI, tells server to remove that entity /// @@ -89,6 +115,22 @@ namespace Content.Client.GameObjects.Components.Storage SendNetworkMessage(new RemoveEntityMessage(entityuid)); } + private void SetDoorSprite(bool open) + { + if(!Owner.TryGetComponent(out var spriteComp)) + return; + + if(!spriteComp.Running) + return; + + var baseName = spriteComp.LayerGetState(0).Name; + + var stateId = open ? $"{baseName}_open" : $"{baseName}_door"; + + if (spriteComp.BaseRSI.TryGetState(stateId, out _)) + spriteComp.LayerSetState(1, stateId); + } + /// /// GUI class for client storage component /// @@ -113,6 +155,12 @@ namespace Content.Client.GameObjects.Components.Storage Information = VSplitContainer.GetChild