コード例 #1
0
ファイル: ThingGrid.cs プロジェクト: KiameV/RimThreaded
        public static bool ThingAt_Building_Door(ThingGrid __instance, ref Building_Door __result, IntVec3 c)
        {
            Map         this_map    = map(__instance);
            CellIndices cellIndices = this_map.cellIndices;

            __result = null;
            if (!c.InBounds(this_map))
            {
                __result = default(Building_Door);
                return(false);
            }
            lock (thingGridDict[__instance][cellIndices.CellToIndex(c)])
            {
                List <Thing> thingList = thingGridDict[__instance][cellIndices.CellToIndex(c)];
                foreach (Thing t in thingList)
                {
                    if (t is Building_Door obj)
                    {
                        __result = obj;
                        return(false);
                    }
                }
            }
            __result = default(Building_Door);
            return(false);
        }
コード例 #2
0
        public int RegionMedianPathCost(Region region)
        {
            int num;
            int result;

            if (this.minPathCosts.TryGetValue(region, out num))
            {
                result = num;
            }
            else
            {
                bool        ignoreAllowedAreaCost = this.allowedArea != null && region.OverlapWith(this.allowedArea) != AreaOverlap.None;
                CellIndices cellIndices           = this.map.cellIndices;
                Rand.PushState();
                Rand.Seed = cellIndices.CellToIndex(region.extentsClose.CenterCell) * (region.links.Count + 1);
                for (int i = 0; i < 11; i++)
                {
                    RegionCostCalculator.pathCostSamples[i] = this.GetCellCostFast(cellIndices.CellToIndex(region.RandomCell), ignoreAllowedAreaCost);
                }
                Rand.PopState();
                Array.Sort <int>(RegionCostCalculator.pathCostSamples);
                int num2 = RegionCostCalculator.pathCostSamples[4];
                this.minPathCosts[region] = num2;
                result = num2;
            }
            return(result);
        }
コード例 #3
0
ファイル: ThingGrid.cs プロジェクト: KiameV/RimThreaded
        public static bool ThingAt(ThingGrid __instance, ref Thing __result, IntVec3 c, ThingDef def)
        {
            Map         this_map    = map(__instance);
            CellIndices cellIndices = this_map.cellIndices;

            if (!c.InBounds(this_map))
            {
                __result = null;
                return(false);
            }
            lock (thingGridDict[__instance][cellIndices.CellToIndex(c)])
            {
                List <Thing> thingList = thingGridDict[__instance][cellIndices.CellToIndex(c)];
                foreach (Thing t in thingList)
                {
                    if (t.def == def)
                    {
                        __result = t;
                        return(false);
                    }
                }
            }
            __result = null;
            return(false);
        }
コード例 #4
0
        protected Step astar(IntVec3 start)
        {
            if (stepCache == null)
            {
                stepCache = new StepFactory();
            }
            stepCache.Reset(dest, costPerMoveCardinal, costPerMoveDiagonal, Math.Max(Math.Abs(start.x - dest.Cell.x), Math.Abs(start.z - dest.Cell.z)) > maxDistanceBeforeCheating, mapSizeX, mapSizeZ);
            openlist = openlistShared;
            if (openlist == null)
            {
                openlist       = new Priority_Queue.FastPriorityQueue <Step>(limitForSearch + 10);
                openlistShared = openlist;
            }
            else
            {
                openlist.Clear();
            }
            List <int> destCells = CalculateAllowedDestCells(map, dest, peMode, traverseParms);

            // Initialisierung der Open List, die Closed List ist noch leer
            // (die Priorität bzw. der f Wert des Startknotens ist unerheblich)
            Step firstStep = stepCache.getCachedOrNewStep(start, cellIndices.CellToIndex(start));

            openlist.Enqueue(firstStep, 0);
            // diese Schleife wird durchlaufen bis entweder
            // - die optimale Lösung gefunden wurde oder
            // - feststeht, dass keine Lösung existiert
            while (openlist.Count != 0)
            {
                // Knoten mit dem geringsten f Wert aus der Open List entfernen
                Step currentStep = openlist.Dequeue();
                // Wurde das Ziel gefunden?
                if (destCells.Contains(currentStep.currentIndx))
                {
                    return(currentStep);
                }
                if (stepCache.Count >= limitForSearch)
                {
                    return(null);
                }
                // Wenn das Ziel noch nicht gefunden wurde: Nachfolgeknoten
                // des aktuellen Knotens auf die Open List setzen
                expandNode(currentStep);
                // der aktuelle Knoten ist nun abschließend untersucht
                currentStep.closed = true;
                //if ( drawPath ) map.debugDrawer.FlashCell(currentStep.current, 0.9f, "closed", 100);
            }
            // die Open List ist leer, es existiert kein Pfad zum Ziel
            return(null);
        }
