public override AcceptanceReport CanDesignateCell( IntVec3 c )
 {
     if (!c.InBounds())
     {
         return false;
     }
     if (!Game.GodMode && c.Fogged())
     {
         return false;
     }
     return TopDeconstructibleInCell( c ) != null;
 }
Ejemplo n.º 2
0
 public override AcceptanceReport CanDesignateCell( IntVec3 c )
 {
     if( !c.InBounds() )
         return "OutOfBounds".Translate();
     if( c.Fogged() )
         return "CannotPlaceInUndiscovered".Translate();
     if( Find.DesignationManager.DesignationAt( c, DesignationDefOf.Mine ) != null )
         return "SpaceAlreadyOccupied".Translate();
     Thing mineable = MineUtility.MineableInCell( c );
     if( ( mineable == null )||( !mineable.def.building.isResourceRock ) )
         return "MessageMustDesignateMineable".Translate();
     return AcceptanceReport.WasAccepted;
 }
 public static bool IsValidPositionToSpawnRefugeePod(IntVec3 position)
 {
     ThingDef chunkDef = ThingDefOf.ShipChunk;
     if ((position.InBounds() == false)
         || position.Fogged()
         || (position.Standable() == false)
         || (position.Roofed()
             && position.GetRoof().isThickRoof))
     {
         return false;
     }
     return true;
 }
        // returning string text assigning false reason to AcceptanceReport
        public override AcceptanceReport CanDesignateCell(IntVec3 cell)
        {
            if (!cell.InBounds() || cell.Fogged() || cell.ContainsStaticFire())
            {
                return false;
            }

            var firstItem = cell.GetFirstItem();
            if (firstItem != null && CanDesignateThing(firstItem).Accepted)
            {
                return true;
            }

            return false;
        }
 public override AcceptanceReport CanDesignateCell(IntVec3 c)
 {
     if (c.InBounds()
         && (c.Fogged() == false))
     {
         Area outpostArea = OG_Util.FindOutpostArea();
         if ((outpostArea != null)
             && outpostArea.ActiveCells.Contains(c))
         {
             return "You cannot manage MiningCo. Outpost roof. This area does not belong to your colony.";
         }
         if (Find.RoofGrid.RoofAt(c) == OG_Util.IronedRoofDef)
         {
             return true;
         }
     }
     return base.CanDesignateCell(c);
 }
 // returning string text assigning false reason to AcceptanceReport
 public override AcceptanceReport CanDesignateCell(IntVec3 loc)
 {
     if (!loc.InBounds())
     {
         return false;
     }
     if (loc.Fogged())
     {
         return false;
     }
     if (Find.DesignationManager.DesignationAt(loc, designationDef) != null)
     {
         return false;
     }
     if (!allowedTerrain.Contains(Find.TerrainGrid.TerrainAt(loc)))
     {
         return "Wrong terrain type";
     }
     return AcceptanceReport.WasAccepted;
 }
 public override AcceptanceReport CanDesignateCell( IntVec3 c )
 {
     if( !c.InBounds() )
         return "OutOfBounds".Translate();
     if( c.Fogged() )
         return "CannotPlaceInUndiscovered".Translate();
     if( Find.DesignationManager.DesignationAt( c, SmoothWall.designationDef ) != null )
         return "TerrainBeingSmoothed".Translate();
     // Must be mineable
     Thing mineable = MineUtility.MineableInCell( c );
     if( mineable == null )
     {
         return "MessageMustDesignateMineable".Translate();
     }
     // Must have associated stone blocks
     string blocksDef = "Blocks" + mineable.def.defName;
     ThingDef stoneBlocks = DefDatabase<ThingDef>.GetNamed( blocksDef, false );
     if( stoneBlocks == null )
     {
         return "MessageMustDesignateMineable".Translate();
     }
     return AcceptanceReport.WasAccepted;
 }
Ejemplo n.º 8
0
 private bool IsGoodLocationForSpawn(IntVec3 loc)
 {
     return(loc.InBounds(base.SingleMap) && !loc.Roofed(base.SingleMap) && loc.Standable(base.SingleMap) && loc.IsValid && !loc.Fogged(base.SingleMap) && loc.Walkable(base.SingleMap));
 }
 internal bool <> m__2(IntVec3 x)
 {
     return(x.Standable(this.map) && !x.Fogged(this.map));
 }
        private static bool TryFindOppositeSpots(Map map, float maxDistPctToOppositeSpots, out IntVec3 first, out IntVec3 second)
        {
            IntVec3  intVec    = MultipleCaravansCellFinder.RandomSpotNearEdge(map);
            IntVec3  intVec2   = MultipleCaravansCellFinder.OppositeSpot(intVec, map);
            int      num       = Mathf.Min(map.Size.x, map.Size.z);
            CellRect cellRect  = CellRect.CenteredOn(intVec, Mathf.Max(Mathf.RoundToInt((float)num * maxDistPctToOppositeSpots), 1)).ClipInsideMap(map);
            CellRect cellRect2 = CellRect.CenteredOn(intVec2, Mathf.Max(Mathf.RoundToInt((float)num * maxDistPctToOppositeSpots), 1)).ClipInsideMap(map);

            for (int i = 0; i < 20; i++)
            {
                IntVec3 intVec3 = (i != 0) ? cellRect.RandomCell : intVec;
                IntVec3 intVec4 = (i != 0) ? cellRect2.RandomCell : intVec2;
                if (intVec3.Standable(map) && !intVec3.Fogged(map) && intVec4.Standable(map) && !intVec4.Fogged(map) && map.reachability.CanReach(intVec3, intVec4, PathEndMode.OnCell, TraverseParms.For(TraverseMode.NoPassClosedDoors, Danger.Deadly, false)))
                {
                    first  = intVec3;
                    second = intVec4;
                    return(true);
                }
            }
            first  = IntVec3.Invalid;
            second = IntVec3.Invalid;
            return(false);
        }
        // Token: 0x06003688 RID: 13960 RVA: 0x001A0BAC File Offset: 0x0019EFAC
        public static bool TryFindRaidDropCenterClose(out IntVec3 spot, Map map)
        {
            Faction parentFaction = map.ParentFaction;

            if (parentFaction == null)
            {
                return(RCellFinder.TryFindRandomCellNearTheCenterOfTheMapWith((IntVec3 x) => DropThoughRoofCellFinder.CanPhysicallyDropInto(x, map, true) && !x.Fogged(map) && x.Standable(map), map, out spot));
            }
            int num = 0;

            for (; ;)
            {
                IntVec3 root = IntVec3.Invalid;
                if (map.mapPawns.FreeHumanlikesSpawnedOfFaction(parentFaction).Count <Pawn>() > 0)
                {
                    root = map.mapPawns.FreeHumanlikesSpawnedOfFaction(parentFaction).RandomElement <Pawn>().Position;
                }
                else
                {
                    if (parentFaction == Faction.OfPlayer)
                    {
                        List <Building> allBuildingsColonist = map.listerBuildings.allBuildingsColonist;
                        for (int i = 0; i < allBuildingsColonist.Count; i++)
                        {
                            if (DropThoughRoofCellFinder.TryFindDropSpotNear(allBuildingsColonist[i].Position, map, out root, true, true))
                            {
                                break;
                            }
                        }
                    }
                    else
                    {
                        List <Thing> list = map.listerThings.ThingsInGroup(ThingRequestGroup.BuildingArtificial);
                        for (int j = 0; j < list.Count; j++)
                        {
                            if (list[j].Faction == parentFaction && DropThoughRoofCellFinder.TryFindDropSpotNear(list[j].Position, map, out root, true, true))
                            {
                                break;
                            }
                        }
                    }
                    if (!root.IsValid)
                    {
                        RCellFinder.TryFindRandomCellNearTheCenterOfTheMapWith((IntVec3 x) => DropThoughRoofCellFinder.CanPhysicallyDropInto(x, map, true) && !x.Fogged(map) && x.Standable(map), map, out root);
                    }
                }
                spot = CellFinder.RandomClosewalkCellNear(root, map, 10, null);
                if (DropThoughRoofCellFinder.CanPhysicallyDropInto(spot, map, true) && !spot.Fogged(map))
                {
                    break;
                }
                num++;
                if (num > 300)
                {
                    goto Block_10;
                }
            }
            return(true);

Block_10:
            spot = CellFinderLoose.RandomCellWith((IntVec3 c) => DropThoughRoofCellFinder.CanPhysicallyDropInto(c, map, true), map, 1000);
            return(false);
        }
 internal bool <> m__1(IntVec3 x)
 {
     return(x.Standable(this.map) && !x.Fogged(this.map) && !x.InHorDistOf(this.localFirst, this.tryMinDistBetweenSpots));
 }
        public bool IsValidPositionToSpawnShipChunk(IntVec3 position)
        {
	        ThingDef chunkDef = ThingDefOf.ShipChunk;
            if ((position.InBounds() == false)
                || position.Fogged()
                || (position.Standable() == false)
                || (position.Roofed()
                    && position.GetRoof().isThickRoof))
            {
                return false;
            }
            if (position.SupportsStructureType(chunkDef.terrainAffordanceNeeded) == false)
            {
                return false;
            }
            List<Thing> thingList = position.GetThingList();
            for (int thingIndex = 0; thingIndex < thingList.Count; thingIndex++)
            {
                Thing thing = thingList[thingIndex];
                if ((thing.def.category != ThingCategory.Plant)
                    && GenSpawn.SpawningWipes(chunkDef, thing.def))
                {
                    return false;
                }
            }
            return true;
        }
