Game.Prefabs.VehicleSideEffects
Assembly:
Assembly-CSharp (typical for game code / mod DLLs)
Namespace:
Game.Prefabs
Type:
class
Base:
ComponentBase
Summary:
Prefab component that exposes configurable per-vehicle side-effect ranges for road wear, noise pollution and air pollution. The inspector fields are float2 ranges (min, max) and during prefab initialization the component writes a VehicleSideEffectData component to the entity with those ranges packed into float3s (min and max). The class is annotated with a ComponentMenu to appear under "Vehicles/" and associated with VehiclePrefab in the editor.
Fields
-
public Unity.Mathematics.float2 m_RoadWear
Default: new float2(0.5f, 1f)
Range (x = min, y = max) that represents how much road wear the vehicle causes. Values are copied into VehicleSideEffectData.m_Min.x and VehicleSideEffectData.m_Max.x during Initialize. -
public Unity.Mathematics.float2 m_NoisePollution
Default: new float2(0.5f, 1f)
Range (x = min, y = max) for noise pollution produced by the vehicle. Mapped to VehicleSideEffectData.m_Min.y and VehicleSideEffectData.m_Max.y. -
public Unity.Mathematics.float2 m_AirPollution
Default: new float2(0.5f, 1f)
Range (x = min, y = max) for air pollution produced by the vehicle. Mapped to VehicleSideEffectData.m_Min.z and VehicleSideEffectData.m_Max.z.
Properties
- This class does not declare any public properties.
Constructors
public VehicleSideEffects()
Default parameterless constructor (implicit). The inspector-exposed fields are initialized to their defaults shown above. No special construction logic beyond the default generated constructor.
Methods
-
public override void GetPrefabComponents(System.Collections.Generic.HashSet<Unity.Entities.ComponentType> components)
Adds the runtime component type required by this prefab to the provided set. Implementation adds ComponentType.ReadWrite(), ensuring the entity will have a VehicleSideEffectData component when the prefab is created. -
public override void GetArchetypeComponents(System.Collections.Generic.HashSet<Unity.Entities.ComponentType> components)
Empty override. No archetype components are forced by this prefab beyond those added in GetPrefabComponents. -
public override void Initialize(Unity.Entities.EntityManager entityManager, Unity.Entities.Entity entity)
Called when the prefab is initialized. Calls base.Initialize(...), constructs a VehicleSideEffectData struct and fills its m_Min and m_Max float3 members from the three float2 fields (road wear, noise pollution, air pollution). Finally writes the component data to the entity via entityManager.SetComponentData(entity, componentData).
Usage Example
// When a Vehicle prefab with this component is initialized, VehicleSideEffectData is written to the entity.
// Example of reading the data back from an EntityManager:
var sideEffectData = entityManager.GetComponentData<VehicleSideEffectData>(entity);
// sideEffectData.m_Min.x -> road wear min
// sideEffectData.m_Min.y -> noise pollution min
// sideEffectData.m_Min.z -> air pollution min
// sideEffectData.m_Max.x -> road wear max
// etc.
Additional notes:
- The class uses Unity.Mathematics types (float2, float3) and Unity.Entities (ECS) APIs.
- The ComponentMenu attribute ([ComponentMenu("Vehicles/", new Type[] { typeof(VehiclePrefab) })]) places this component under the Vehicles menu and associates it with VehiclePrefab in the editor.