Class WaterDataProvider
Base class for providing water surface data to WaterObjects. Implementations provide water height, flow velocity, and surface normal information. Uses a trigger collider to automatically detect and register WaterObjects that enter the water. Inherit from this class to create adapters for different water systems.
Inheritance
Namespace: NWH.DWP2.WaterData
Assembly: NWH.DWP2.dll
Syntax
public abstract class WaterDataProvider : MonoBehaviour
Fields
| Edit this page View Source_singleHeightArray
Declaration
protected float[] _singleHeightArray
Field Value
| Type | Description |
|---|---|
| float[] |
_singlePointArray
Declaration
protected Vector3[] _singlePointArray
Field Value
| Type | Description |
|---|---|
| Vector3[] |
_triggerCollider
Declaration
protected Collider _triggerCollider
Field Value
| Type | Description |
|---|---|
| Collider |
Methods
| Edit this page View SourceAwake()
Declaration
public virtual void Awake()
GetWaterFlows(WaterObject, ref Vector3[], ref Vector3[])
Returns water flow velocity at each given point. Override this method to provide water flow data from your water system. Flow should be in world space and relative to the world, not the WaterObject.
Declaration
public virtual void GetWaterFlows(WaterObject waterObject, ref Vector3[] points, ref Vector3[] waterFlows)
Parameters
| Type | Name | Description |
|---|---|---|
| WaterObject | waterObject | WaterObject requesting the data. |
| Vector3[] | points | Position array in world coordinates. |
| Vector3[] | waterFlows | Water flow velocity array in world coordinates. Corresponds to positions. |
GetWaterHeight(WaterObject, Vector3)
Returns water height at the given world position.
Declaration
public float GetWaterHeight(WaterObject waterObject, Vector3 worldPoint)
Parameters
| Type | Name | Description |
|---|---|---|
| WaterObject | waterObject | WaterObject making the query. |
| Vector3 | worldPoint | Position in world coordinates. |
Returns
| Type | Description |
|---|---|
| float | Water surface height at the given point. |
GetWaterHeightSingle(WaterObject, Vector3)
Returns water height at a single point. Less efficient than batch queries but useful for one-off checks.
Declaration
public virtual float GetWaterHeightSingle(WaterObject waterObject, Vector3 point)
Parameters
| Type | Name | Description |
|---|---|---|
| WaterObject | waterObject | WaterObject requesting the data. |
| Vector3 | point | Position in world coordinates. |
Returns
| Type | Description |
|---|---|
| float | Water height at the given point. |
GetWaterHeights(WaterObject, ref Vector3[], ref float[])
Returns water height at each given point. Override this method to provide water height data from your water system.
Declaration
public virtual void GetWaterHeights(WaterObject waterObject, ref Vector3[] points, ref float[] waterHeights)
Parameters
| Type | Name | Description |
|---|---|---|
| WaterObject | waterObject | WaterObject requesting the data. |
| Vector3[] | points | Position array in world coordinates. |
| float[] | waterHeights | Water height array in world coordinates. Corresponds to positions. |
GetWaterHeightsFlowsNormals(WaterObject, ref Vector3[], ref float[], ref Vector3[], ref Vector3[], bool, bool, bool)
Queries water data based on enabled flags. Calls the appropriate getter methods based on which data types are requested.
Declaration
public void GetWaterHeightsFlowsNormals(WaterObject waterObject, ref Vector3[] points, ref float[] waterHeights, ref Vector3[] waterFlows, ref Vector3[] waterNormals, bool useWaterHeight, bool useWaterNormals, bool useWaterFlow)
Parameters
| Type | Name | Description |
|---|---|---|
| WaterObject | waterObject | WaterObject requesting the data. |
| Vector3[] | points | Position array in world coordinates. |
| float[] | waterHeights | Output water heights array. |
| Vector3[] | waterFlows | Output water flows array. |
| Vector3[] | waterNormals | Output water normals array. |
| bool | useWaterHeight | Should water heights be queried. |
| bool | useWaterNormals | Should water normals be queried. |
| bool | useWaterFlow | Should water flows be queried. |
GetWaterNormals(WaterObject, ref Vector3[], ref Vector3[])
Returns water surface normals at each given point. Override this method to provide water normal data from your water system.
Declaration
public virtual void GetWaterNormals(WaterObject waterObject, ref Vector3[] points, ref Vector3[] waterNormals)
Parameters
| Type | Name | Description |
|---|---|---|
| WaterObject | waterObject | WaterObject requesting the data. |
| Vector3[] | points | Position array in world coordinates. |
| Vector3[] | waterNormals | Water surface normal array in world coordinates. Corresponds to positions. |
PointInWater(WaterObject, Vector3)
Checks if a point is underwater. Accounts for wave height when water normals are supported.
Declaration
public bool PointInWater(WaterObject waterObject, Vector3 worldPoint)
Parameters
| Type | Name | Description |
|---|---|---|
| WaterObject | waterObject | WaterObject making the query. |
| Vector3 | worldPoint | Position to check in world coordinates. |
Returns
| Type | Description |
|---|---|
| bool | True if the point is below the water surface. |
SupportsWaterFlowQueries()
Does this water system support water velocity queries?
Declaration
public abstract bool SupportsWaterFlowQueries()
Returns
| Type | Description |
|---|---|
| bool | True if it does, false if it does not. |
SupportsWaterHeightQueries()
Does this water system support water height queries?
Declaration
public abstract bool SupportsWaterHeightQueries()
Returns
| Type | Description |
|---|---|
| bool | True if it does, false if it does not. |
SupportsWaterNormalQueries()
Does this water system support water normal queries?
Declaration
public abstract bool SupportsWaterNormalQueries()
Returns
| Type | Description |
|---|---|
| bool | True if it does, false if it does not. |