コード例 #5
0
 private static void SetCellsInRadiusNoRoofNoRock(IntVec3 position, float radius)
 {
     foreach (IntVec3 cell in GenRadial.RadialCellsAround(position, radius, true))
     {
         if (cell.InBounds() == false)
         {
             continue;
         }
         // Unroof cell.
         if (cell.Roofed())
         {
             Find.RoofGrid.SetRoof(cell, null);
         }
         // Remove rock from cell.
         Building rock = Find.EdificeGrid.InnerArray[CellIndices.CellToIndex(cell)];
         if (rock != null)
         {
             rock.Destroy();
         }
         // Remove cave roof.
         List <Thing> thingList = cell.GetThingList();
         for (int thingIndex = 0; thingIndex < thingList.Count; thingIndex++)
         {
             Thing thing = thingList[thingIndex];
             if (thing.def == Util_CaveBiome.CaveRoofDef)
             {
                 thing.Destroy();
             }
         }
     }
 }
コード例 #6
0
        public static bool ThingAt(ThingGrid __instance, ref Thing __result, IntVec3 c, ThingDef def)
        {
            Map         this_map    = map(__instance);
            CellIndices cellIndices = this_map.cellIndices;

            if (!c.InBounds(this_map))
            {
                __result = null;
                return(false);
            }
            List <Thing> thingList = thingGrid(__instance)[cellIndices.CellToIndex(c)];
            Thing        thing;

            for (int index = 0; index < thingList.Count; index++)
            {
                try
                {
                    thing = thingList[index];
                }
                catch (ArgumentOutOfRangeException) { break; }
                if (thing.def == def)
                {
                    __result = thing;
                    return(false);
                }
            }
            __result = null;
            return(false);
        }
コード例 #7
0
        public override void Regenerate()
        {
            var ZTracker = Current.Game.GetComponent <ZLevelsManager>();
            int curLevel = ZTracker.GetZIndexFor(base.Map);

            bool[] fogGrid = base.Map.fogGrid.fogGrid;
            if (curLevel > 0)
            {
                foreach (var map in ZTracker.GetAllMaps(base.Map.Tile)
                         .OrderByDescending(x => ZTracker.GetZIndexFor(x)))
                {
                    int         baseLevel   = ZTracker.GetZIndexFor(map);
                    CellIndices cellIndices = map.cellIndices;

                    if (curLevel > baseLevel && baseLevel >= 0)
                    {
                        CellRect cellRect = this.section.CellRect;

                        foreach (IntVec3 intVec in this.section.CellRect)
                        {
                            if (intVec.Fogged(map) && !intVec.Fogged(base.Map))
                            {
                                fogGrid[cellIndices.CellToIndex(intVec)] = true;
                                base.Map.mapDrawer.MapMeshDirty(intVec, MapMeshFlag.FogOfWar);
                            }
                        }
                    }
                }
            }
        }