Ejemplo n.º 14
0
            internal bool <> m__0(IntVec3 x)
            {
                bool result;

                if (!x.InBounds(this.map))
                {
                    result = false;
                }
                else if (!x.Standable(this.map))
                {
                    result = false;
                }
                else if (x.Fogged(this.map))
                {
                    result = false;
                }
                else if (this.rectWithMargin.Contains(x))
                {
                    result = false;
                }
                else if ((x.z <= this.rectWithMargin.maxZ || (this.allowedSides & SpectateRectSide.Up) != SpectateRectSide.Up) && (x.x <= this.rectWithMargin.maxX || (this.allowedSides & SpectateRectSide.Right) != SpectateRectSide.Right) && (x.z >= this.rectWithMargin.minZ || (this.allowedSides & SpectateRectSide.Down) != SpectateRectSide.Down) && (x.x >= this.rectWithMargin.minX || (this.allowedSides & SpectateRectSide.Left) != SpectateRectSide.Left))
                {
                    result = false;
                }
                else
                {
                    IntVec3 intVec = this.spectateRect.ClosestCellTo(x);
                    if ((float)intVec.DistanceToSquared(x) > 210.25f)
                    {
                        result = false;
                    }
                    else if (!GenSight.LineOfSight(intVec, x, this.map, true, null, 0, 0))
                    {
                        result = false;
                    }
                    else if (x.GetThingList(this.map).Find((Thing y) => y is Pawn && y != this.p) != null)
                    {
                        result = false;
                    }
                    else
                    {
                        if (this.p != null)
                        {
                            if (!this.p.CanReserveAndReach(x, PathEndMode.OnCell, Danger.Some, 1, -1, null, false))
                            {
                                return(false);
                            }
                            Building edifice = x.GetEdifice(this.map);
                            if (edifice != null && edifice.def.category == ThingCategory.Building && edifice.def.building.isSittable && !this.p.CanReserve(edifice, 1, -1, null, false))
                            {
                                return(false);
                            }
                            if (x.IsForbidden(this.p))
                            {
                                return(false);
                            }
                            if (x.GetDangerFor(this.p, this.map) != Danger.None)
                            {
                                return(false);
                            }
                        }
                        if (this.extraDisallowedCells != null && this.extraDisallowedCells.Contains(x))
                        {
                            result = false;
                        }
                        else
                        {
                            if (!SpectatorCellFinder.CorrectlyRotatedChairAt(x, this.map, this.spectateRect))
                            {
                                int num = 0;
                                for (int i = 0; i < GenAdj.AdjacentCells.Length; i++)
                                {
                                    IntVec3 x2 = x + GenAdj.AdjacentCells[i];
                                    if (SpectatorCellFinder.CorrectlyRotatedChairAt(x2, this.map, this.spectateRect))
                                    {
                                        num++;
                                    }
                                }
                                if (num >= 3)
                                {
                                    return(false);
                                }
                                int num2 = SpectatorCellFinder.DistanceToClosestChair(x, new IntVec3(-1, 0, 0), this.map, 4, this.spectateRect);
                                if (num2 >= 0)
                                {
                                    int num3 = SpectatorCellFinder.DistanceToClosestChair(x, new IntVec3(1, 0, 0), this.map, 4, this.spectateRect);
                                    if (num3 >= 0 && Mathf.Abs(num2 - num3) <= 1)
                                    {
                                        return(false);
                                    }
                                }
                                int num4 = SpectatorCellFinder.DistanceToClosestChair(x, new IntVec3(0, 0, 1), this.map, 4, this.spectateRect);
                                if (num4 >= 0)
                                {
                                    int num5 = SpectatorCellFinder.DistanceToClosestChair(x, new IntVec3(0, 0, -1), this.map, 4, this.spectateRect);
                                    if (num5 >= 0 && Mathf.Abs(num4 - num5) <= 1)
                                    {
                                        return(false);
                                    }
                                }
                            }
                            result = true;
                        }
                    }
                }
                return(result);
            }
