Game.Prefabs.LaneDeterioration
Assembly: Assembly-CSharp
Namespace: Game.Prefabs
Type: class
Base: ComponentBase
Summary:
Component used by net lane prefabs to supply lane deterioration configuration to the ECS world. When the prefab is converted to an entity this component adds a LaneDeteriorationData component (carrying traffic/time deterioration factors). If the prefab archetype does not include a MasterLane component, this component also requests a LaneCondition component be added to the archetype. The inspector-exposed fields control configurable deterioration factors that are written into the LaneDeteriorationData during Initialize.
This component is registered in the component menu via the attribute: [ComponentMenu("Net/", new Type[] { typeof(NetLanePrefab) })]
Fields
-
public float m_TrafficDeterioration = 0.01f
Controls the traffic-related deterioration factor. This value is copied to LaneDeteriorationData.m_TrafficFactor during Initialize. -
public float m_TimeDeterioration = 0.5f
Controls the time-related deterioration factor. This value is copied to LaneDeteriorationData.m_TimeFactor during Initialize.
Properties
- None (the class exposes public fields; there are no CLR properties defined).
Constructors
public LaneDeterioration()
Default parameterless constructor (inherited behavior). The public fields have their default values as declared.
Methods
-
public override void GetPrefabComponents(HashSet<ComponentType> components)
Adds the runtime ECS component type required for deterioration data: components.Add(ComponentType.ReadWrite()); Used when converting the prefab to an entity to ensure LaneDeteriorationData is present. -
public override void GetArchetypeComponents(HashSet<ComponentType> components)
If the archetype being built does not already contain MasterLane, this method requests that LaneCondition be added to the archetype: if (!components.Contains(ComponentType.ReadWrite())) { components.Add(ComponentType.ReadWrite ()); } This ensures lane condition data exists for lanes that are not part of a master lane grouping. -
public override void Initialize(EntityManager entityManager, Entity entity)
Called during prefab-to-entity initialization. It: - Calls base.Initialize(entityManager, entity)
- Constructs a LaneDeteriorationData instance and sets:
- m_TrafficFactor = m_TrafficDeterioration
- m_TimeFactor = m_TimeDeterioration
- Writes the component data to the entity via entityManager.SetComponentData(entity, componentData)
Usage Example
// Example: setting values on the prefab component (e.g. in the editor or via script)
// When the prefab is converted to an entity, Initialize will copy these into the ECS component.
var laneDet = gameObject.AddComponent<Game.Prefabs.LaneDeterioration>();
laneDet.m_TrafficDeterioration = 0.02f;
laneDet.m_TimeDeterioration = 0.6f;
// After prefab conversion:
// entity will have LaneDeteriorationData with m_TrafficFactor = 0.02f and m_TimeFactor = 0.6f
Related types: LaneDeteriorationData (m_TrafficFactor, m_TimeFactor), LaneCondition, MasterLane, NetLanePrefab.