コード例 #8
0
        public static void InitStatusesAndPushStartNode2(ref int curIndex, IntVec3 start, CellIndices cellIndices, PathFinderNodeFast[] pathFinderNodeFast, FastPriorityQueue <CostNode2> fastPriorityQueue, ref ushort local_statusOpenValue, ref ushort local_statusClosedValue)
        {
            local_statusOpenValue   += 2;
            local_statusClosedValue += 2;
            if (local_statusClosedValue >= 65435)
            {
                int num = pathFinderNodeFast.Length;
                for (int i = 0; i < num; i++)
                {
                    pathFinderNodeFast[i].status = 0;
                }

                local_statusOpenValue   = 1;
                local_statusClosedValue = 2;
            }
            curIndex = cellIndices.CellToIndex(start);
            pathFinderNodeFast[curIndex].knownCost     = 0;
            pathFinderNodeFast[curIndex].heuristicCost = 0;
            pathFinderNodeFast[curIndex].costNodeCost  = 0;
            pathFinderNodeFast[curIndex].parentIndex   = curIndex;
            pathFinderNodeFast[curIndex].status        = local_statusOpenValue;
            fastPriorityQueue.Clear();

            //CostNode2 newCostNode = constructorCostNode.Invoke(new object[] { curIndex, 0 });
            fastPriorityQueue.Push(new CostNode2(curIndex, 0));
        }
コード例 #9
0
        public static void InitStatusesAndPushStartNode3(ref int curIndex, IntVec3 start, CellIndices cellIndices, PathFinderNodeFast[] calcGrid, ref ushort local_statusOpenValue, ref ushort local_statusClosedValue)
        {
            local_statusOpenValue   += 2;
            local_statusClosedValue += 2;
            if (local_statusClosedValue >= 65435)
            {
                int num = calcGrid.Length;
                for (int i = 0; i < num; i++)
                {
                    calcGrid[i].status = 0;
                }

                local_statusOpenValue   = 1;
                local_statusClosedValue = 2;
            }
            openValues[Thread.CurrentThread.ManagedThreadId]   = local_statusOpenValue;
            closedValues[Thread.CurrentThread.ManagedThreadId] = local_statusClosedValue;
            curIndex = cellIndices.CellToIndex(start);
            calcGrid[curIndex].knownCost     = 0;
            calcGrid[curIndex].heuristicCost = 0;
            calcGrid[curIndex].costNodeCost  = 0;
            calcGrid[curIndex].parentIndex   = curIndex;
            calcGrid[curIndex].status        = local_statusOpenValue;

            //fastPriorityQueue.Clear();
            //object newCostNode = constructorCostNode.Invoke(new object[] { curIndex, 0 });
            //fastPriorityQueue.Push(newCostNode);
        }
コード例 #10
0
        public static void Convert_Old_Stockpiles_To_Lazy(ZoneManager __instance, Zone[] ___zoneGrid)
        {
            Zone[]                zoneGrid    = ___zoneGrid;
            ZoneManager           manager     = __instance;
            Map                   map         = manager.map;
            CellIndices           cellIndices = manager.map.cellIndices;
            List <Zone>           zones       = manager.AllZones;
            List <Zone_Stockpile> deregister  = new List <Zone_Stockpile>();
            List <Lazy_Stockpile> register    = new List <Lazy_Stockpile>();


            for (int i = 0; i < zones.Count; i++)
            {
                Zone z = zones[i];
                if (z as Zone_Stockpile != null && z as Lazy_Stockpile == null)
                {
                    Lazy_Stockpile tmp = new Lazy_Stockpile(z as Zone_Stockpile);
                    manager.AllZones.Remove(z);
                    manager.AllZones.Add(tmp);
                    foreach (IntVec3 c in tmp)
                    {
                        zoneGrid[cellIndices.CellToIndex(c)] = tmp;
                    }
                    //deregister.Add(z as Zone_Stockpile);
                    //register.Add(tmp);
                    Log.Message($"The stockpile {z.label} has been converted to a lazy stockpile");
                }
            }
        }