Ejemplo n.º 15
0
        private static string TemperatureString()
        {
            IntVec3 intVec = UI.MouseCell();
            IntVec3 c      = intVec;
            Room    room   = intVec.GetRoom(Find.CurrentMap, RegionType.Set_All);

            if (room == null)
            {
                for (int i = 0; i < 9; i++)
                {
                    IntVec3 intVec2 = intVec + GenAdj.AdjacentCellsAndInside[i];
                    if (intVec2.InBounds(Find.CurrentMap))
                    {
                        Room room2 = intVec2.GetRoom(Find.CurrentMap, RegionType.Set_All);
                        if (room2 != null && ((!room2.PsychologicallyOutdoors && !room2.UsesOutdoorTemperature) || (!room2.PsychologicallyOutdoors && (room == null || room.PsychologicallyOutdoors)) || (room2.PsychologicallyOutdoors && room == null)))
                        {
                            c    = intVec2;
                            room = room2;
                        }
                    }
                }
            }
            if (room == null && intVec.InBounds(Find.CurrentMap))
            {
                Building edifice = intVec.GetEdifice(Find.CurrentMap);
                if (edifice != null)
                {
                    foreach (IntVec3 item in edifice.OccupiedRect().ExpandedBy(1).ClipInsideMap(Find.CurrentMap))
                    {
                        room = item.GetRoom(Find.CurrentMap, RegionType.Set_All);
                        if (room != null && !room.PsychologicallyOutdoors)
                        {
                            c = item;
                            break;
                        }
                    }
                }
            }
            string text;

            if (c.InBounds(Find.CurrentMap) && !c.Fogged(Find.CurrentMap) && room != null && !room.PsychologicallyOutdoors)
            {
                if (room.OpenRoofCount == 0)
                {
                    text = "Indoors".Translate();
                }
                else
                {
                    if (indoorsUnroofedStringCachedRoofCount != room.OpenRoofCount)
                    {
                        indoorsUnroofedStringCached          = "IndoorsUnroofed".Translate() + " (" + room.OpenRoofCount.ToStringCached() + ")";
                        indoorsUnroofedStringCachedRoofCount = room.OpenRoofCount;
                    }
                    text = indoorsUnroofedStringCached;
                }
            }
            else
            {
                text = "Outdoors".Translate();
            }
            float num  = ((room == null || c.Fogged(Find.CurrentMap)) ? Find.CurrentMap.mapTemperature.OutdoorTemp : room.Temperature);
            int   num2 = Mathf.RoundToInt(GenTemperature.CelsiusTo(cachedTemperatureStringForTemperature, Prefs.TemperatureMode));
            int   num3 = Mathf.RoundToInt(GenTemperature.CelsiusTo(num, Prefs.TemperatureMode));

            if (cachedTemperatureStringForLabel != text || num2 != num3)
            {
                cachedTemperatureStringForLabel       = text;
                cachedTemperatureStringForTemperature = num;
                cachedTemperatureString = text + " " + num.ToStringTemperature("F0");
            }
            return(cachedTemperatureString);
        }
        private bool TryFindRandomDoorCell(CellRect rect, Rot4 dir, out IntVec3 found)
        {
            var map = BaseGen.globalSettings.map;

            if (dir == Rot4.North)
            {
                if (rect.Width <= 2)
                {
                    found = IntVec3.Invalid;
                    return(false);
                }

                if (!Rand.TryRangeInclusiveWhere(rect.minX + 1, rect.maxX - 1, delegate(int x)
                {
                    var c = new IntVec3(x, 0, rect.maxZ + 1);
                    return(c.InBounds(map) && c.Walkable(map) && !c.Fogged(map));
                }, out var newX))
                {
                    found = IntVec3.Invalid;
                    return(false);
                }

                found = new IntVec3(newX, 0, rect.maxZ);
                return(true);
            }

            if (dir == Rot4.South)
            {
                if (rect.Width <= 2)
                {
                    found = IntVec3.Invalid;
                    return(false);
                }

                if (!Rand.TryRangeInclusiveWhere(rect.minX + 1, rect.maxX - 1, delegate(int x)
                {
                    var c = new IntVec3(x, 0, rect.minZ - 1);
                    return(c.InBounds(map) && c.Walkable(map) && !c.Fogged(map));
                }, out var newX2))
                {
                    found = IntVec3.Invalid;
                    return(false);
                }

                found = new IntVec3(newX2, 0, rect.minZ);
                return(true);
            }

            if (dir == Rot4.West)
            {
                if (rect.Height <= 2)
                {
                    found = IntVec3.Invalid;
                    return(false);
                }

                if (!Rand.TryRangeInclusiveWhere(rect.minZ + 1, rect.maxZ - 1, delegate(int z)
                {
                    var c = new IntVec3(rect.minX - 1, 0, z);
                    return(c.InBounds(map) && c.Walkable(map) && !c.Fogged(map));
                }, out var newZ))
                {
                    found = IntVec3.Invalid;
                    return(false);
                }

                found = new IntVec3(rect.minX, 0, newZ);
                return(true);
            }

            if (rect.Height <= 2)
            {
                found = IntVec3.Invalid;
                return(false);
            }

            if (!Rand.TryRangeInclusiveWhere(rect.minZ + 1, rect.maxZ - 1, delegate(int z)
            {
                var c = new IntVec3(rect.maxX + 1, 0, z);
                return(c.InBounds(map) && c.Walkable(map) && !c.Fogged(map));
            }, out var newZ2))
            {
                found = IntVec3.Invalid;
                return(false);
            }

            found = new IntVec3(rect.maxX, 0, newZ2);
            return(true);
        }
Ejemplo n.º 17
0
        public static bool GetScoreAt(ref float __result, IntVec3 cell, Map map)
        {
            if ((float)(int)distToColonyBuildingField[cell] > 30f)
            {
                __result = 0f;
                return(false);
            }

            if (!cell.Walkable(map))
            {
                __result = 0f;
                return(false);
            }

            if (cell.Fogged(map))
            {
                __result = 0f;
                return(false);
            }

            if (CellHasBlockingThings(cell, map))
            {
                __result = 0f;
                return(false);
            }

            if (!cell.Roofed(map) || !cell.GetRoof(map).isThickRoof)
            {
                __result = 0f;
                return(false);
            }

            Region region = cell.GetRegion(map);

            if (region == null)
            {
                __result = 0f;
                return(false);
            }

            if (closedAreaSizeField[cell] < 2)
            {
                __result = 0f;
                return(false);
            }

            float temperature = cell.GetTemperature(map);

            if (temperature < -17f)
            {
                __result = 0f;
                return(false);
            }

            float mountainousnessScoreAt = GetMountainousnessScoreAt(cell, map);

            if (mountainousnessScoreAt < 0.17f)
            {
                __result = 0f;
                return(false);
            }

            int   num   = StraightLineDistToUnroofed(cell, map);
            float value = regionsDistanceToUnroofedField.TryGetValue(region, out value) ? Mathf.Min(value, (float)num * 4f) : ((float)num * 1.15f);

            value = Mathf.Pow(value, 1.55f);
            float num2 = Mathf.InverseLerp(0f, 12f, num);
            float num3 = Mathf.Lerp(1f, 0.18f, map.glowGrid.GameGlowAt(cell));
            float num4 = 1f - Mathf.Clamp(DistToBlocker(cell, map) / 11f, 0f, 0.6f);
            float num5 = Mathf.InverseLerp(-17f, -7f, temperature);
            float f    = value * num2 * num4 * mountainousnessScoreAt * num3 * num5;

            f = Mathf.Pow(f, 1.2f);
            if (f < 7.5f)
            {
                __result = 0f;
                return(false);
            }

            __result = f;
            return(false);
        }
Ejemplo n.º 18
0
        private static float GetScoreAt(IntVec3 cell, Map map)
        {
            if ((float)InfestationCellFinder.distToColonyBuilding[cell] > 30f)
            {
                return(0f);
            }
            if (!cell.Standable(map))
            {
                return(0f);
            }
            if (cell.Fogged(map))
            {
                return(0f);
            }
            if (InfestationCellFinder.CellHasBlockingThings(cell, map))
            {
                return(0f);
            }
            if (!cell.Roofed(map) || !cell.GetRoof(map).isThickRoof)
            {
                return(0f);
            }
            Region region = cell.GetRegion(map, RegionType.Set_Passable);

            if (region == null)
            {
                return(0f);
            }
            if (InfestationCellFinder.closedAreaSize[cell] < 16)
            {
                return(0f);
            }
            float temperature = cell.GetTemperature(map);

            if (temperature < -17f)
            {
                return(0f);
            }
            float mountainousnessScoreAt = InfestationCellFinder.GetMountainousnessScoreAt(cell, map);

            if (mountainousnessScoreAt < 0.17f)
            {
                return(0f);
            }
            int   num = InfestationCellFinder.StraightLineDistToUnroofed(cell, map);
            float num2;

            if (!InfestationCellFinder.regionsDistanceToUnroofed.TryGetValue(region, out num2))
            {
                num2 = (float)num * 1.15f;
            }
            else
            {
                num2 = Mathf.Min(num2, (float)num * 4f);
            }
            num2 = Mathf.Pow(num2, 1.55f);
            float num3 = Mathf.InverseLerp(0f, 12f, (float)num);
            float num4 = Mathf.Lerp(1f, 0.18f, map.glowGrid.GameGlowAt(cell, false));
            float num5 = 1f - Mathf.Clamp(InfestationCellFinder.DistToBlocker(cell, map) / 11f, 0f, 0.6f);
            float num6 = Mathf.InverseLerp(-17f, -7f, temperature);
            float num7 = num2 * num3 * num5 * mountainousnessScoreAt * num4 * num6;

            num7 = Mathf.Pow(num7, 1.2f);
            if (num7 < 7.5f)
            {
                return(0f);
            }
            return(num7);
        }
