#if MODULE_ENTITIES
using Pathfinding.RVO;
using Unity.Entities;
using UnityEngine;
using Unity.Transforms;
using Unity.Mathematics;
namespace Pathfinding.ECS.RVO {
using Pathfinding.RVO;
///
/// Agent data for the local avoidance system.
///
/// See: local-avoidance (view in online documentation for working links)
///
[System.Serializable]
public struct RVOAgent : IComponentData {
/// How far into the future to look for collisions with other agents (in seconds)
[Tooltip("How far into the future to look for collisions with other agents (in seconds)")]
public float agentTimeHorizon;
/// How far into the future to look for collisions with obstacles (in seconds)
[Tooltip("How far into the future to look for collisions with obstacles (in seconds)")]
public float obstacleTimeHorizon;
///
/// Max number of other agents to take into account.
/// A smaller value can reduce CPU load, a higher value can lead to better local avoidance quality.
///
[Tooltip("Max number of other agents to take into account.\n" +
"A smaller value can reduce CPU load, a higher value can lead to better local avoidance quality.")]
public int maxNeighbours;
///
/// Specifies the avoidance layer for this agent.
/// The mask on other agents will determine if they will avoid this agent.
///
public RVOLayer layer;
///
/// Layer mask specifying which layers this agent will avoid.
/// You can set it as CollidesWith = RVOLayer.DefaultAgent | RVOLayer.Layer3 | RVOLayer.Layer6 ...
///
/// This can be very useful in games which have multiple teams of some sort. For example you usually
/// want the agents in one team to avoid each other, but you do not want them to avoid the enemies.
///
/// This field only affects which other agents that this agent will avoid, it does not affect how other agents
/// react to this agent.
///
/// See: bitmasks (view in online documentation for working links)
/// See: http://en.wikipedia.org/wiki/Mask_(computing)
///
[Pathfinding.EnumFlag]
public RVOLayer collidesWith;
/// \copydocref{Pathfinding.RVO.IAgent.Priority}
[Tooltip("How strongly other agents will avoid this agent")]
[UnityEngine.Range(0, 1)]
public float priority;
///
/// Priority multiplier.
/// This functions identically to the , however it is not exposed in the Unity inspector.
/// It is primarily used by the .
///
[System.NonSerialized]
public float priorityMultiplier;
[System.NonSerialized]
public float flowFollowingStrength;
/// Enables drawing debug information in the scene view
public AgentDebugFlags debug;
/// A locked unit cannot move. Other units will still avoid it but avoidance quality is not the best.
[Tooltip("A locked unit cannot move. Other units will still avoid it. But avoidance quality is not the best")]
public bool locked;
/// Good default settings for an RVO agent
public static readonly RVOAgent Default = new RVOAgent {
locked = false,
agentTimeHorizon = 1.0f,
obstacleTimeHorizon = 0.5f,
maxNeighbours = 10,
layer = RVOLayer.DefaultAgent,
collidesWith = (RVOLayer)(-1),
priority = 0.5f,
priorityMultiplier = 1.0f,
flowFollowingStrength = 0.0f,
debug = AgentDebugFlags.Nothing,
};
}
}
#endif