コード例 #11
0
ファイル: ThingGrid.cs プロジェクト: KiameV/RimThreaded
        public static bool ThingsListAtFast(ThingGrid __instance, ref List <Thing> __result, IntVec3 c)
        {
            Map         this_map    = map(__instance);
            CellIndices cellIndices = this_map.cellIndices;

            __result = thingGridDict[__instance][cellIndices.CellToIndex(c)];
            return(false);
        }
コード例 #12
0
        public static AirNet NetAt(IntVec3 pos, NetLayer layer)
        {
            if (!AirNetTicker.doneInit)
            {
                AirNetTicker.Initialize();
            }

            return(netGrid[(int)layer][CellIndices.CellToIndex(pos)]);
        }
コード例 #13
0
        public int RegionMedianPathCost(Region region)
        {
            if (minPathCosts.TryGetValue(region, out int value))
            {
                return(value);
            }
            bool        ignoreAllowedAreaCost = allowedArea != null && region.OverlapWith(allowedArea) != AreaOverlap.None;
            CellIndices cellIndices           = map.cellIndices;

            Rand.PushState();
            Rand.Seed = cellIndices.CellToIndex(region.extentsClose.CenterCell) * (region.links.Count + 1);
            for (int i = 0; i < 11; i++)
            {
                pathCostSamples[i] = GetCellCostFast(cellIndices.CellToIndex(region.RandomCell), ignoreAllowedAreaCost);
            }
            Rand.PopState();
            Array.Sort(pathCostSamples);
            return(minPathCosts[region] = pathCostSamples[4]);
        }
コード例 #14
0
        private bool isBlocked(IntVec3 position, int angleDelta)
        {
            Thing thingBlockers = innerArray[CellIndices.CellToIndex(position)];

            if (thingBlockers != null)
            {
                if (thingBlockers.def.blockLight)
                {
                    //block this tile
                    addCellIndex(position, true);
                    //block next forward tile to prevent further light going this way
                    addCellIndex(position.TranslateDirection(Orientation), true);

                    //block next left and right tiles to prevent further light going this way and help with "angle" detection
                    addCellIndex(position.TranslateDirection(Orientation, 1), true);
                    addCellIndex(position.TranslateDirection(Orientation, -1), true);
                }
                thingBlockers = null;
                //Log.Message("Blocking by Def: X: " + position.x + " Z: " + position.z);
                return(true);
            }

            /////----------If def.blocked not found scan for previous blocks-------------//////


            //I pre emtifly block the cell at the building collision level so now I can find it here and carry on blocking
            //This part feels a bit iffy to me because I have to carry on calculation blockers. Not sure how flag any further
            //blockers in that particular direction to be forgotten about. possibly a shortfall in my calculation logic. Oh well..it works I suppose
            GlowGridCache thisCellBlocked = ColorCellIndexCache.FirstOrDefault(deltaZ => position == deltaZ.Position & deltaZ.IsBlocked);

            if (thisCellBlocked != null)
            {
                //block the next cell ahead and repeat el'kapitan!
                addCellIndex(thisCellBlocked.Position.TranslateDirection(Orientation), true);
                if (angleDelta < 0)
                {
                    //pffff.. a bit ugly i know.. but i need to compensate for wide angles over distance
                    addCellIndex(thisCellBlocked.Position.TranslateDirection(Orientation, -1), true);
                    //addCellIndex(thisCellBlocked.Position.TranslateDirection(this.Orientation, -2), true);
                    //addCellIndex(thisCellBlocked.Position.TranslateDirection(this.Orientation, -3), true);
                }
                if (angleDelta > 0)
                {
                    addCellIndex(thisCellBlocked.Position.TranslateDirection(Orientation, 1), true);
                    //addCellIndex(thisCellBlocked.Position.TranslateDirection(this.Orientation, 2), true);
                    //addCellIndex(thisCellBlocked.Position.TranslateDirection(this.Orientation, 3), true);
                }
            }



            return(false);
        }
