Skip to main content

RiverNode

A class in Root.Township, Alta.Forests.

A point in the forest's river network. Water volume flows down its outgoing path, and its width comes from the volume. Used while generating rivers and their edge decorations.

Constructors​

MemberWhat it is
RiverNode(int index, Space space, Vector2 position, float height, float volume)Creates a RiverNode from index, space, position, height and volume.

Fields​

4 private and internal fields
MemberWhat it is
private bool isBelowThresholdSet by CacheVolume when the volume is under the river's overground threshold, which makes the node underground.
private bool isVolumeCachedWhether CacheVolume has run. Note it's never set to true, so every call recomputes.
private float volumeCacheNode volume including all upstream flow, capped at the river's max volume. Set by CacheVolume.
private float widthBacking field for Width, worked out from the volume in CacheVolume.

Properties​

MemberWhat it is
RiverNode Catchment { get; private set; }The last node downstream, where this node's water ends up. Set by EvaluateCatchment.
List<RiverNode> FlowedElsewhere { get; }Nodes whose water was sent elsewhere.
float GroundAttachment { get; set; }Ground attachment value for the node.
IEnumerable<RiverPath> Incoming { get; }Paths flowing into this node.
bool IsTooSmall { get; set; }Set when the river here is too small to keep.
bool IsUnderground { get; }True if the volume is below the overground threshold or the node is too small.
RiverPath Outgoing { get; }The path flowing out of this node, or null.
float Radius { get; }Half the width.
float SelfVolume { get; set; }Water this node adds on its own.
Space Space { get; }The forest space the node lies in.
float StaticVolumeMultiplier { get; set; }Multiplier on the cached volume. Default 1.
float Volume { get; }Cached volume times StaticVolumeMultiplier.
float Width { get; }River width here, from the volume. Set by CacheVolume.

Methods​

MemberWhat it is
float CacheVolume(RiverGeneration river, bool isRecache = false)Works out and caches the volume (its own plus everything flowing in, capped), the width, and whether it is too small to show above ground.
void EvaluateAdjacent()Links each above-ground path at this node to its clockwise and anticlockwise neighbours, with angles.
void EvaluateCatchment()Follows outgoing paths to the end and stores it as Catchment.
static void EvaluateEdgeInformation(float decorationMultiplier, List<IRiverDecorationSegment> decorations, RiverPath finalOutgoing)Walks around the river's outline from a final outgoing path and adds line and arc decoration segments along the banks.
static void EvaluateSegmentInformation(List<IRiverDecorationSegment> segments, RiverNode node, float offset = 0)Adds a line segment for every path upstream of a node, recursively.
1 private and internal method
MemberWhat it is
private static Vector2 EvaluateEdgeInformation(float decorationMultiplier, List<IRiverDecorationSegment> decorations, RiverNode nodeA, RiverNode nodeB, RiverNode nodeC, Vector2 nodeAB, Vector2 nodeBC, Vector2 leftPoint, ref float totalLength, ref float totalAngle, bool isWaterfall, bool isCurveWaterfall, float height)Walks around the river's outline from a final outgoing path and adds line and arc decoration segments along the banks.

Used in​

Members of other types that take, return or hold a RiverNode: