Example #1
0
            public static bool Prefix(WorldPathPool __instance, ref WorldPath __result)
            {
                List <WorldPath> paths = Traverse.Create(root: __instance).Field(name: "paths").GetValue <List <WorldPath> >();

                for (int i = 0; i < paths.Count; i++)
                {
                    if (!paths[i].inUse)
                    {
                        paths[i].inUse = true;
                        __result       = paths[i];
                        return(false);
                    }
                }
                if (paths.Count > Find.WorldObjects.CaravansCount + 2 + (Find.WorldObjects.RoutePlannerWaypointsCount - 1))
                {
                    //Log.ErrorOnce("WorldPathPool leak: more paths than caravans. Force-recovering.", 664788);
                    paths.Clear();
                }
                WorldPath worldPath = new WorldPath();

                paths.Add(worldPath);
                worldPath.inUse = true;
                __result        = worldPath;
                return(false);
            }
Example #2
0
            public static bool Prefix(WorldPathPool __instance, ref List <WorldPath> ___paths, ref WorldPath __result)
            {
                for (int i = 0; i < ___paths.Count; i++)
                {
                    if (!___paths[i].inUse)
                    {
                        ___paths[i].inUse = true;
                        __result          = ___paths[i];
                        return(false);
                    }
                }
                if (___paths.Count > Find.WorldObjects.CaravansCount + 2 + (Find.WorldObjects.RoutePlannerWaypointsCount - 1))
                {
                    //Log.ErrorOnce("WorldPathPool leak: more paths than caravans. Force-recovering.", 664788);
                    ___paths.Clear();
                }
                WorldPath worldPath = new WorldPath();

                ___paths.Add(worldPath);
                worldPath.inUse = true;
                __result        = worldPath;
                return(false);
            }