Skip to content

Game.PlaceableNet

Assembly: Assembly-CSharp
Namespace: Game.Prefabs

Type: public class

Base: ComponentBase

Summary:
PlaceableNet is a prefab component used for placeable network prefabs (roads, rails, etc.). It defines elevation placement bounds, whether parallel-mode placement is allowed, an optional underground counterpart prefab, and an XP reward value. It also declares which ECS components the prefab requires at runtime (via GetPrefabComponents and GetArchetypeComponents) and reports dependent prefabs (such as an underground variant).


Fields

  • public Bounds1 m_ElevationRange = new Bounds1(-50f, 50f);
    Defines the allowed elevation range (min/max) where this net can be placed. Uses Colossal.Mathematics.Bounds1 to represent a single-axis bounds (usually height).

  • public bool m_AllowParallelMode = true;
    When true, this net supports parallel-mode placement (placing parallel instances, e.g., parallel lanes/tracks).

  • public NetPrefab m_UndergroundPrefab;
    Optional reference to an underground variant of this net. If set, GetDependencies will add that prefab to the dependency list so it is included/loaded together.

  • public int m_XPReward;
    Integer XP reward granted when the net is placed (used by progression systems).

Properties

  • This class declares no public properties.

Constructors

  • public PlaceableNet()
    Default parameterless constructor. The class relies on field initializers; no custom construction logic is declared.

Methods

  • public override void GetDependencies(List<PrefabBase> prefabs)
    Adds dependent prefabs to the provided list. Implementation calls base.GetDependencies(prefabs) and, if m_UndergroundPrefab is non-null, adds it to the list. Use: ensures related prefabs (underground variants) are included when this prefab is collected/serialized/loaded.

  • public override void GetPrefabComponents(HashSet<ComponentType> components)
    Adds runtime component requirements for the prefab. This implementation adds PlaceableNetData and PlaceableInfoviewItem (both as ReadWrite) to the supplied components set. Use: ensures the generated entity prefab includes these components.

  • public override void GetArchetypeComponents(HashSet<ComponentType> components)
    Called when building entity archetypes. If NetCompositionData is present in the components set, this method adds PlaceableNetComposition (ReadWrite) to the archetype components. Use: conditionally adds composition data when the net participates in net composition systems.

Usage Example

// Simple initialization (e.g., when creating a prefab instance in code)
var placeable = new PlaceableNet {
    m_ElevationRange = new Bounds1(-10f, 30f),
    m_AllowParallelMode = false,
    m_XPReward = 100,
    m_UndergroundPrefab = myUndergroundNetPrefab // NetPrefab reference
};

// Extending behavior: override to add more dependencies
public class MyCustomPlaceableNet : PlaceableNet
{
    public override void GetDependencies(List<PrefabBase> prefabs)
    {
        base.GetDependencies(prefabs);
        // ensure some other prefab dependency is included
        if (myOtherPrefab != null)
            prefabs.Add(myOtherPrefab);
    }
}