Game.Prefabs.SoilWaterParameterData
Assembly: Assembly-CSharp
Namespace: Game.Prefabs
Type: struct
Base: System.ValueType
Summary:
SoilWaterParameterData is an ECS component (IComponentData) used to configure per‑prefab parameters that control soil/terrain water behaviour in the game's hydrology simulation. It exposes several tunable float fields that influence how rain adds water, how water diffuses across height differences, maximum storage and overflow behaviour, and how moist the soil remains when submerged. This struct also implements IQueryTypeParameter to be usable in specific query contexts within Unity.Entities.
Fields
-
public float m_RainMultiplier
Scales the amount of water added by rainfall. Higher values increase how much water accumulates from rain events. -
public float m_HeightEffect
Controls how height differences influence water movement/diffusion. Larger values make elevation changes have a stronger effect on redistribution. -
public float m_MaxDiffusion
Maximum diffusion rate (per update) allowed when water spreads between neighboring cells. Limits how quickly water equalizes. -
public float m_WaterPerUnit
Amount of water represented by a single "unit" in the simulation (used to convert between internal units and displayed/physical units). -
public float m_MoistureUnderWater
Base moisture level to apply when a cell is fully underwater (a floor value for moisture under submerged conditions). -
public float m_MaximumWaterDepth
Cap on stored water depth for the cell. Water accumulation beyond this value will be subject to overflow behaviour. -
public float m_OverflowRate
Rate at which excess water is transferred out of a cell when it exceeds m_MaximumWaterDepth. Higher values cause faster overflow.
Properties
- This type does not declare any properties. It is a plain data struct with public fields.
Constructors
public SoilWaterParameterData()
Struct has the default parameterless constructor. All fields default to 0.0f — you should initialize fields explicitly before use to avoid unintended behaviour.
Methods
- This type defines no methods. It is a pure data container used by systems that implement the hydrology/water simulation.
Usage Example
using Unity.Entities;
using Game.Prefabs;
// create and initialize the soil water parameters
var soilParams = new SoilWaterParameterData
{
m_RainMultiplier = 1.0f,
m_HeightEffect = 0.5f,
m_MaxDiffusion = 0.1f,
m_WaterPerUnit = 0.02f,
m_MoistureUnderWater = 0.9f,
m_MaximumWaterDepth = 2.0f,
m_OverflowRate = 0.3f
};
// add to an entity (e.g., a terrain-prefab entity)
EntityManager entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
entityManager.AddComponentData(someTerrainEntity, soilParams);
Additional notes: - Because this is an IComponentData used by ECS systems, prefer initializing it when creating the prefab/entity rather than mutating frequently on the main thread. - Tuning these values affects game balance and visual behaviour of flooding — test changes incrementally and in combination with neighbor-cell/grid size and simulation timestep.