コード例 #15
0
ファイル: ThingGrid.cs プロジェクト: KiameV/RimThreaded
        public static List <Thing> ThingsListAt2(ThingGrid __instance, IntVec3 c)
        {
            Map         this_map    = map(__instance);
            CellIndices cellIndices = this_map.cellIndices;

            if (c.InBounds(this_map))
            {
                return(thingGridDict[__instance][cellIndices.CellToIndex(c)]);
            }
            Log.ErrorOnce("Got ThingsListAt out of bounds: " + c, 495287, false);
            return(EmptyThingList);
        }
コード例 #16
0
ファイル: EdificeGrid.cs プロジェクト: potsh/RimWorld
        public void DeRegister(Building ed)
        {
            CellIndices cellIndices = map.cellIndices;
            CellRect    cellRect    = ed.OccupiedRect();

            for (int i = cellRect.minZ; i <= cellRect.maxZ; i++)
            {
                for (int j = cellRect.minX; j <= cellRect.maxX; j++)
                {
                    innerArray[cellIndices.CellToIndex(j, i)] = null;
                }
            }
        }
コード例 #17
0
        //Returns things that are in area
        public static IEnumerable <Thing> searcher(Area area, List <Thing> things)
        {
            List <Thing> results = new List <Thing>();

            foreach (Thing thing in things)
            {
                if (area.GetCellBool(CellIndices.CellToIndex(thing.Position)))
                {
                    yield return(thing);
                }
            }
            yield break;
        }
コード例 #18
0
 public static void NotifyNetCreated(AirNet newNet)
 {
     foreach (var node in newNet.nodes)
     {
         //For every cell occupied by a node
         var occupiedRect = node.parent.OccupiedRect();
         foreach (var current in occupiedRect)
         {
             //Register the cell as the new net
             netGrid[newNet.LayerInt][CellIndices.CellToIndex(current)] = newNet;
         }
     }
 }
コード例 #19
0
 public static void NotifyNetDeregistered(AirNet oldNet)
 {
     foreach (var node in oldNet.nodes)
     {
         //For every cell occupied by a node
         var occupiedRect = node.parent.OccupiedRect();
         foreach (var current in occupiedRect)
         {
             //Delete the cell's registered net
             netGrid[oldNet.LayerInt][CellIndices.CellToIndex(current)] = null;
         }
     }
 }
コード例 #20
0
ファイル: ThingGrid.cs プロジェクト: KiameV/RimThreaded
        public static bool ThingsAt(ThingGrid __instance, ref IEnumerable <Thing> __result, IntVec3 c)
        {
            Map         this_map    = map(__instance);
            CellIndices cellIndices = this_map.cellIndices;

            __result = null;
            if (c.InBounds(this_map))
            {
                __result = thingGridDict[__instance][cellIndices.CellToIndex(c)];
                return(false);
            }
            return(false);
        }
コード例 #21
0
        public void Register(Building ed)
        {
            CellIndices cellIndices = map.cellIndices;
            CellRect    cellRect    = ed.OccupiedRect();

            for (int i = cellRect.minZ; i <= cellRect.maxZ; i++)
            {
                for (int j = cellRect.minX; j <= cellRect.maxX; j++)
                {
                    IntVec3 c = new IntVec3(j, 0, i);
                    innerArray[cellIndices.CellToIndex(c)] = ed;
                }
            }
        }
コード例 #22
0
ファイル: ThingGrid.cs プロジェクト: KiameV/RimThreaded
        public static bool ThingsListAt(ThingGrid __instance, ref List <Thing> __result, IntVec3 c)
        {
            Map         this_map    = map(__instance);
            CellIndices cellIndices = this_map.cellIndices;

            if (c.InBounds(this_map))
            {
                __result = thingGridDict[__instance][cellIndices.CellToIndex(c)];
                return(false);
            }
            Log.ErrorOnce("Got ThingsListAt out of bounds: " + c, 495287, false);
            __result = EmptyThingList;
            return(false);
        }
