Code/Network/WaterNode.cs

Represents a node in the water graph (river source, bend, confluence or mouth). Stores an Id, a network-local Position, an AutoTangents flag and a CornerRadius property for rounded banks.

using Sandbox;

namespace RedSnail.WaterTool2;

/// <summary>
/// A point of the water graph: a river's source or end, a bend where a river passes through, a confluence once three
/// or more rivers meet there, or the mouth where a river opens into a lake. Positions are in network-local space, and
/// a node's height is the height of the water surface there.
/// </summary>
public sealed class WaterNode
{
	public int Id { get; set; }

	public Vector3 Position { get; set; }

	/// <summary>
	/// While set, the network keeps the tangent handles of every river at this node in sync with its neighbours:
	/// smooth through a bend, straight at a river end and into a confluence. Cleared once the handles are placed by
	/// hand.
	/// </summary>
	public bool AutoTangents { get; set; } = true;

	/// <summary>
	/// Radius of the rounded banks where rivers meet at this node. 0 gives sharp corners.
	/// </summary>
	[Range(0.0f, 2000.0f)] public float CornerRadius { get; set { field = value.Clamp(0.0f, 100000.0f); } } = 150.0f;
}