Ejemplo n.º 19
0
        private static string TemperatureString()
        {
            IntVec3 intVec = UI.MouseCell();
            IntVec3 c      = intVec;
            Room    room   = intVec.GetRoom(Find.VisibleMap, RegionType.Set_All);

            if (room == null)
            {
                for (int i = 0; i < 9; i++)
                {
                    IntVec3 intVec2 = intVec + GenAdj.AdjacentCellsAndInside[i];
                    Room    room2;
                    if (intVec2.InBounds(Find.VisibleMap))
                    {
                        room2 = intVec2.GetRoom(Find.VisibleMap, RegionType.Set_All);
                        if (room2 != null)
                        {
                            if (!room2.PsychologicallyOutdoors && !room2.UsesOutdoorTemperature)
                            {
                                goto IL_00a8;
                            }
                            if (!room2.PsychologicallyOutdoors && (room == null || room.PsychologicallyOutdoors))
                            {
                                goto IL_00a8;
                            }
                            if (room2.PsychologicallyOutdoors && room == null)
                            {
                                goto IL_00a8;
                            }
                        }
                    }
                    continue;
IL_00a8:
                    c    = intVec2;
                    room = room2;
                }
            }
            if (room == null && intVec.InBounds(Find.VisibleMap))
            {
                Building edifice = intVec.GetEdifice(Find.VisibleMap);
                if (edifice != null)
                {
                    CellRect.CellRectIterator iterator = edifice.OccupiedRect().ExpandedBy(1).ClipInsideMap(Find.VisibleMap)
                                                         .GetIterator();
                    while (!iterator.Done())
                    {
                        IntVec3 current = iterator.Current;
                        room = current.GetRoom(Find.VisibleMap, RegionType.Set_All);
                        if (room != null && !room.PsychologicallyOutdoors)
                        {
                            c = current;
                            break;
                        }
                        iterator.MoveNext();
                    }
                }
            }
            string str         = (!c.InBounds(Find.VisibleMap) || c.Fogged(Find.VisibleMap) || room == null || room.PsychologicallyOutdoors) ? "Outdoors".Translate() : ((room.OpenRoofCount != 0) ? ("IndoorsUnroofed".Translate() + " (" + room.OpenRoofCount.ToStringCached() + ")") : "Indoors".Translate());
            float  celsiusTemp = (room != null && !c.Fogged(Find.VisibleMap)) ? room.Temperature : Find.VisibleMap.mapTemperature.OutdoorTemp;

            return(str + " " + celsiusTemp.ToStringTemperature("F0"));
        }
Ejemplo n.º 20
0
        public static IntVec3 RandomSpawnCellForPawnNear(IntVec3 root, Map map, Pawn pawn, Predicate <IntVec3> validator, bool waterEntry = false, int firstTryWithRadius = 4)
        {
            if (!(pawn is VehiclePawn vehicle))
            {
                return(root);
            }
            if (validator(root) && root.GetFirstPawn(map) is null && vehicle.CellRectStandable(map, root))
            {
                return(root);
            }

            IntVec3 result;
            int     num = firstTryWithRadius;

            for (int i = 0; i < 3; i++)
            {
                if (waterEntry)
                {
                    if (TryFindRandomReachableCellNear(root, map, num, TraverseParms.For(TraverseMode.NoPassClosedDoors, Danger.Deadly, false),
                                                       (IntVec3 c) => validator(c) && vehicle.CellRectStandable(map, c) && (root.Fogged(map) || !c.Fogged(map)) && c.GetFirstPawn(map) is null, null, out result, 999999))
                    {
                        return(result);
                    }
                }
                else
                {
                    if (CellFinder.TryFindRandomReachableCellNear(root, map, num, TraverseParms.For(TraverseMode.NoPassClosedDoors, Danger.Deadly, false),
                                                                  (IntVec3 c) => validator(c) && vehicle.CellRectStandable(map, c) && (root.Fogged(map) || !c.Fogged(map)) && c.GetFirstPawn(map) is null, null, out result, 999999))
                    {
                        return(result);
                    }
                }

                num *= 2;
            }
            num = firstTryWithRadius + 1;

            while (!TryRandomClosewalkCellNear(root, map, num, out result, null))
            {
                if (num > map.Size.x / 2 && num > map.Size.z / 2)
                {
                    return(root);
                }
                num *= 2;
            }
            return(result);
        }
Ejemplo n.º 21
0
        private static float GetScoreAt(IntVec3 cell, Map map, HiveDefExtension HiveExt)
        {
            float minTemp = HiveExt.minTemp ?? 17f;
            float maxTemp = HiveExt.maxTemp ?? 40f;

            if ((float)(int)distToColonyBuilding[cell] > HiveExt.maxColonyDistance && HiveExt.mustBeNearColony)
            {
                return(0f);
            }
            if ((float)(int)distToColonyBuilding[cell] < HiveExt.minColonyDistance)
            {
                return(0f);
            }
            if (!cell.Walkable(map) && HiveExt.mustBeWalkable)
            {
                return(0f);
            }
            if (cell.Fogged(map) && HiveExt.mustBeVisable)
            {
                return(0f);
            }
            if (CellHasBlockingThings(cell, map))
            {
                return(0f);
            }
            if (HiveExt.requiresRoofed)
            {
                if (!cell.Roofed(map))
                {
                    return(0f);
                }
                else
                {
                    if (HiveExt.mustBeThickRoof && !cell.GetRoof(map).isThickRoof)
                    {
                        return(0f);
                    }
                }
            }
            Region region = cell.GetRegion(map);

            if (region == null)
            {
                return(0f);
            }
            if (closedAreaSize[cell] < HiveExt.minClosedAreaSize)
            {
                return(0f);
            }
            float temperature = cell.GetTemperature(map);

            if (temperature < minTemp)
            {
                return(0f);
            }
            if (temperature > maxTemp)
            {
                return(0f);
            }
            float temperatureBonus = 0f;

            if (HiveExt.bonusTempScore != 0)
            {
                if (HiveExt.bonusAboveTemp.HasValue && temperature > HiveExt.bonusAboveTemp.Value)
                {
                    temperatureBonus = HiveExt.bonusTempScore;
                }
                if (HiveExt.bonusBelowTemp.HasValue && temperature < HiveExt.bonusBelowTemp.Value)
                {
                    temperatureBonus = HiveExt.bonusTempScore;
                }
            }
            float mountainousnessScoreAt = GetMountainousnessScoreAt(cell, map);

            if (HiveExt.minMountainouseness == 0)
            {
                mountainousnessScoreAt = 1f;
            }
            else
            {
                if (mountainousnessScoreAt < HiveExt.minMountainouseness)
                {
                    return(0f);
                }
            }
            int   num   = StraightLineDistToUnroofed(cell, map);
            float value = regionsDistanceToUnroofed.TryGetValue(region, out value) ? Mathf.Min(value, (float)num * 4f) : ((float)num * 1.15f);

            value = Mathf.Pow(value, 1.55f);
            float num2 = Mathf.InverseLerp(0f, 12f, num);
            float num3 = Mathf.Lerp(1f, 0.18f, map.glowGrid.GameGlowAt(cell));
            float num4 = 1f - Mathf.Clamp(DistToBlocker(cell, map) / 11f, 0f, 0.6f);
            float num5 = Mathf.InverseLerp(-17f, -7f, temperature);
            float f    = value * num2 * num4 * mountainousnessScoreAt * num3 * num5;

            f = Mathf.Pow(f, 1.2f);
            if (f < 7.5f)
            {
                return(0f);
            }
            return(f);
        }
