Example #1
0
        public static bool hijackCanReach(this Reachability oldReacher, IntVec3 start, LocalTargetInfo dest, PathEndMode peMode, TraverseParms traverseParams)
        {
            int    ticket = -1;
            String index  = "";

            try
            {
                FieldInfo mapField = typeof(Reachability).GetField("map", BindingFlags.NonPublic | BindingFlags.Instance);
                Map       map      = (Map)mapField.GetValue(oldReacher);
                index = map.GetUniqueLoadID();

                var reacher = ReachabilityInstanceContrainer.GetInstance().requestReacher(index, ref ticket, map);
                var result  = reacher.CanReach(start, dest, peMode, traverseParams);
                ReachabilityInstanceContrainer.GetInstance().CheckInReacher(index, ticket);
                return(result);
            }
            catch (Exception e)
            {
                if (ticket != -1 && !index.NullOrEmpty())
                {
                    ReachabilityInstanceContrainer.GetInstance().CheckInReacher(index, ticket);
                }
                throw e;
            }
        }
Example #2
0
        public static bool hijackCanReachFactionBase(this Reachability oldReacher, IntVec3 c, Faction factionBaseFaction)
        {
            int    ticket = -1;
            String index  = "";

            try
            {
                FieldInfo mapField = typeof(Reachability).GetField("map", BindingFlags.NonPublic | BindingFlags.Instance);
                Map       map      = (Map)mapField.GetValue(oldReacher);
                index = map.GetUniqueLoadID();

                var reacher = ReachabilityInstanceContrainer.GetInstance().requestReacher(index, ref ticket, map);
                var result  = reacher.CanReachFactionBase(c, factionBaseFaction);
                ReachabilityInstanceContrainer.GetInstance().CheckInReacher(index, ticket);
                return(result);
            }
            catch (Exception e)
            {
                if (ticket != -1 && !index.NullOrEmpty())
                {
                    ReachabilityInstanceContrainer.GetInstance().CheckInReacher(index, ticket);
                }
                throw e;
            }
        }
Example #3
0
 public static void prePatch()
 {
     ReachabilityInstanceContrainer.GetInstance().refreshReachers();
     PathFinderInstanceContainer.GetInstance().refreshFinders();
 }