Skip to content

Game.Prefabs.PlaceholderLane

Assembly: Game (Assembly-CSharp)
Namespace: Game.Prefabs

Type: class

Base: ComponentBase

Summary:
PlaceholderLane is a ComponentBase-derived prefab component used for net lane prefabs. It ensures that entities created from the prefab include placeholder-related ECS components (PlaceholderObjectElement for prefab components and Placeholder for archetype/components used during entity creation). It also logs a warning if the associated prefab is marked as a SpawnableLane, which is likely unexpected for a placeholder lane prefab.


Fields

  • This class declares no instance fields.
    {{ The class itself does not declare any private or public fields. It relies on inherited members from ComponentBase and uses ECS ComponentType helpers inside its methods. }}

Properties

  • This class declares no custom properties.
    {{ No properties are defined on PlaceholderLane; it only overrides base methods to supply component lists and initialization behavior. }}

Constructors

  • public PlaceholderLane()
    {{ Uses the default parameterless constructor inherited from System.Object; no custom constructor logic is defined. Instances are typically created by Unity/serialization when loading prefab component data. }}

Methods

  • public override void GetPrefabComponents(HashSet<ComponentType> components)
    {{ Adds ComponentType.ReadWrite() to the provided set. This tells the prefab system to attach PlaceholderObjectElement as a component on the prefab entity(s) when treating this class as a prefab component. }}

  • public override void GetArchetypeComponents(HashSet<ComponentType> components)
    {{ Adds ComponentType.ReadWrite() to the provided set. This ensures the entity archetype used for this prefab includes a Placeholder component at creation time. }}

  • public override void Initialize(EntityManager entityManager, Entity entity)
    {{ Calls base.Initialize(entityManager, entity). Then checks if the underlying prefab object has a SpawnableLane component (base.prefab.Has()). If it does, logs a warning via ComponentBase.baseLog.WarnFormat with the prefab reference and name. This is a runtime check to help catch unexpected prefab configurations (a placeholder lane that is also spawnable). }}

Additional notes:
- The class is decorated with the ComponentMenu attribute: [ComponentMenu("Net/", new Type[] { typeof(NetLanePrefab) })], which places it in the "Net/" menu and associates it with NetLanePrefab in Unity's component/prefab menus.
- This class interacts with Unity.Entities (ECS), so it expects ComponentType, EntityManager, and Entity types to be available.

Usage Example

// This shows how PlaceholderLane contributes components via the prefab pipeline.
// Usually you don't instantiate this directly; it's used by the prefab system when
// converting a NetLanePrefab into ECS entities.

[ComponentMenu("Net/", new Type[] { typeof(NetLanePrefab) })]
public class MyCustomLanePrefab : PlaceholderLane
{
    // Optionally extend behavior by overriding Initialize
    public override void Initialize(EntityManager entityManager, Entity entity)
    {
        base.Initialize(entityManager, entity);

        // Example: perform additional setup of components on the created entity
        // if needed (pseudo-code):
        // if (!entityManager.HasComponent<MyMarker>(entity))
        //     entityManager.AddComponentData(entity, new MyMarker { ... });
    }
}

{{ When creating or inspecting lane prefabs for Cities: Skylines 2 modding, PlaceholderLane ensures placeholder ECS components are present and helps surface misconfigurations (e.g., placeholder lanes marked spawnable). }}