Game.Prefabs.CarLane
Assembly: Assembly-CSharp
Namespace: Game.Prefabs
Type: class
Base: ComponentBase
Summary:
Represents a lane prefab used for car traffic on road prefabs. This prefab exposes configuration for lane characteristics (width, allowed vehicle types, direction, bus/track exceptions and size class) and contributes required ECS component types when the prefab is converted to an entity archetype. The class also reports prefab dependencies for referenced alternate lane prefabs.
Fields
-
public NetLanePrefab m_NotTrackLane
Reference to an alternate NetLanePrefab used when the lane should not be a track lane (used as a dependency reference). Can be null. Added to prefab dependencies if set. -
public NetLanePrefab m_NotBusLane
Reference to an alternate NetLanePrefab used when the lane should not be a bus lane (used as a dependency reference). Can be null. Added to prefab dependencies if set. -
public RoadTypes m_RoadType = RoadTypes.Car
Enumerates the road/vehicle type this lane is intended for (default: Car). Controls lane behavior and vehicle filtering. -
public SizeClass m_MaxSize = SizeClass.Large
Maximum vehicle size class allowed on this lane (default: Large). -
public float m_Width = 3f
Lane width in world units (default: 3.0). Used when building the lane geometry and for spacing calculations. -
public bool m_StartingLane
If true, marks this lane as a starting lane (e.g., for spawning or lane graph entry logic). -
public bool m_EndingLane
If true, marks this lane as an ending lane (e.g., for despawning or lane graph exit logic). -
public bool m_Twoway
If true, indicates the lane supports two-way traffic. Affects routing / flow direction. -
public bool m_BusLane
If true, marks the lane as a bus-only or bus-priority lane (affects allowed vehicles and logic).
Properties
- (No public properties declared in this class.)
All lane configuration is exposed via public fields. The class adds ECS component types via GetPrefabComponents/GetArchetypeComponents rather than exposing runtime properties.
Constructors
public CarLane()
Default parameterless constructor is provided by the compiler. No custom initialization logic is defined in the class; default field values are those declared inline (see m_RoadType, m_MaxSize, m_Width).
Methods
-
public override void GetDependencies(List<PrefabBase> prefabs)
Adds referenced alternate lane prefabs to the provided prefabs list. If m_NotTrackLane or m_NotBusLane are not null, they are appended to the dependencies list. Callers (prefab system) use this to ensure referenced prefabs are included/loaded. -
public override void GetPrefabComponents(HashSet<ComponentType> components)
Adds the component type CarLaneData (ReadWrite) to the given set. This declares that an entity created from this prefab will include CarLaneData. -
public override void GetArchetypeComponents(HashSet<ComponentType> components)
Adds the component type Game.Net.CarLane (ReadWrite). Additionally, if the master lane component (MasterLane) is not already present in the set, it adds these lane-related component types (ReadWrite): LaneObject, LaneReservation, LaneFlow, LaneOverlap, and UpdateFrame. This method defines the full set of ECS components required on lane entities created from this prefab.
Usage Example
// Typical usage is via the prefab/inspector in the editor.
// Example: referencing alternate lane prefabs and setting basic properties.
public class MyRoadPrefabSetup
{
void ConfigureCarLane(CarLane lane)
{
lane.m_Width = 3.5f;
lane.m_BusLane = true;
lane.m_Twoway = false;
// Assign alternate prefabs in editor or via code:
// lane.m_NotTrackLane = someNetLanePrefab;
// lane.m_NotBusLane = anotherNetLanePrefab;
}
}
Notes: - The ComponentMenu attribute on the class places this prefab type under the Net menu in the editor (ComponentMenu("Net/", typeof(NetLanePrefab))). - Conversion to ECS entities and usage/runtime behavior depend on the Game's prefab->entity conversion pipeline which consumes the component sets returned by GetPrefabComponents/GetArchetypeComponents.