namespace Zinnia.Rule
{
using UnityEngine;
using UnityEngine.AI;
///
/// Determines whether a given point is within the .
///
public class NavMeshRule : Vector3Rule
{
[Tooltip("The relative vertical displacement of the NavMesh to the nearest surface.")]
[SerializeField]
private float baseOffset = 0f;
///
/// The relative vertical displacement of the to the nearest surface.
///
public float BaseOffset
{
get
{
return baseOffset;
}
set
{
baseOffset = value;
}
}
[Tooltip("The max distance given point can be outside the NavMesh to be considered valid.")]
[SerializeField]
private float distanceLimit = 0.1f;
///
/// The max distance given point can be outside the to be considered valid.
///
public float DistanceLimit
{
get
{
return distanceLimit;
}
set
{
distanceLimit = value;
}
}
[Tooltip("The parts of the NavMesh that are considered valid.")]
[SerializeField]
private int validAreas = -1;
///
/// The parts of the that are considered valid.
///
public int ValidAreas
{
get
{
return validAreas;
}
set
{
validAreas = value;
}
}
///
protected override bool Accepts(Vector3 targetVector3)
{
return NavMesh.SamplePosition(targetVector3 + (Vector3.up * BaseOffset), out NavMeshHit hit, DistanceLimit, ValidAreas);
}
}
}