Cigarette ecs (#4495)
* Reorganized Shared.Storage folder * Replace StorageCounter with Item Counter * Change stack visuals setting data * Fix mirrorcult suggestions * Fix items from upstream * Fix type formatting
This commit is contained in:
33
Content.Shared/Storage/Components/ItemCounterComponent.cs
Normal file
33
Content.Shared/Storage/Components/ItemCounterComponent.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using Content.Shared.Storage.EntitySystems;
|
||||
using Content.Shared.Whitelist;
|
||||
using Robust.Shared.Analyzers;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
|
||||
namespace Content.Shared.Storage.Components
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Storage that spawns and counts a single item.
|
||||
/// Usually used for things like matchboxes, cigarette packs,
|
||||
/// cigar cases etc.
|
||||
/// </summary>
|
||||
/// <code>
|
||||
/// - type: ItemCounter
|
||||
/// amount: 6 # Note: this field can be omitted.
|
||||
/// count:
|
||||
/// tags: [Cigarette]
|
||||
/// </code>
|
||||
[RegisterComponent]
|
||||
[Friend(typeof(SharedItemCounterSystem))]
|
||||
public class ItemCounterComponent : Component
|
||||
{
|
||||
public override string Name => "ItemCounter";
|
||||
|
||||
[DataField("count", required: true)]
|
||||
public EntityWhitelist Count { get; set; } = default!;
|
||||
|
||||
[DataField("amount")]
|
||||
public int? MaxAmount { get; set; }
|
||||
}
|
||||
}
|
||||
27
Content.Shared/Storage/Components/ItemMapperComponent.cs
Normal file
27
Content.Shared/Storage/Components/ItemMapperComponent.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using System.Collections.Generic;
|
||||
using Content.Shared.Storage.EntitySystems;
|
||||
using Robust.Shared.Analyzers;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
|
||||
namespace Content.Shared.Storage.Components
|
||||
{
|
||||
[RegisterComponent]
|
||||
[Friend(typeof(SharedItemMapperSystem))]
|
||||
public class ItemMapperComponent : Component, ISerializationHooks
|
||||
{
|
||||
public override string Name => "ItemMapper";
|
||||
|
||||
[DataField("mapLayers")] public readonly Dictionary<string, SharedMapLayerData> MapLayers = new();
|
||||
|
||||
void ISerializationHooks.AfterDeserialization()
|
||||
{
|
||||
foreach (var (layerName, val) in MapLayers)
|
||||
{
|
||||
val.Layer = layerName;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
18
Content.Shared/Storage/Components/SharedBagOpenVisuals.cs
Normal file
18
Content.Shared/Storage/Components/SharedBagOpenVisuals.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Storage.Components
|
||||
{
|
||||
[Serializable, NetSerializable]
|
||||
public enum SharedBagOpenVisuals : byte
|
||||
{
|
||||
BagState,
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public enum SharedBagState : byte
|
||||
{
|
||||
Open,
|
||||
Close,
|
||||
}
|
||||
}
|
||||
46
Content.Shared/Storage/Components/SharedMapLayerData.cs
Normal file
46
Content.Shared/Storage/Components/SharedMapLayerData.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Content.Shared.Whitelist;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
|
||||
namespace Content.Shared.Storage.Components
|
||||
{
|
||||
[Serializable, NetSerializable]
|
||||
public enum StorageMapVisuals : sbyte
|
||||
{
|
||||
InitLayers,
|
||||
LayerChanged,
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
[DataDefinition]
|
||||
public class SharedMapLayerData
|
||||
{
|
||||
public string Layer = string.Empty;
|
||||
|
||||
[DataField("whitelist", required: true)]
|
||||
public EntityWhitelist Whitelist { get; set; } = new();
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public class ShowLayerData
|
||||
{
|
||||
public IReadOnlyList<string> QueuedEntities { get; internal set; }
|
||||
|
||||
public ShowLayerData()
|
||||
{
|
||||
QueuedEntities = new List<string>();
|
||||
}
|
||||
|
||||
public ShowLayerData(IReadOnlyList<string> other)
|
||||
{
|
||||
QueuedEntities = other;
|
||||
}
|
||||
|
||||
public ShowLayerData(ShowLayerData other)
|
||||
{
|
||||
QueuedEntities = other.QueuedEntities;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user