Game.PollutionModifierData
Assembly:
{{ Inferred from file path: Game (actual assembly name depends on the project's compilation/assembly definition). }}
Namespace: Game.Prefabs
Type:
public struct PollutionModifierData
Base:
Implements: Unity.Entities.IComponentData, Unity.Entities.IQueryTypeParameter, ICombineData
{{ This is an ECS component (value type) intended to be attached to entities. It implements ICombineData
Summary:
{{ Represents multiplicative modifiers for different pollution channels (ground, air and noise). Each field is treated as a multiplier applied to the corresponding pollution type. The struct is designed to be combined with other PollutionModifierData instances via the Combine method (adds the multipliers). Because this is a plain struct (IComponentData), it will default to 0.0 for floats unless explicitly initialized — if you want a neutral multiplier use 1.0. }}
Fields
-
public float m_GroundPollutionMultiplier
{{ Multiplier applied to ground pollution. Typical usage: scale ground pollution emitted or applied by an entity. Default struct value is 0.0 if not initialized; initialize to 1.0 for a neutral (no change) effect. }} -
public float m_AirPollutionMultiplier
{{ Multiplier applied to air pollution. Same conventions and notes as m_GroundPollutionMultiplier. }} -
public float m_NoisePollutionMultiplier
{{ Multiplier applied to noise pollution. Same conventions and notes as m_GroundPollutionMultiplier. }}
Properties
- None.
{{ This component exposes only public fields and does not declare any properties. It is used as an IComponentData marker/holder for modifier values and as a combinable data type via ICombineData. }}
Constructors
public PollutionModifierData()
{{ Implicit default parameterless constructor provided by C# for structs. It initializes all float fields to 0.0. If you need a neutral modifier, construct with values set to 1.0 (see usage example). You may also create a convenience constructor yourself if desired. }}
Methods
public void Combine(PollutionModifierData otherData)
{{ Adds the otherData multipliers into this instance. This is an in-place, additive combine: m_GroundPollutionMultiplier += otherData.m_GroundPollutionMultiplier, etc. Intended for use by combine/aggregation systems that merge multiple modifier instances. Note: the semantics are additive, so ensure calling code expects sum-of-modifiers behavior. Thread-safety: method mutates the instance and should be used accordingly (e.g., on a single thread or within appropriate ECS job/synchronization). }}
Usage Example
// Create two modifier instances and combine them
var baseModifier = new PollutionModifierData
{
m_GroundPollutionMultiplier = 1.0f, // neutral
m_AirPollutionMultiplier = 1.0f,
m_NoisePollutionMultiplier = 1.0f
};
var upgradeModifier = new PollutionModifierData
{
m_GroundPollutionMultiplier = -0.2f, // reduce ground pollution by 0.2 (interpretation depends on system)
m_AirPollutionMultiplier = 0.1f,
m_NoisePollutionMultiplier = 0.0f
};
// Combine upgrade into base (in-place)
baseModifier.Combine(upgradeModifier);
// baseModifier now contains the summed multipliers
{{ Notes: Interpret how multipliers are applied in the consuming code — additive combine semantics here mean the final multiplier is the sum of contributions. When integrating with game systems, ensure initialization values and interpretation (e.g., additive offsets vs multiplicative factors) match the system's expectations. }}