Game.Prefabs.TrackLane
Assembly: Assembly-CSharp
Namespace: Game.Prefabs
Type: public class
Base: ComponentBase
Summary:
Represents a prefab component for rail-style lanes (tracks) used by trains/trams in the game. Exposes references to a fallback lane prefab and an end object, along with configuration values such as track type, width, curviness and whether the lane is two-way. It also contributes required ECS component types to the prefab's archetype so the runtime entities for the lane get the right data components and systems can operate on them. The class is decorated with a ComponentMenu attribute to make it available under the "Net/" menu in prefab/component editors and associates it with NetLanePrefab in the editor UI.
Fields
-
public NetLanePrefab m_FallbackLane
Reference to an alternative NetLanePrefab to use as a fallback. Included as a dependency when building the prefab. -
public ObjectPrefab m_EndObject
Reference to an object prefab to place at the end of the lane (for visuals/objects). Included as a dependency when building the prefab. -
public TrackTypes m_TrackType
Enum specifying the track type (default: Train). Determines classification of the lane (e.g., train, tram). -
public float m_Width
Lane width in world units (default: 4f). Controls lane spacing/placement. -
public float m_MaxCurviness
Maximum allowed curviness for the track (default: 1.8f). Used by placement/geometry code to constrain curvature. -
public bool m_Twoway
Whether the lane supports two-way traffic.
Properties
- None. (The class exposes only public fields and overrides; there are no C# properties declared in the source.)
Constructors
public TrackLane()
Implicit default constructor. The class relies on field initializers for default values (e.g., m_TrackType = TrackTypes.Train, m_Width = 4f, m_MaxCurviness = 1.8f).
Methods
-
public override void GetDependencies(List<PrefabBase> prefabs)
Adds any referenced prefabs to the provided dependency list so dependent assets are loaded/packaged. Specifically, if m_FallbackLane or m_EndObject are set, they are appended to prefabs. Calls base.GetDependencies(prefabs) first. -
public override void GetPrefabComponents(HashSet<ComponentType> components)
Adds the prefab-level component types that should be present for this TrackLane. This implementation adds TrackLaneData (read/write), which is the data component stored on the prefab/entity for this lane. -
public override void GetArchetypeComponents(HashSet<ComponentType> components)
Adds runtime ECS component types required for lane entities. It always adds Game.Net.TrackLane (read/write). If MasterLane is not already present on the component set, it additionally adds LaneObject, LaneReservation, LaneColor, LaneOverlap and UpdateFrame (all read/write). This ensures the lane's runtime archetype contains the standard lane runtime components unless the prefab is being composed as part of a master lane variant.
Additional notes: - The class is annotated with [ComponentMenu("Net/", new Type[] { typeof(NetLanePrefab) })], which places it in the editor component menu and ties editor tooling to NetLanePrefab. - Types referenced by the methods/components (TrackLaneData, Game.Net.TrackLane, MasterLane, LaneObject, LaneReservation, LaneColor, LaneOverlap, UpdateFrame) are ECS component types used by the game's simulation systems.
Usage Example
// Create/configure a TrackLane instance (e.g., from code when building prefabs)
var trackLane = new TrackLane
{
m_FallbackLane = someNetLanePrefab,
m_EndObject = someEndObjectPrefab,
m_TrackType = TrackTypes.Tram,
m_Width = 3.5f,
m_MaxCurviness = 2.0f,
m_Twoway = true
};
// When the prefab system queries dependencies and components, TrackLane overrides ensure:
// - referenced prefabs are added to dependency lists
// - TrackLaneData is added to prefab components
// - runtime archetype receives Game.Net.TrackLane and other lane runtime components