Ejemplo n.º 22
0
 public override AcceptanceReport CanDesignateCell(IntVec3 loc) =>
 loc.InBounds(Map) && (DebugSettings.godMode || !loc.Fogged(Map)) && DestructibleInCell(loc) != null;
        // Token: 0x060000E2 RID: 226 RVA: 0x000071D4 File Offset: 0x000053D4
        public static AcceptanceReport CanPlaceBlueprintAt(BuildableDef entDef, IntVec3 center, Rot4 rot, Map map, bool godMode = false, Thing thingToIgnore = null, Thing thing = null, ThingDef stuffDef = null)
        {
            CellRect cellRect = GenAdj.OccupiedRect(center, rot, entDef.Size);
            bool     flag     = stuffDef == null && thing != null;

            if (flag)
            {
                stuffDef = thing.Stuff;
            }
            foreach (IntVec3 c in cellRect)
            {
                bool flag2 = !c.InBounds(map);
                if (flag2)
                {
                    return(new AcceptanceReport("OutOfBounds".Translate()));
                }
                bool flag3 = c.InNoBuildEdgeArea(map) && !godMode;
                if (flag3)
                {
                    return("TooCloseToMapEdge".Translate());
                }
            }
            bool             flag4 = center.Fogged(map);
            AcceptanceReport result;

            if (flag4)
            {
                result = "CannotPlaceInUndiscovered".Translate();
            }
            else
            {
                List <Thing> thingList = center.GetThingList(map);
                for (int i = 0; i < thingList.Count; i++)
                {
                    Thing thing2 = thingList[i];
                    bool  flag5  = thing2 != thingToIgnore && thing2.Position == center && thing2.Rotation == rot;
                    if (flag5)
                    {
                        bool flag6 = thing2.def == entDef;
                        if (flag6)
                        {
                            return(new AcceptanceReport("IdenticalThingExists".Translate()));
                        }
                        bool flag7 = thing2.def.entityDefToBuild == entDef;
                        if (flag7)
                        {
                            bool flag8 = thing2 is Blueprint;
                            if (flag8)
                            {
                                return(new AcceptanceReport("IdenticalBlueprintExists".Translate()));
                            }
                            return(new AcceptanceReport("IdenticalThingExists".Translate()));
                        }
                    }
                }
                ThingDef thingDef = entDef as ThingDef;
                bool     flag9    = thingDef != null && thingDef.hasInteractionCell;
                if (flag9)
                {
                    IntVec3 c2     = ThingUtility.InteractionCellWhenAt(thingDef, center, rot, map);
                    bool    flag10 = !c2.InBounds(map);
                    if (flag10)
                    {
                        return(new AcceptanceReport("InteractionSpotOutOfBounds".Translate()));
                    }
                    List <Thing> list = map.thingGrid.ThingsListAtFast(c2);
                    for (int j = 0; j < list.Count; j++)
                    {
                        bool flag11 = list[j] != thingToIgnore;
                        if (flag11)
                        {
                            bool flag12 = list[j].def.passability == Traversability.Impassable || list[j].def == thingDef;
                            if (flag12)
                            {
                                return(new AcceptanceReport("InteractionSpotBlocked".Translate(list[j].LabelNoCount, list[j]).CapitalizeFirst()));
                            }
                            BuildableDef entityDefToBuild = list[j].def.entityDefToBuild;
                            bool         flag13           = entityDefToBuild != null && (entityDefToBuild.passability == Traversability.Impassable || entityDefToBuild == thingDef);
                            if (flag13)
                            {
                                return(new AcceptanceReport("InteractionSpotWillBeBlocked".Translate(list[j].LabelNoCount, list[j]).CapitalizeFirst()));
                            }
                        }
                    }
                }
                foreach (IntVec3 c3 in GenAdj.CellsAdjacentCardinal(center, rot, entDef.Size))
                {
                    bool flag14 = c3.InBounds(map);
                    if (flag14)
                    {
                        thingList = c3.GetThingList(map);
                        for (int k = 0; k < thingList.Count; k++)
                        {
                            Thing thing3 = thingList[k];
                            bool  flag15 = thing3 != thingToIgnore;
                            if (flag15)
                            {
                                Blueprint blueprint = thing3 as Blueprint;
                                bool      flag16    = blueprint != null;
                                ThingDef  thingDef3;
                                if (flag16)
                                {
                                    ThingDef thingDef2 = blueprint.def.entityDefToBuild as ThingDef;
                                    bool     flag17    = thingDef2 == null;
                                    if (flag17)
                                    {
                                        goto IL_48F;
                                    }
                                    thingDef3 = thingDef2;
                                }
                                else
                                {
                                    thingDef3 = thing3.def;
                                }
                                bool flag18 = thingDef3.hasInteractionCell && (entDef.passability == Traversability.Impassable || entDef == thingDef3) && cellRect.Contains(ThingUtility.InteractionCellWhenAt(thingDef3, thing3.Position, thing3.Rotation, thing3.Map));
                                if (flag18)
                                {
                                    return(new AcceptanceReport("WouldBlockInteractionSpot".Translate(entDef.label, thingDef3.label).CapitalizeFirst()));
                                }
                            }
                            IL_48F :;
                        }
                    }
                }
                TerrainDef terrainDef = entDef as TerrainDef;
                bool       flag19     = terrainDef != null;
                if (flag19)
                {
                    bool flag20 = map.terrainGrid.TerrainAt(center) == terrainDef;
                    if (flag20)
                    {
                        return(new AcceptanceReport("TerrainIsAlready".Translate(terrainDef.label)));
                    }
                    bool flag21 = map.designationManager.DesignationAt(center, DesignationDefOf.SmoothFloor) != null;
                    if (flag21)
                    {
                        return(new AcceptanceReport("SpaceBeingSmoothed".Translate()));
                    }
                }
                bool flag22 = WPGenConstruct.CanBuildOnTerrain(entDef, center, map, rot, thingToIgnore, stuffDef);
                if (flag22)
                {
                    bool flag23 = !godMode;
                    if (flag23)
                    {
                        foreach (IntVec3 c4 in cellRect)
                        {
                            thingList = c4.GetThingList(map);
                            for (int l = 0; l < thingList.Count; l++)
                            {
                                Thing thing4 = thingList[l];
                                bool  flag24 = thing4 != thingToIgnore && !WPGenConstruct.CanPlaceBlueprintOver(entDef, thing4.def);
                                if (flag24)
                                {
                                    return(new AcceptanceReport("SpaceAlreadyOccupied".Translate()));
                                }
                            }
                        }
                    }
                    bool flag25 = entDef.PlaceWorkers != null;
                    if (flag25)
                    {
                        for (int m = 0; m < entDef.PlaceWorkers.Count; m++)
                        {
                            AcceptanceReport result2 = entDef.PlaceWorkers[m].AllowsPlacing(entDef, center, rot, map, thingToIgnore, thing);
                            bool             flag26  = !result2.Accepted;
                            if (flag26)
                            {
                                return(result2);
                            }
                        }
                    }
                    result = AcceptanceReport.WasAccepted;
                }
                else
                {
                    bool flag27 = entDef.GetTerrainAffordanceNeed(stuffDef) == null;
                    if (flag27)
                    {
                        result = new AcceptanceReport("TerrainCannotSupport".Translate(entDef).CapitalizeFirst());
                    }
                    else
                    {
                        bool flag28 = entDef.useStuffTerrainAffordance && stuffDef != null;
                        if (flag28)
                        {
                            result = new AcceptanceReport("TerrainCannotSupport_TerrainAffordanceFromStuff".Translate(entDef, entDef.GetTerrainAffordanceNeed(stuffDef), stuffDef).CapitalizeFirst());
                        }
                        else
                        {
                            result = new AcceptanceReport("TerrainCannotSupport_TerrainAffordance".Translate(entDef, entDef.GetTerrainAffordanceNeed(stuffDef)).CapitalizeFirst());
                        }
                    }
                }
            }
            return(result);
        }
