Skip to main content

LocalWindManager

A class in Root.Township, Alta.Environmental.Vegetation.

Non-networked copy of GrassManager: same wind and cloud shader updates, no syncing. Destroys itself on a headless server.

Constructors​

MemberWhat it is
LocalWindManager()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

17 private and internal fields
MemberWhat it is
private List<WindPattern> availablePatternsBacking field for AvailablePatterns.
private float cloudsRotationCloud rotation as a fraction of a turn, wrapping at 1.
private float cloudsSpeedMultiplierScales how fast clouds turn with the wind.
private float directionChangeLerpSpeedLerp amount per frame when turning; 1 snaps at once.
private bool isLerpingDirectionTrue while turning toward newDirection.
private float maxValueToLerpCopied from GrassManager; not read here.
private float networkCloudRotationCopied from GrassManager; not read here.
private Vector2 newDirectionDirection being turned toward.
private Vector2 windDirectionBacking field for WindDirection.
private Texture2D windMapWind noise texture given to shaders as _WindMap.
private Vector2 windMapOffsetCurrent scroll offset of the wind map.
private Vector2 windMapOffsetNetworkCopied from GrassManager; not read here.
private float windMapScaleWorld size of one wind map tile; shaders get its inverse.
private float windSpeedBacking field for WindSpeed.
private float windStrengthBacking field for WindStrength.
private float worldPositionSerialized world origin. Not read in this build.
private float worldSizeWorld size used to turn wind movement into cloud rotation.

Properties​

MemberWhat it is
List<WindPattern> AvailablePatterns { get; }Wind patterns that can be applied with ReadPattern.
Vector2 WindDirection { get; set; }Wind direction on the ground plane. Setting it updates the shader off headless.
float WindSpeed { get; }How fast the wind map scrolls.
float WindStrength { get; }How strongly grass bends.

Methods​

MemberWhat it is
void ReadPattern(WindPattern pattern)Applies a pattern's speed and strength (not direction).
8 private and internal methods
MemberWhat it is
private void Awake()On headless, drops the wind map and destroys itself; otherwise sets the global wind map shader values.
private void ChangeWindDirection(Vector2 direction)Starts turning toward a new (normalized) direction.
private void ChangeWindSpeed(float speed)Sets the wind speed, not below 0.
private void ChangeWindStrength(float strength)Sets the wind strength, not below 0, and updates the shader.
private void OnValidate()Editor: normalizes the direction and updates the shader.
private void Update()Lerps the direction, scrolls the wind map and cloud rotation by speed, and updates shaders.
private void UpdateShader()Sets the global cloud rotation values from cloudsRotation, then the wind parameters.
private void UpdateWindParameters()Sets the global _WindParameters: wind map offset and direction times strength.