Exemple #1
0
        public static bool GetPreciseRegionLinkDistances(RegionCostCalculator __instance, Region region, CellRect destination, List <Pair <RegionLink, int> > outDistances)
        {
            outDistances.Clear();
            if (tmpCellIndices == null)
            {
                tmpCellIndices = new List <int>();
            }
            else
            {
                tmpCellIndices.Clear();
            }
            if (destination.Width == 1 && destination.Height == 1)
            {
                tmpCellIndices.Add(map(__instance).cellIndices.CellToIndex(destination.CenterCell));// Replaces tmpCellIndices
            }
            else
            {
                foreach (IntVec3 item in destination)
                {
                    if (item.InBounds(map(__instance)))
                    {
                        tmpCellIndices.Add(map(__instance).cellIndices.CellToIndex(item));// Replaces tmpCellIndices
                    }
                }
            }
            if (tmpDistances == null)
            {
                tmpDistances = new Dictionary <int, float>();
            }
            else
            {
                tmpDistances.Clear();
            }

            DijkstraInt.Run(tmpCellIndices, (int x) => funcPreciseRegionLinkDistancesNeighborsGetter(__instance, x, region),
                            preciseRegionLinkDistancesDistanceGetter(__instance), tmpDistances); // Replaces tmpCellIndices

            for (int i = 0; i < region.links.Count; i++)
            {
                RegionLink regionLink = region.links[i]; //Needs catch ArgumentOutOfRange - or fix region links
                if (regionLink.GetOtherRegion(region).Allows(traverseParmsField(__instance), isDestination: false))
                {
                    if (!tmpDistances.TryGetValue(map(__instance).cellIndices.CellToIndex(
                                                      linkTargetCells(__instance)[regionLink]), out float value))//Replaces tmpDistances
                    {
                        Log.ErrorOnce("Dijkstra couldn't reach one of the cells even though they are in the same region. There is most likely something wrong with the neighbor nodes getter.", 1938471531);
                        value = 100f;
                    }
                    outDistances.Add(new Pair <RegionLink, int>(regionLink, (int)value));
                }
            }
            return(false);
        }
 public static void InitializeAllThreadStatics()
 {
     AttackTargetFinder_Patch.InitializeThreadStatics();
     AttackTargetsCache_Patch.InitializeThreadStatics();
     BeautyUtility_Patch.InitializeThreadStatics();
     CellFinder_Patch.InitializeThreadStatics();
     CompCauseGameCondition_Patch.InitializeThreadStatics();
     DamageWorker_Patch.InitializeThreadStatics();
     DijkstraInt.InitializeThreadStatics();
     Fire_Patch.InitializeThreadStatics();
     FloatMenuMakerMap_Patch.InitializeThreadStatics();
     FoodUtility_Patch.InitializeThreadStatics();
     FloodFiller_Patch.InitializeThreadStatics();
     GenAdj_Patch.InitializeThreadStatics();
     GenAdjFast_Patch.InitializeThreadStatics();
     GenLeaving_Patch.InitializeThreadStatics();
     GenRadial_Patch.InitializeThreadStatics();
     GenTemperature_Patch.InitializeThreadStatics();
     GenText_Patch.InitializedThreadStatics();
     HaulAIUtility_Patch.InitializeThreadStatics();
     ImmunityHandler_Patch.InitializeThreadStatics();
     InfestationCellFinder_Patch.InitializeThreadStatics();
     MapTemperature_Patch.InitializeThreadStatics();
     PathFinder_Patch.InitializeThreadStatics();
     Pawn_InteractionsTracker_Transpile.InitializeThreadStatics();
     Pawn_MeleeVerbs_Patch.InitializeThreadStatics();
     Pawn_WorkSettings_Patch.InitializeThreadStatics();
     PawnDiedOrDownedThoughtsUtility_Patch.InitializeThreadStatics();
     PawnsFinder_Patch.InitializeThreadStatics();
     Rand_Patch.InitializeThreadStatics();
     RCellFinder_Patch.InitializeThreadStatics();
     Reachability_Patch.InitializeThreadStatics();
     ReachabilityCache_Patch.InitializeThreadStatics();
     RegionDirtyer_Patch.InitializeThreadStatics();
     RegionListersUpdater_Patch.InitializeThreadStatics();
     RegionTraverser_Transpile.InitializeThreadStatics(); //this
     Projectile_Patch.InitializeThreadStatics();
     ThinkNode_PrioritySorter_Patch.InitializeThreadStatics();
     ThoughtHandler_Patch.InitializeThreadStatics();
     Verb_Patch.InitializeThreadStatics();
     WealthWatcher_Patch.InitializeThreads();
     World_Patch.InitializeThreadStatics();
     JoyGiver_InteractBuilding_Patch.InitializeThreadStatics();
     JoyGiver_InteractBuildingSitAdjacent_Patch.InitializeThreadStatics();
     JoyGiver_TakeDrug_Patch.InitializeThreadStatics();
     WorkGiver_DoBill_RegionProcessor.InitializeThreadStatics();
     Pawn_RelationsTracker_Patch.InitializeThreadStatics();
     Battle_Patch.InitializeThreadStatics();
 }