Ejemplo n.º 24
0
        public static IntVec3 RandomSpawnCellForPawnNear(IntVec3 root, Map map, int firstTryWithRadius = 4)
        {
            MapExtension mapE = MapExtensionUtility.GetExtensionToMap(map);

            if (GenGridShips.Standable(root, map, mapE) && root.GetFirstPawn(map) is null)
            {
                return(root);
            }
            IntVec3 result;
            int     num = firstTryWithRadius;

            for (int i = 0; i < 3; i++)
            {
                if (CellFinderExtended.TryFindRandomReachableCellNear(root, map, (float)num, TraverseParms.For(TraverseMode.NoPassClosedDoors, Danger.Deadly, false), (IntVec3 c)
                                                                      => GenGridShips.Standable(c, map, mapE) && (root.Fogged(map) || !c.Fogged(map)) && c.GetFirstPawn(map) is null, out result, null, 999999))
                {
                    return(result);
                }
                num *= 2;
            }
            num = firstTryWithRadius + 1;

            while (!CellFinderExtended.TryRandomClosewalkCellNear(root, map, num, out result, null))
            {
                if (num > map.Size.x / 2 && num > map.Size.z / 2)
                {
                    return(root);
                }
                num *= 2;
            }
            return(result);
        }
        protected override void Impact(Thing hitThing)
        {
            Map map = base.Map;

            GenClamor.DoClamor(this, 5.1f, ClamorDefOf.Impact);
            if (initialized)
            {
                Destroy();
            }

            if (!initialized)
            {
                this.initialized = true;
                SpawnThings spawnThing = new SpawnThings();
                pawn = this.launcher as Pawn;
                MagicPowerSkill        pwr         = pawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_SummonPoppi.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_SummonPoppi_pwr");
                MagicPowerSkill        ver         = pawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_SummonPoppi.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_SummonPoppi_ver");
                ModOptions.SettingsRef settingsRef = new ModOptions.SettingsRef();
                pwrVal         = pwr.level;
                verVal         = ver.level;
                this.arcaneDmg = pawn.GetComp <CompAbilityUserMagic>().arcaneDmg;
                if (settingsRef.AIHardMode && !pawn.IsColonist)
                {
                    pwrVal = 1;
                    verVal = 1;
                }
                CellRect cellRect = CellRect.CenteredOn(this.Position, 4);
                cellRect.ClipInsideMap(map);

                IntVec3       centerCell = cellRect.CenterCell;
                System.Random random     = new System.Random();
                random = new System.Random();

                for (int i = 0; i < 4 + pwrVal; i++)
                {
                    centerCell = cellRect.RandomCell;
                    if (centerCell.IsValid && centerCell.InBounds(pawn.Map) && centerCell.Standable(pawn.Map) && !centerCell.Fogged(pawn.Map))
                    {
                        spawnThing.factionDef = TorannMagicDefOf.TM_ElementalFaction;
                        spawnThing.spawnCount = 1;
                        spawnThing.temporary  = false;

                        spawnThing.def     = TorannMagicDefOf.TM_Poppi;
                        spawnThing.kindDef = PawnKindDef.Named("TM_Poppi");

                        MoteMaker.ThrowSmoke(centerCell.ToVector3(), map, 1 + pwrVal);
                        SingleSpawnLoop(spawnThing, centerCell, map);
                    }
                    else
                    {
                        i--;
                    }
                }
            }
        }
 public List<Thing> CryptoAnimalsInCell(IntVec3 loc)
 {
     List<Thing> list = new List<Thing>();
     if (loc.Fogged())
     {
         return list;
     }
     else
     {
         list.AddRange(loc.GetThingList().Where(t => CanDesignateThing(t).Accepted));
         return list;
     }
 }
