Files
tbd-station-14/Content.Shared/GameObjects/Components/Storage/SharedStorageComponent.cs
Acruid 3dc3031054 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.
2018-10-25 17:35:34 -07:00

96 lines
2.6 KiB
C#

using SS14.Shared.GameObjects;
using SS14.Shared.Serialization;
using System;
using System.Collections.Generic;
namespace Content.Shared.GameObjects.Components.Storage
{
public abstract class SharedStorageComponent : Component
{
public sealed override string Name => "Storage";
public override uint? NetID => ContentNetIDs.INVENTORY;
public override Type StateType => typeof(StorageComponentState);
protected bool _open;
/// <inheritdoc />
public override void ExposeData(ObjectSerializer serializer)
{
base.ExposeData(serializer);
serializer.DataField(ref _open, "open", false);
}
}
[Serializable, NetSerializable]
public class StorageComponentState : ComponentState
{
public bool Open { get; }
public StorageComponentState(bool open)
: base(ContentNetIDs.INVENTORY)
{
Open = open;
}
}
/// <summary>
/// Updates the client component about what entities this storage is holding
/// </summary>
[Serializable, NetSerializable]
public class StorageHeldItemsMessage : ComponentMessage
{
public readonly int StorageSizeMax;
public readonly int StorageSizeUsed;
public Dictionary<EntityUid, int> StoredEntities;
public StorageHeldItemsMessage(Dictionary<EntityUid, int> storedentities, int storageused, int storagemaxsize)
{
Directed = true;
StorageSizeMax = storagemaxsize;
StorageSizeUsed = storageused;
StoredEntities = storedentities;
}
}
/// <summary>
/// Component message for removing a contained entity from the storage entity
/// </summary>
[Serializable, NetSerializable]
public class RemoveEntityMessage : ComponentMessage
{
public EntityUid EntityUid;
public RemoveEntityMessage(EntityUid entityuid)
{
Directed = true;
EntityUid = entityuid;
}
}
/// <summary>
/// Component message for opening the storage UI
/// </summary>
[Serializable, NetSerializable]
public class OpenStorageUIMessage : ComponentMessage
{
public OpenStorageUIMessage()
{
Directed = true;
}
}
/// <summary>
/// Component message for closing the storage UI.
/// E.g when the player moves too far away from the container.
/// </summary>
[Serializable, NetSerializable]
public class CloseStorageUIMessage : ComponentMessage
{
public CloseStorageUIMessage()
{
Directed = true;
}
}
}