Skip to content

Game.Prefabs.MarkerNet

Assembly: Assembly-CSharp (game runtime assembly)
Namespace: Game.Prefabs

Type: class

Base: ComponentBase

Summary:
MarkerNet is a prefab component class used by net-related prefabs (registered under the "Net/" ComponentMenu). Its purpose is to ensure that net prefabs include the MarkerNetData component at prefab creation time and to add a Marker component into the entity archetype when the archetype contains either Edge or Node components. It is used for pathway/taxiway/powerline/pipeline style net prefabs to mark entities for net-related behaviour or tracking.


Fields

  • This class declares no private or public fields in the source file.

Properties

  • This class declares no properties.

Constructors

  • public MarkerNet()
    The default parameterless constructor is implicit (no custom construction logic in the source).

Methods

  • public override void GetPrefabComponents(HashSet<ComponentType> components)
    Adds the MarkerNetData component type to the provided set of prefab component types:
  • components.Add(ComponentType.ReadWrite())

Purpose: ensure the prefab will have MarkerNetData available when instantiated.

  • public override void GetArchetypeComponents(HashSet<ComponentType> components)
    Conditionally adds the Marker component to the provided archetype component set:
  • If the archetype already contains Edge (ComponentType.ReadWrite()), add Marker.
  • Else if the archetype contains Node (ComponentType.ReadWrite()), add Marker.

Purpose: when building entity archetypes for nets, the presence of Edge or Node indicates this prefab represents net segments/nodes and therefore needs Marker for per-entity marking/handling.

Additional notes: - The class is annotated with [ComponentMenu("Net/", new Type[] { typeof(PathwayPrefab), typeof(TaxiwayPrefab), typeof(PowerLinePrefab), typeof(PipelinePrefab) })], which places it into the editor/component menu under "Net/" and associates it with those prefab types. - The code uses ComponentType.ReadWrite() to declare required ECS component types.

Usage Example

// Example: The MarkerNet class itself (source) ensures MarkerNetData is added to the prefab and Marker
// is added to the archetype when Edge or Node components are present.

[ComponentMenu("Net/", new Type[]
{
    typeof(PathwayPrefab),
    typeof(TaxiwayPrefab),
    typeof(PowerLinePrefab),
    typeof(PipelinePrefab)
})]
public class MarkerNet : ComponentBase
{
    public override void GetPrefabComponents(HashSet<ComponentType> components)
    {
        components.Add(ComponentType.ReadWrite<MarkerNetData>());
    }

    public override void GetArchetypeComponents(HashSet<ComponentType> components)
    {
        if (components.Contains(ComponentType.ReadWrite<Edge>()))
        {
            components.Add(ComponentType.ReadWrite<Marker>());
        }
        else if (components.Contains(ComponentType.ReadWrite<Node>()))
        {
            components.Add(ComponentType.ReadWrite<Marker>());
        }
    }
}

Practical effect: when a net prefab that uses MarkerNet is registered, its prefab will include MarkerNetData. When an entity archetype for that prefab is constructed and already contains Edge or Node, Marker will be added to the archetype so the runtime systems that rely on Marker can operate on those entities.