Ejemplo n.º 27
0
        public static bool MouseoverReadoutOnGUI(MouseoverReadout __instance)
        {
            IntVec3 c = UI.MouseCell();

            if (!c.InBounds(Find.CurrentMap) ||
                Event.current.type != EventType.Repaint ||
                Find.MainTabsRoot.OpenTab != null)
            {
                return(false);
            }

            if (Find.CurrentMap.GetComponent <MapComponent_FertilityMods>().Get is MapComponent_FertilityMods fert &&
                fert.ActiveCells.Contains(c))
            {
                //Original Variables
                Vector2 BotLeft = new Vector2(15f, 65f);

                GenUI.DrawTextWinterShadow(new Rect(256f, (float)(UI.screenHeight - 256), -256f, 256f));
                Text.Font = GameFont.Small;
                GUI.color = new Color(1f, 1f, 1f, 0.8f);

                float num = 0f;
                Rect  rect;
                if (c.Fogged(Find.CurrentMap))
                {
                    rect = new Rect(BotLeft.x, (float)UI.screenHeight - BotLeft.y - num, 999f, 999f);
                    Widgets.Label(rect, "Undiscovered".Translate());
                    GUI.color = Color.white;
                    return(false);
                }
                rect = new Rect(BotLeft.x, (float)UI.screenHeight - BotLeft.y - num, 999f, 999f);
                int      num2        = Mathf.RoundToInt(Find.CurrentMap.glowGrid.GameGlowAt(c) * 100f);
                string[] glowStrings = Traverse.Create(__instance).Field("glowStrings").GetValue <string[]>();
                Widgets.Label(rect, glowStrings[num2]);
                num += 19f;
                rect = new Rect(BotLeft.x, (float)UI.screenHeight - BotLeft.y - num, 999f, 999f);
                TerrainDef terrain = c.GetTerrain(Find.CurrentMap);
                //string SpeedPercentString = Traverse.Create(__instance).Method("SpeedPercentString", (float)terrain.pathCost).GetValue<string>();
                //TerrainDef cachedTerrain = Traverse.Create(__instance).Field("cachedTerrain").GetValue<TerrainDef>();
                string cachedTerrainString =
                    Traverse.Create(__instance).Field("cachedTerrainString").GetValue <string>();

                //if (terrain != cachedTerrain)
                //{
                float  fertNum = Find.CurrentMap.fertilityGrid.FertilityAt(c);
                string str     = (fertNum <= 0.0001)
                    ? TaggedString.Empty
                    : (" " + "FertShort".Translate() + " " + fertNum.ToStringPercent());
                cachedTerrainString = terrain.LabelCap + ((terrain.passability == Traversability.Impassable)
                                          ? null
                                          : (" (" + "WalkSpeed".Translate(SpeedPercentString((float)terrain.pathCost) + str + ")")));
                //cachedTerrain = terrain;
                //}
                Widgets.Label(rect, cachedTerrainString);
                num += 19f;
                Zone zone = c.GetZone(Find.CurrentMap);
                if (zone != null)
                {
                    rect = new Rect(BotLeft.x, (float)UI.screenHeight - BotLeft.y - num, 999f, 999f);
                    string label = zone.label;
                    Widgets.Label(rect, label);
                    num += 19f;
                }
                float depth = Find.CurrentMap.snowGrid.GetDepth(c);
                if (depth > 0.03f)
                {
                    rect = new Rect(BotLeft.x, (float)UI.screenHeight - BotLeft.y - num, 999f, 999f);
                    SnowCategory snowCategory = SnowUtility.GetSnowCategory(depth);
                    string       label2       = SnowUtility.GetDescription(snowCategory) +
                                                " (" +
                                                "WalkSpeed".Translate(SpeedPercentString((float)SnowUtility.MovementTicksAddOn(snowCategory))) +
                                                ")";
                    Widgets.Label(rect, label2);
                    num += 19f;
                }
                List <Thing> thingList = c.GetThingList(Find.CurrentMap);
                for (int i = 0; i < thingList.Count; i++)
                {
                    Thing thing = thingList[i];
                    if (thing.def.category != ThingCategory.Mote)
                    {
                        rect = new Rect(BotLeft.x, (float)UI.screenHeight - BotLeft.y - num, 999f, 999f);
                        string labelMouseover = thing.LabelMouseover;
                        Widgets.Label(rect, labelMouseover);
                        num += 19f;
                    }
                }
                RoofDef roof = c.GetRoof(Find.CurrentMap);
                if (roof != null)
                {
                    rect = new Rect(BotLeft.x, (float)UI.screenHeight - BotLeft.y - num, 999f, 999f);
                    Widgets.Label(rect, roof.LabelCap);
                    num += 19f;
                }
                GUI.color = Color.white;
                return(false);
            }
            return(true);
        }
        public bool IsValidPositionForShipCrashSite(IntVec3 position)
        {
            ThingDef chunkDef = ThingDefOf.ShipChunk;
            if ((position.InBounds() == false)
                || position.Fogged())
            {
                return false;
            }
			foreach (IntVec3 chckedPosition in GenAdj.CellsOccupiedBy(position, Rot4.North, this.def.shipPart.size))
			{
				if ((chckedPosition.Standable() == false)
                    || chckedPosition.Roofed()
                    || chckedPosition.CanReachColony() == false)
				{
					return false;
				}
			}
            return true;
        }
Ejemplo n.º 29
0
 internal bool <> m__0(IntVec3 x)
 {
     return(x.Standable(this.map) && !x.Fogged(this.map) && this.map.reachability.CanReachMapEdge(x, this.traverseParams) && x.GetRoom(this.map, RegionType.Set_Passable).CellCount >= this.$this.MinRoomCells);
 }
Ejemplo n.º 30
0
        protected override void Impact(Thing hitThing)
        {
            if (!this.initialized)
            {
                base.Impact(hitThing);
                this.initialized = true;
                this.BF          = new List <BloodFire>();
                this.BF.Clear();
                ModOptions.SettingsRef settingsRef = new ModOptions.SettingsRef();
                Pawn pawn = this.launcher as Pawn;
                CompAbilityUserMagic comp = pawn.GetComp <CompAbilityUserMagic>();
                MagicPowerSkill      bpwr = pawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_BloodGift.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_BloodGift_pwr");
                MagicPowerSkill      pwr  = pawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_IgniteBlood.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_IgniteBlood_pwr");
                MagicPowerSkill      ver  = pawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_IgniteBlood.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_IgniteBlood_ver");
                pwrVal = pwr.level;
                verVal = ver.level;
                if (pawn.story.traits.HasTrait(TorannMagicDefOf.Faceless))
                {
                    MightPowerSkill mpwr = pawn.GetComp <CompAbilityUserMight>().MightData.MightPowerSkill_Mimic.FirstOrDefault((MightPowerSkill x) => x.label == "TM_Mimic_pwr");
                    MightPowerSkill mver = pawn.GetComp <CompAbilityUserMight>().MightData.MightPowerSkill_Mimic.FirstOrDefault((MightPowerSkill x) => x.label == "TM_Mimic_ver");
                    pwrVal = mpwr.level;
                    verVal = mver.level;
                }
                this.arcaneDmg   = comp.arcaneDmg;
                this.arcaneDmg  *= (1 + (.1f * bpwr.level));
                this.spreadRate -= 2 * verVal;
                if (settingsRef.AIHardMode && !pawn.IsColonist)
                {
                    pwrVal = 3;
                    verVal = 3;
                }
                this.bloodTypes = new List <ThingDef>();
                this.bloodTypes.Clear();
                if (settingsRef.unrestrictedBloodTypes)
                {
                    this.pawnBloodDef = pawn.RaceProps.BloodDef;
                    this.bloodTypes   = TM_Calc.GetAllRaceBloodTypes();
                }
                else
                {
                    this.pawnBloodDef = ThingDefOf.Filth_Blood;
                    this.bloodTypes.Add(this.pawnBloodDef);
                }

                List <IntVec3> cellList = GenRadial.RadialCellsAround(base.Position, this.def.projectile.explosionRadius, true).ToList();

                Filth filth = (Filth)ThingMaker.MakeThing(this.pawnBloodDef);
                GenSpawn.Spawn(filth, base.Position, pawn.Map);
                //FilthMaker.MakeFilth(base.Position, this.Map, ThingDefOf.Filth_Blood, 1);
                for (int i = 0; i < 30; i++)
                {
                    IntVec3 randomCell = cellList.RandomElement();
                    if (randomCell.IsValid && randomCell.InBounds(pawn.Map) && !randomCell.Fogged(pawn.Map) && randomCell.Walkable(pawn.Map))
                    {
                        //FilthMaker.MakeFilth(randomCell, this.Map, ThingDefOf.Filth_Blood, 1);
                        //Log.Message("creating blood at " + randomCell);
                        Filth filth2 = (Filth)ThingMaker.MakeThing(this.pawnBloodDef);
                        GenSpawn.Spawn(filth2, randomCell, pawn.Map);
                    }
                }
                this.BF.Add(new BloodFire(base.Position, 0));
            }

            if (this.age > 0 && Find.TickManager.TicksGame % this.spreadRate == 0)
            {
                BurnBloodAtCell();
                FindNearbyBloodCells();
            }

            if (this.BF.Count <= 0)
            {
                this.age = this.duration;
            }

            if (this.age >= this.duration)
            {
                this.Destroy(DestroyMode.Vanish);
            }
        }
