Skip to content

Game.Prefabs.LaneBlock

Assembly:
Game (assembly inferred from file path)

Namespace:
Game.Prefabs

Type:
class

Base:
ComponentBase

Summary:
Marker/component class used on prefabs (StaticObjectPrefab and MarkerObjectPrefab) to ensure that entities produced from those prefabs include the BlockedLane ECS component in their archetype. It provides no prefab-time components itself (GetPrefabComponents is empty) but contributes the BlockedLane component to the runtime archetype via GetArchetypeComponents. This is typically used to mark lanes as blocked in game logic/systems.


Fields

  • None
    This class does not declare any instance or static fields.

Properties

  • None
    No properties are declared by this class.

Constructors

  • public LaneBlock()
    Default parameterless constructor (implicit). No custom construction logic is present.

Methods

  • public override void GetPrefabComponents(HashSet<ComponentType> components)
    Empty implementation. Intended to allow adding component types that belong to prefab instances, but currently this class does not add any prefab-level components.

  • public override void GetArchetypeComponents(HashSet<ComponentType> components)
    Adds ComponentType.ReadWrite<BlockedLane>() to the provided set. This ensures entities created from prefabs that include this LaneBlock component will have a BlockedLane component in their ECS archetype (read/write access).

Additional notes: - The class is decorated with a ComponentMenu attribute that associates it with Object prefabs and indicates it applies to StaticObjectPrefab and MarkerObjectPrefab types. This affects how the editor displays/attaches the component to prefabs. - BlockedLane is expected to be an ECS component (likely an IComponentData struct). Systems can query for entities with BlockedLane to handle lane-blocking behavior.

Usage Example

// LaneBlock already ensures the BlockedLane component is part of the prefab archetype.
// Example: querying entities that were created from a prefab that had LaneBlock attached.

public class BlockedLaneSystem : SystemBase
{
    protected override void OnUpdate()
    {
        // Example query: operate on all entities that have BlockedLane
        Entities
            .WithName("HandleBlockedLanes")
            .ForEach((ref BlockedLane blocked) =>
            {
                // process blocked lane marker here
            })
            .ScheduleParallel();
    }
}

// Alternatively, when creating an entity manually, add the component type similarly:
var entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
var archetype = entityManager.CreateArchetype(typeof(BlockedLane), /* other components */);
var entity = entityManager.CreateEntity(archetype);

{{ This class is a lightweight prefab helper: it doesn't contain runtime logic itself but alters the ECS archetype composition so other systems can detect and handle blocked lanes. If you want additional per-prefab initialization, implement GetPrefabComponents to add prefab-local component types or attach data components (e.g., default values) at prefab creation time. }}