Skip to content

Game.Prefabs.WaterLevelChangeType

Assembly: Game
Namespace: Game.Prefabs

Type: public enum
Base: System.Enum (underlying type: System.Byte)

Summary:
Serializable enumeration that indicates how a prefab's water level should change over time. Used by water-related prefabs (for example ponds, reservoirs, canals, or environment features) to determine whether the water remains static, oscillates in a sine-wave pattern, or is driven by the game's rainfall/precipitation system. The enum is explicitly backed by a byte to ensure compact storage and predictable binary serialization for game saves and network/mod interoperability.


Fields

  • None
    Defines no automatic change to the water level; the water stays at its configured/static height unless changed explicitly by code or the user.

  • Sine
    The water level oscillates over time using a sine wave. Useful for decorative or gentle wave motions where a repeating, smooth up-and-down movement is desired.

  • RainControlled
    The water level is controlled by the game's rainfall/precipitation simulation. When selected, water elevation changes will follow rain intensity or other weather-driven inputs provided by the environment/weather systems.

Properties

  • This enum does not declare any properties. It is a simple value type with named constants representing behavior modes.

Constructors

  • Enums do not have user-defined constructors. Instances are created by assigning one of the named constants (e.g., WaterLevelChangeType.Sine). The underlying value is stored as a byte.

Methods

  • The enum itself declares no methods. Standard System.Enum methods (ToString, HasFlag, GetValues, etc.) and implicit conversions (to/from the underlying byte when cast) apply.

  • Notes for modders:

  • When serializing to binary formats or interop layers, cast to/from byte explicitly (e.g., (byte)myValue) to match the declared underlying type.
  • When reading/writing legacy save formats or networked data, ensure the expected byte values align with these enum members (None = 0, Sine = 1, RainControlled = 2).

Usage Example

using Game.Prefabs;

public class WaterBehaviorController
{
    public WaterLevelChangeType changeType;

    public void ApplyWaterChange(float time, ref float waterHeight)
    {
        switch (changeType)
        {
            case WaterLevelChangeType.None:
                // keep waterHeight unchanged
                break;

            case WaterLevelChangeType.Sine:
                // example: small sinusoidal oscillation around a base height
                float baseHeight = 10f;
                float amplitude = 0.5f;
                float frequency = 1f; // cycles per second
                waterHeight = baseHeight + amplitude * (float)System.Math.Sin(2 * System.Math.PI * frequency * time);
                break;

            case WaterLevelChangeType.RainControlled:
                // query some hypothetical weather system for rain intensity
                float rainIntensity = WeatherSystem.GetRainIntensity(); // 0..1
                float minHeight = 9f;
                float maxHeight = 12f;
                waterHeight = Mathf.Lerp(minHeight, maxHeight, rainIntensity);
                break;
        }
    }
}

Additional notes: - The enum is marked [Serializable], which makes it suitable for Unity/Unity-like serialization systems used by the game. - Changing enum order or inserting new values in the middle can break existing save compatibility; prefer appending new values and handling unknown values gracefully.