Ejemplo n.º 31
0
 public static void GetWanderRoot_PostFix(JobGiver_WanderColony __instance, Pawn pawn, ref IntVec3 __result)
 {
     if (Find.Scenario.name == "Resident Evil")
     {
         if (pawn is Zombie)
         {
             return;
         }
         if (pawn.Spawned)
         {
             var map             = pawn.Map;
             var ZombieDangerMap = map.GetComponent <ZombieDangerMap>();
             if (!ZombieDangerMap.regionDangers.ContainsKey(__result.GetRegion(map)))
             {
                 ZombieDangerMap.regionDangers.Add(__result.GetRegion(map), 1000);
             }
             if (ZombieDangerMap.regionDangers[__result.GetRegion(map)] > 0 || __result.Fogged(map))
             {
                 __result = pawn.GetRegion().Cells.InRandomOrder().First(x => x.Standable(map));
             }
         }
     }
 }
 private bool <DoAction> m__0(IntVec3 x)
 {
     return(x.Standable(base.Map) && !x.Fogged(base.Map) && base.Map.reachability.CanReachColony(x));
 }
Ejemplo n.º 33
0
        public static AcceptanceReport CanPlaceBlueprintAt(BuildableDef entDef, IntVec3 center, Rot4 rot, Map map, bool godMode = false, Thing thingToIgnore = null, Thing thing = null, ThingDef stuffDef = null)
        {
            CellRect cellRect = GenAdj.OccupiedRect(center, rot, entDef.Size);

            if (stuffDef == null && thing != null)
            {
                stuffDef = thing.Stuff;
            }
            foreach (IntVec3 item in cellRect)
            {
                if (!item.InBounds(map))
                {
                    return(new AcceptanceReport("OutOfBounds".Translate()));
                }
                if (item.InNoBuildEdgeArea(map) && !godMode)
                {
                    return("TooCloseToMapEdge".Translate());
                }
            }
            if (center.Fogged(map))
            {
                return("CannotPlaceInUndiscovered".Translate());
            }
            List <Thing> thingList = center.GetThingList(map);

            for (int i = 0; i < thingList.Count; i++)
            {
                Thing thing2 = thingList[i];
                if (thing2 == thingToIgnore || !(thing2.Position == center) || !(thing2.Rotation == rot))
                {
                    continue;
                }
                if (thing2.def == entDef)
                {
                    return(new AcceptanceReport("IdenticalThingExists".Translate()));
                }
                if (thing2.def.entityDefToBuild == entDef)
                {
                    if (thing2 is Blueprint)
                    {
                        return(new AcceptanceReport("IdenticalBlueprintExists".Translate()));
                    }
                    return(new AcceptanceReport("IdenticalThingExists".Translate()));
                }
            }
            ThingDef thingDef = entDef as ThingDef;

            if (thingDef != null && thingDef.hasInteractionCell)
            {
                IntVec3 c = ThingUtility.InteractionCellWhenAt(thingDef, center, rot, map);
                if (!c.InBounds(map))
                {
                    return(new AcceptanceReport("InteractionSpotOutOfBounds".Translate()));
                }
                List <Thing> list = map.thingGrid.ThingsListAtFast(c);
                for (int j = 0; j < list.Count; j++)
                {
                    if (list[j] != thingToIgnore)
                    {
                        if (list[j].def.passability == Traversability.Impassable || list[j].def == thingDef)
                        {
                            return(new AcceptanceReport("InteractionSpotBlocked".Translate(list[j].LabelNoCount, list[j]).CapitalizeFirst()));
                        }
                        BuildableDef entityDefToBuild = list[j].def.entityDefToBuild;
                        if (entityDefToBuild != null && (entityDefToBuild.passability == Traversability.Impassable || entityDefToBuild == thingDef))
                        {
                            return(new AcceptanceReport("InteractionSpotWillBeBlocked".Translate(list[j].LabelNoCount, list[j]).CapitalizeFirst()));
                        }
                    }
                }
            }
            foreach (IntVec3 item2 in GenAdj.CellsAdjacentCardinal(center, rot, entDef.Size))
            {
                if (!item2.InBounds(map))
                {
                    continue;
                }
                thingList = item2.GetThingList(map);
                for (int k = 0; k < thingList.Count; k++)
                {
                    Thing thing3 = thingList[k];
                    if (thing3 == thingToIgnore)
                    {
                        continue;
                    }
                    ThingDef  thingDef2 = null;
                    Blueprint blueprint = thing3 as Blueprint;
                    if (blueprint != null)
                    {
                        ThingDef thingDef3 = blueprint.def.entityDefToBuild as ThingDef;
                        if (thingDef3 == null)
                        {
                            continue;
                        }
                        thingDef2 = thingDef3;
                    }
                    else
                    {
                        thingDef2 = thing3.def;
                    }
                    if (thingDef2.hasInteractionCell && (entDef.passability == Traversability.Impassable || entDef == thingDef2) && cellRect.Contains(ThingUtility.InteractionCellWhenAt(thingDef2, thing3.Position, thing3.Rotation, thing3.Map)))
                    {
                        return(new AcceptanceReport("WouldBlockInteractionSpot".Translate(entDef.label, thingDef2.label).CapitalizeFirst()));
                    }
                }
            }
            TerrainDef terrainDef = entDef as TerrainDef;

            if (terrainDef != null)
            {
                if (map.terrainGrid.TerrainAt(center) == terrainDef)
                {
                    return(new AcceptanceReport("TerrainIsAlready".Translate(terrainDef.label)));
                }
                if (map.designationManager.DesignationAt(center, DesignationDefOf.SmoothFloor) != null)
                {
                    return(new AcceptanceReport("SpaceBeingSmoothed".Translate()));
                }
            }
            if (!CanBuildOnTerrain(entDef, center, map, rot, thingToIgnore, stuffDef))
            {
                if (entDef.GetTerrainAffordanceNeed(stuffDef) != null)
                {
                    if (entDef.useStuffTerrainAffordance && stuffDef != null)
                    {
                        return(new AcceptanceReport("TerrainCannotSupport_TerrainAffordanceFromStuff".Translate(entDef, entDef.GetTerrainAffordanceNeed(stuffDef), stuffDef).CapitalizeFirst()));
                    }
                    return(new AcceptanceReport("TerrainCannotSupport_TerrainAffordance".Translate(entDef, entDef.GetTerrainAffordanceNeed(stuffDef)).CapitalizeFirst()));
                }
                return(new AcceptanceReport("TerrainCannotSupport".Translate(entDef).CapitalizeFirst()));
            }
            if (ModsConfig.RoyaltyActive)
            {
                List <Thing> list2 = map.listerThings.ThingsOfDef(ThingDefOf.MonumentMarker);
                for (int l = 0; l < list2.Count; l++)
                {
                    MonumentMarker monumentMarker = (MonumentMarker)list2[l];
                    if (!monumentMarker.complete && !monumentMarker.AllowsPlacingBlueprint(entDef, center, rot, stuffDef))
                    {
                        return(new AcceptanceReport("BlueprintWouldCollideWithMonument".Translate()));
                    }
                }
            }
            if (!godMode)
            {
                foreach (IntVec3 item3 in cellRect)
                {
                    thingList = item3.GetThingList(map);
                    for (int m = 0; m < thingList.Count; m++)
                    {
                        Thing thing4 = thingList[m];
                        if (thing4 != thingToIgnore && !CanPlaceBlueprintOver(entDef, thing4.def))
                        {
                            return(new AcceptanceReport("SpaceAlreadyOccupied".Translate()));
                        }
                    }
                }
            }
            if (entDef.PlaceWorkers != null)
            {
                for (int n = 0; n < entDef.PlaceWorkers.Count; n++)
                {
                    AcceptanceReport result = entDef.PlaceWorkers[n].AllowsPlacing(entDef, center, rot, map, thingToIgnore, thing);
                    if (!result.Accepted)
                    {
                        return(result);
                    }
                }
            }
            return(AcceptanceReport.WasAccepted);
        }