Skip to content

Game.Prefabs.RoadComposition

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

Type: struct

Base: Implements Unity.Entities.IComponentData, Unity.Entities.IQueryTypeParameter

Summary:
RoadComposition is an ECS component data struct used to describe a road prefab's composition and runtime parameters. It holds a reference to a related zone-block prefab, numeric parameters such as a speed limit and a priority value, and a set of flags that control road behavior. This component is intended to be attached to entities that represent road prefabs within the game's entity-component system.


Fields

  • public Unity.Entities.Entity m_ZoneBlockPrefab
    Reference to an Entity that is the zone-block prefab associated with this road composition. Typically used to spawn or link the block/piece that defines zoning behavior adjacent to this road.

  • public float m_SpeedLimit
    Numeric speed limit associated with the road composition. Unit and interpretation follow the game's conventions (e.g., game speed units or km/h depending on other systems). Used by systems that evaluate traffic speed, pathfinding, or simulation rules.

  • public float m_Priority
    A priority or weight value used by road selection, placement, or simulation systems. Higher values can indicate preferred compositions when multiple options are available. Exact semantics depend on consuming systems.

  • public RoadFlags m_Flags
    Bitwise flags (enum defined elsewhere) controlling optional behaviors and characteristics of the road composition (for example: enable/disable lanes, special rendering or traffic rules). See the RoadFlags definition for exact flag meanings.

Properties

  • This struct does not define any C# properties. It exposes only public fields and implements IComponentData / IQueryTypeParameter so it can be used directly by the Entities API.

Constructors

  • No explicit constructors are defined. The struct uses the default parameterless constructor; initialize fields via an object initializer when creating instances.

Methods

  • This type declares no methods. It is a plain data container (component) used by ECS systems.

Usage Example

// Example: create and add RoadComposition to an entity
var roadEntity = entityManager.CreateEntity();

var roadComp = new RoadComposition {
    m_ZoneBlockPrefab = zoneBlockPrefabEntity, // previously obtained prefab entity
    m_SpeedLimit = 50f,
    m_Priority = 1.0f,
    m_Flags = RoadFlags.None // or other flags defined in RoadFlags
};

entityManager.AddComponentData(roadEntity, roadComp);

// Example: query and read RoadComposition in a system (Entities.ForEach or EntityManager)
Entities.WithAll<RoadComposition>().ForEach((ref RoadComposition comp) =>
{
    float limit = comp.m_SpeedLimit;
    // ... use comp in simulation logic ...
}).Schedule();