Skip to content

Game.SurfaceWater

Assembly:
Assembly information not available (likely part of the main game assembly)

Namespace: Game.Simulation

Type: struct

Base: System.ValueType

Summary:
SurfaceWater is a plain data container used by the simulation to represent the state of surface (above-ground) water for a cell or simulation element. It stores the water depth, pollution amount, and a 2D velocity vector. The struct is blittable (floats and float2), compact (16 bytes) and suitable for use in NativeArray/NativeSlice and Unity Jobs.


Fields

  • public System.Single m_Depth
    Represents the water depth at this simulation point. Units are game-specific (typically meters in many simulations). Use small positive values for shallow water; zero means no surface water.

  • public System.Single m_Polluted
    Represents the pollution concentration or pollution amount in the surface water. The exact range/units are game-specific; commonly treated as a normalized concentration or an amount that can be accumulated and transported.

  • public Unity.Mathematics.float2 m_Velocity
    A 2D velocity vector describing the surface water flow direction and magnitude across the simulation plane (X, Y). Uses Unity.Mathematics.float2 for efficient math and job compatibility.

Properties

  • This type exposes no properties.

Constructors

  • public SurfaceWater()
    No explicit constructors are defined in code; the default (parameterless) constructor initializes floats to 0.0 and float2 to (0,0).

Methods

  • This type declares no methods.

Usage Example

using Unity.Mathematics;
using Game.Simulation;

// Create and initialize a SurfaceWater value
SurfaceWater sw = new SurfaceWater();
sw.m_Depth = 0.25f;                     // 25 cm of water
sw.m_Polluted = 0.1f;                   // small pollution amount
sw.m_Velocity = new float2(1.0f, 0.0f); // flow along +X

// Typical use in arrays / jobs:
NativeArray<SurfaceWater> waterArray = new NativeArray<SurfaceWater>(cellCount, Allocator.Persistent);
// initialize or update entries...
// Use in IJobParallelFor, etc., since the struct is blittable.

Additional notes: - Memory layout: 4 bytes (m_Depth) + 4 bytes (m_Polluted) + 8 bytes (m_Velocity) = 16 bytes total. - Because it's a simple POD struct, prefer using NativeArray/NativeSlice and Unity Jobs for high-performance simulation updates. - The exact semantics (units, expected ranges, clamping behavior) of m_Depth and m_Polluted are determined by the consuming simulation code — clamp or validate values as needed when writing mod code.