コード例 #23
0
        internal void SetAllFogged(Map map)
        {
            CellIndices cellIndices = map.cellIndices;

            if (map.fogGrid?.fogGrid != null)
            {
                foreach (IntVec3 c in map.AllCells)
                {
                    map.fogGrid.fogGrid[cellIndices.CellToIndex(c)] = true;
                }
                if (Current.ProgramState == ProgramState.Playing)
                {
                    map.roofGrid.Drawer.SetDirty();
                }
            }
        }
コード例 #24
0
 protected void InitStatusesAndPushStartNode(ref int curIndex, IntVec3 start)
 {
     statusOpenValue   += 2;
     statusClosedValue += 2;
     if (statusClosedValue >= 65435)
     {
         ResetStatuses();
     }
     curIndex = cellIndices.CellToIndex(start);
     calcGrid[curIndex].knownCost     = 0;
     calcGrid[curIndex].heuristicCost = 0;
     calcGrid[curIndex].costNodeCost  = 0;
     calcGrid[curIndex].parentIndex   = curIndex;
     calcGrid[curIndex].status        = statusOpenValue;
     openList.Clear();
     openList.Push(new CostNode(curIndex, 0));
 }
コード例 #25
0
        private static Room FindCurrentRegionGroupNeighborWithMostRegions2(RegionAndRoomUpdater __instance, out bool multipleOldNeighborRooms)
        {
            multipleOldNeighborRooms = false;
            Room room = null;

            for (int i = 0; i < currentRegionGroup(__instance).Count; i++)
            {
                foreach (Region item in currentRegionGroup(__instance)[i].NeighborsOfSameType)
                {
                    Region      currentRegionGroup3 = item;
                    Map         map2        = currentRegionGroup3.Map;
                    CellIndices cellIndices = map2.cellIndices;
                    Region[]    directGrid  = map2.regionGrid.DirectGrid;
                    bool        cellExists  = false;
                    foreach (IntVec3 intVec3 in currentRegionGroup3.extentsClose)
                    {
                        if (directGrid[cellIndices.CellToIndex(intVec3)] == currentRegionGroup3)
                        {
                            cellExists = true;
                            break;
                        }
                    }
                    if (!cellExists)
                    {
                        Log.Error("still bad regions");
                    }
                    if (item.Room != null && !reusedOldRooms(__instance).Contains(item.Room))
                    {
                        if (room == null)
                        {
                            room = item.Room;
                        }
                        else if (item.Room != room)
                        {
                            multipleOldNeighborRooms = true;
                            if (item.Room.RegionCount > room.RegionCount)
                            {
                                room = item.Room;
                            }
                        }
                    }
                }
            }
            return(room);
        }
コード例 #26
0
ファイル: BlueprintHandler.cs プロジェクト: SwimUp/moreevents
        private static void AddRoomsToFog(List <Room> allRooms, Map map, bool fogDoors = false)
        {
            CellIndices cellIndices = map.cellIndices;

            foreach (var room in allRooms)
            {
                foreach (var cell in room.Cells)
                {
                    if (cell.GetDoor(map) != null && !fogDoors)
                    {
                        continue;
                    }

                    map.fogGrid.fogGrid[cellIndices.CellToIndex(cell)] = true;
                    map.mapDrawer.MapMeshDirty(cell, MapMeshFlag.FogOfWar);
                }
            }
        }
