예제 #1
0
 /// <summary>
 /// Applied before OnCleanUp runs.
 /// </summary>
 internal static void Prefix(PathProber __instance)
 {
     if (__instance != null)
     {
         PathCacher.Cleanup(__instance);
     }
 }
예제 #2
0
        /// <summary>
        /// Ends a path grid update and marks the entry as authoritative in the reachability
        /// monitor, allowing removed cells to be processed.
        /// </summary>
        /// <param name="grid">The path grid to update.</param>
        /// <param name="isComplete">true if the probing is complete.</param>
        /// <param name="prober">The path prober making the update.</param>
        private static void EndUpdate(PathGrid grid, bool isComplete, PathProber prober)
        {
            grid.isUpdating = false;
            int sn   = grid.serialNo;
            var gp   = grid.groupProber;
            var inst = SensorPatches.FastGroupProber.Instance;

            if (gp != null)
            {
                var cells = grid.freshlyOccupiedCells;
                if (inst != null && ReferenceEquals(gp, MinionGroupProber.Instance))
                {
                    inst.Occupy(grid, cells, isComplete);
                }
                else
                {
                    gp.Occupy(grid, sn, cells);
                }
            }
            if (isComplete)
            {
                // There is no need to do this on the minion group prober, but in case another
                // one appears later
                gp?.SetValidSerialNos(grid, grid.previousSerialNo, sn);
                grid.previousSerialNo = sn;
            }
            if (isComplete && FastTrackOptions.Instance.CachePaths)
            {
                PathCacher.SetValid(prober, true);
            }
        }
예제 #3
0
 /// <summary>
 /// Applied after Stop runs.
 /// </summary>
 internal static void Postfix(Navigator __instance, bool arrived_at_destination)
 {
     if (__instance != null && !arrived_at_destination)
     {
         PathCacher.SetValid(__instance.PathProber, false);
     }
 }
예제 #4
0
 /// <summary>
 /// Sets the cached path to invalid.
 /// </summary>
 /// <param name="instance">The navigator to invalidate.</param>
 private static void ForceInvalid(Navigator instance)
 {
     if (instance != null)
     {
         PathCacher.SetValid(instance.PathProber, false);
     }
 }
예제 #5
0
        /// <summary>
        /// Applied before Sim4000ms runs.
        /// </summary>
        internal static bool Prefix(Navigator __instance)
        {
            var options = FastTrackOptions.Instance;

            if (__instance != null && options.CachePaths)
            {
                PathCacher.SetValid(__instance.PathProber, false);
            }
            return(!options.AsyncPathProbe);
        }
예제 #6
0
        /// <summary>
        /// Checks to see if the path cache is clean.
        /// </summary>
        /// <param name="instance">The prober that is querying.</param>
        /// <returns>true if the cache is clean, or false if it needs to run.</returns>
        private static bool CheckCache(PathProber instance)
        {
            // If nothing has changed since last time, it is a hit!
            bool hit = PathCacher.IsValid(instance);

            if (FastTrackOptions.Instance.Metrics)
            {
                Metrics.DebugMetrics.PATH_CACHE.Log(hit);
            }
            return(hit);
        }