diff --git a/Content.Server/Storage/EntitySystems/ItemMapperSystem.cs b/Content.Server/Storage/EntitySystems/ItemMapperSystem.cs index 00aa0f5b12..6662213215 100644 --- a/Content.Server/Storage/EntitySystems/ItemMapperSystem.cs +++ b/Content.Server/Storage/EntitySystems/ItemMapperSystem.cs @@ -6,6 +6,7 @@ using Robust.Shared.Containers; namespace Content.Server.Storage.EntitySystems { + /// [UsedImplicitly] public sealed class ItemMapperSystem : SharedItemMapperSystem { diff --git a/Content.Shared/Storage/Components/ItemMapperComponent.cs b/Content.Shared/Storage/Components/ItemMapperComponent.cs index 624db7f3b1..459ff73a4a 100644 --- a/Content.Shared/Storage/Components/ItemMapperComponent.cs +++ b/Content.Shared/Storage/Components/ItemMapperComponent.cs @@ -3,6 +3,55 @@ using Robust.Shared.Serialization; namespace Content.Shared.Storage.Components { + /// + /// ItemMapperComponent is a that maps string labels to an of elements. Useful primarily for visualization. + /// + /// To define a mapping, create a mapLayers map in configuration ItemMapper component and with mapping. + /// Each map layer maps layer name to an , plus special modifiers for min and max item count. + /// Min and max count are useful when you need to visualize a certain number of items, for example, to display one, two, three, or more items. + /// + /// + /// If you need a more straightforward way to change appearance where only variable is how many items, rather than which items + /// and how many, see + /// + /// + /// For a contrived example, create a tool-belt with a Power drill slot and two light bulb slots. + /// To use this for visualization, we need a or VisualizerSystem, e.g. + /// + /// - type: Appearance + /// visuals: + /// - type: MappedItemVisualizer + /// + /// To map Powerdrill to the given example, we need the following code. + /// + /// - type: ItemMapper + /// mapLayers: + /// drill: + /// whitelist: + /// tags: + /// - Powerdrill + /// #... to be continued + /// + /// To map Lightbulb (not tag) to two different layers (for one and two light bulbs, respectively) + /// + /// #... to be continued + /// lightbulb1: + /// minCount: 1 + /// whitelist: + /// component: + /// - Lightbulb + /// lightbulb2: + /// minCount: 2 + /// whitelist: + /// component: + /// - Lightbulb + /// + /// The min count will ensure that lightbulb1 layer is only displayed when one or more light bulbs are in the belt. + /// And lightbulb2 layer will only be shown when two or more light bulbs are inserted. + /// + /// + /// + /// [RegisterComponent] [Access(typeof(SharedItemMapperSystem))] public sealed class ItemMapperComponent : Component, ISerializationHooks diff --git a/Content.Shared/Storage/EntitySystems/SharedItemMapperSystem.cs b/Content.Shared/Storage/EntitySystems/SharedItemMapperSystem.cs index 6e9d4f9c19..55d8fe17c8 100644 --- a/Content.Shared/Storage/EntitySystems/SharedItemMapperSystem.cs +++ b/Content.Shared/Storage/EntitySystems/SharedItemMapperSystem.cs @@ -4,6 +4,11 @@ using Robust.Shared.Containers; namespace Content.Shared.Storage.EntitySystems { + /// + /// ItemMapperSystem is a system that on each initialization, insertion, removal of an entity from + /// given (with appropriate storage attached) will check each stored item to see + /// if its tags/component, and overall quantity match . + /// [UsedImplicitly] public abstract class SharedItemMapperSystem : EntitySystem { @@ -45,6 +50,17 @@ namespace Content.Shared.Storage.EntitySystems } } + /// + /// Method that iterates over storage of the entity in and sets according to + /// definition. It will have O(n*m) time behavior (n - number of entities in container, and m - number of + /// definitions in . + /// + /// event with EntityUid used to search the storage + /// component that contains definition used to map whitelist in + /// mapLayers to string. + /// + /// list of layers that should be visible + /// false if msg.Container.Owner is not a storage, true otherwise. protected abstract bool TryGetLayers(ContainerModifiedMessage msg, ItemMapperComponent itemMapper, out IReadOnlyList containedLayers);