Show / Hide Table of Contents

Class ItemMapperComponent

ItemMapperComponent is a that maps string labels to an EntityWhitelist of elements. Useful primarily for visualization.

To define a mapping, create a mapLayers map in configuration ItemMapper component and with MapLayers mapping. Each map layer maps layer name to an EntityWhitelist, 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 ItemCounterComponent

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 TagComponent 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.

EntityWhitelist SharedMapLayerData
Inheritance
System.Object
ItemMapperComponent
Namespace: Content.Shared.Storage.Components
Assembly: Content.Shared.dll
Syntax
public sealed class ItemMapperComponent : Component

Fields

| Improve this Doc View Source

ContainerWhitelist

If this exists, shown layers will only consider entities in the given containers.

Declaration
public HashSet<string>? ContainerWhitelist
Field Value
Type Description
System.Nullable<HashSet<System.String>>
| Improve this Doc View Source

MapLayers

Declaration
public Dictionary<string, SharedMapLayerData> MapLayers
Field Value
Type Description
Dictionary<System.String, SharedMapLayerData>
| Improve this Doc View Source

RSIPath

Declaration
public ResPath? RSIPath
Field Value
Type Description
System.Nullable<Robust.Shared.Utility.ResPath>
| Improve this Doc View Source

SpriteLayers

The list of map layer keys that are valid targets for changing in MapLayers Can be initialized if already existing on the sprite, or inferred automatically

Declaration
public List<string> SpriteLayers
Field Value
Type Description
List<System.String>
  • Improve this Doc
  • View Source
☀
☾
In This Article
Back to top
Generated by DocFX
☀
☾