diff --git "a/golfmanager/Packages/com.arongranberg.astar@4.3.43/Core/AI/RichAI.cs" "b/golfmanager/Packages/com.arongranberg.astar@4.3.43/Core/AI/RichAI.cs" index a2bea2fa7..09c1ee7c5 100644 --- "a/golfmanager/Packages/com.arongranberg.astar@4.3.43/Core/AI/RichAI.cs" +++ "b/golfmanager/Packages/com.arongranberg.astar@4.3.43/Core/AI/RichAI.cs" @@ -10,6 +10,10 @@ namespace Pathfinding { [AddComponentMenu("Pathfinding/AI/RichAI (3D, for navmesh)")] /// Advanced AI for navmesh based graphs. public partial class RichAI : AIBase, IAstarAI { + + public delegate void BoolDelegate(bool state); + public event BoolDelegate OnPathDestroyed; + /// /// Max acceleration of the agent. /// In world units per second per second. @@ -199,6 +203,7 @@ namespace Pathfinding { /// \copydoc Pathfinding::IAstarAI::canMove bool IAstarAI.canMove { get { return canMove; } set { canMove = value; } } + bool m_pathBrokenLast = false; /// /// True if approaching the last waypoint in the current part of the path. /// Path parts are separated by off-mesh links. @@ -357,6 +362,13 @@ namespace Pathfinding { SearchPath(); } + if (requiresRepath && !m_pathBrokenLast) + OnPathDestroyed?.Invoke(true); + else if (!requiresRepath && m_pathBrokenLast && !waitingForPathCalculation) + OnPathDestroyed?.Invoke(false); + + m_pathBrokenLast = requiresRepath; + return position; }