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.
This commit is contained in:
Acruid
2018-10-25 17:35:34 -07:00
committed by GitHub
parent 6cc88115b5
commit 3dc3031054
18 changed files with 296 additions and 6 deletions

View File

@@ -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();
}
/// <inheritdoc />
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();
}
/// <summary>
/// Function for clicking one of the stored entity buttons in the UI, tells server to remove that entity
/// </summary>
@@ -89,6 +115,22 @@ namespace Content.Client.GameObjects.Components.Storage
SendNetworkMessage(new RemoveEntityMessage(entityuid));
}
private void SetDoorSprite(bool open)
{
if(!Owner.TryGetComponent<ISpriteComponent>(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);
}
/// <summary>
/// GUI class for client storage component
/// </summary>
@@ -113,6 +155,12 @@ namespace Content.Client.GameObjects.Components.Storage
Information = VSplitContainer.GetChild<Label>("Information");
}
public override void Close()
{
StorageEntity.SendNetworkMessage(new CloseStorageUIMessage());
base.Close();
}
/// <summary>
/// Loops through stored entities creating buttons for each, updates information labels
/// </summary>