コード例 #27
0
        //EdificeGrid
        //TODO Make transpiler
        public static bool RegisterDoorExpanded(EdificeGrid __instance, Building ed)
        {
            //Log.Message("Register");
            //Log.Message(ed.Label);
            //Log.Message(ed.def.thingClass.ToString());
            if (isExceptionForEdificeRegistration(ed))
            {
                //<VanillaCodeSequence>
                CellIndices cellIndices = Traverse.Create(__instance).Field("map").GetValue <Map>().cellIndices;
                CellRect    cellRect    = ed.OccupiedRect();
                for (int i = cellRect.minZ; i <= cellRect.maxZ; i++)
                {
                    for (int j = cellRect.minX; j <= cellRect.maxX; j++)
                    {
                        IntVec3 intVec      = new IntVec3(j, 0, i);
                        var     oldBuilding = __instance[intVec];
                        if (UnityData.isDebugBuild && oldBuilding != null && !oldBuilding.Destroyed &&
                            !isExceptionForEdificeRegistration(oldBuilding))
                        {
                            Log.Error(string.Concat(new object[]
                            {
                                "Added edifice ",
                                ed.LabelCap,
                                " over edifice ",
                                oldBuilding.LabelCap,
                                " at ",
                                intVec,
                                ". Destroying old edifice, despite DoorsExpanded code."
                            }));
                            oldBuilding.Destroy(DestroyMode.Vanish);
                            return(false);
                        }

                        Traverse.Create(__instance).Field("innerArray").GetValue <Building[]>()[
                            cellIndices.CellToIndex(intVec)] = ed;
                    }
                }

                //</VanillaCodeSequence>
                return(false);
            }

            return(true);
        }
コード例 #28
0
        /*
         * public static void Postfix_Constructor(ThingGrid __instance, Map map)
         * {
         *  ThingGrid_Patch.map(__instance) = map;
         *  CellIndices cellIndices = map.cellIndices;
         *  List<Thing>[] thingGrid = new List<Thing>[cellIndices.NumGridCells];
         *  thingGridDict.Add(__instance, thingGrid);
         *  for (int i = 0; i < cellIndices.NumGridCells; ++i)
         *      thingGrid[i] = new List<Thing>(4);
         * }
         */
        public static bool RegisterInCell(ThingGrid __instance, Thing t, IntVec3 c)
        {
            Map         this_map    = map(__instance);
            CellIndices cellIndices = this_map.cellIndices;

            if (!c.InBounds(this_map))
            {
                Log.Warning(t.ToString() + " tried to register out of bounds at " + c + ". Destroying.", false);
                t.Destroy(DestroyMode.Vanish);
            }
            else
            {
                int index = cellIndices.CellToIndex(c);
                lock (thingGrid(__instance)[index]) {
                    thingGrid(__instance)[index].Add(t);
                }
            }
            return(false);
        }
コード例 #29
0
        public static bool get_AnyCell(Region __instance, ref IntVec3 __result)
        {
            Map         map         = Find.Maps[__instance.mapIndex];
            CellIndices cellIndices = map.cellIndices;

            Region[] directGrid = map.regionGrid.DirectGrid;
            foreach (IntVec3 item in __instance.extentsClose)
            {
                if (directGrid[cellIndices.CellToIndex(item)] == __instance)
                {
                    __result = item;
                    return(false);
                }
            }

            Log.Warning("Couldn't find any cell in region " + __instance.ToString());
            __result = __instance.extentsClose.RandomCell;
            return(false);
        }
コード例 #30
0
        public static bool WithinRangeOfRoofHolder(IntVec3 c, Map map)
        {
            CellIndices cellIndices = map.cellIndices;

            Building[] innerArray = map.edificeGrid.InnerArray;
            for (int i = 0; i < RoofCollapseUtility.RoofSupportRadialCellsCount; i++)
            {
                IntVec3 c2 = c + GenRadial.RadialPattern[i];
                if (c2.InBounds(map))
                {
                    Building building = innerArray[cellIndices.CellToIndex(c2)];
                    if (building != null && building.def.holdsRoof)
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }