public static bool Prefix(ref bool __result, IntVec3 c, Map map, bool canRoofPunch)
        {
            ModExt_Biome_FeatureControl extFtControl = map.Biome.GetModExtension <ModExt_Biome_FeatureControl>();

            if (extFtControl == null || extFtControl.overwriteRoof != RoofOverwriteType.FullStable)
            {
                return(true);
            }
            if (!c.Walkable(map))
            {
                __result = false;
                return(false);
            }
            if (c.CloseToEdge(map, MaxDistanceToEdge))
            {
                __result = true;
                return(false);
            }
            RoofDef roof = c.GetRoof(map);

            if (roof != null && !canRoofPunch)
            {
                __result = false;
            }
            else
            {
                __result = true;
            }
            return(false);
        }
        public static void Prefix(IntVec3 dropCenter, Map map, ref bool instaDrop)
        {
            ModExt_Biome_FeatureControl extFtControl = map.Biome.GetModExtension <ModExt_Biome_FeatureControl>();

            if (extFtControl == null || extFtControl.overwriteRoof != RoofOverwriteType.FullStable)
            {
                return;
            }
            // Set instaDrop to true if the drop pot should arrive near the map edge
            // This is mainly for event refugee and resource drops (which should maybe be deactivated at all on deep cave maps)
            if (dropCenter.CloseToEdge(map, MaxDistanceToEdge))
            {
                instaDrop = true;
            }
        }
        private bool CanScatterAt(IntVec3 c, Map map, int height, int widht)
        {
            if (c.CloseToEdge(map, height))
            {
                return(false);
            }
            if (!this.allowFoggedPosition && c.Fogged(map))
            {
                return(false);
            }
            if (!c.SupportsStructureType(map, TerrainAffordanceDefOf.Heavy))
            {
                return(false);
            }
            CellRect rect = new CellRect(c.x, c.z, widht, height).ClipInsideMap(map);

            return(this.CanPlaceInRange(rect, map));
        }
Esempio n. 4
0
        private static bool IsSafeDropSpot(IntVec3 cell, Map map, Faction faction, IntVec2?size = null, int distToEdge = 25, int distToHostiles = 35, int distToFires = 15)
        {
            Faction factionBaseFaction = map.ParentFaction ?? Faction.OfPlayer;

            if (size.HasValue)
            {
                foreach (IntVec3 item in GenAdj.OccupiedRect(cell, Rot4.North, size.Value))
                {
                    if (!IsGoodDropSpot(item, map, allowFogged: false, canRoofPunch: false, allowIndoors: false))
                    {
                        return(false);
                    }
                }
            }
            else if (!IsGoodDropSpot(cell, map, allowFogged: false, canRoofPunch: false, allowIndoors: false))
            {
                return(false);
            }
            if (distToEdge > 0 && cell.CloseToEdge(map, distToEdge))
            {
                return(false);
            }
            if (faction != null)
            {
                foreach (IAttackTarget item2 in map.attackTargetsCache.TargetsHostileToFaction(faction))
                {
                    if (!item2.ThreatDisabled(null) && item2.Thing.Position.InHorDistOf(cell, distToHostiles))
                    {
                        return(false);
                    }
                }
            }
            if (!map.reachability.CanReachFactionBase(cell, factionBaseFaction))
            {
                return(false);
            }
            if (size.HasValue)
            {
                foreach (IntVec3 cell2 in CellRect.CenteredOn(cell, size.Value.x, size.Value.z).Cells)
                {
                    if (CellHasCrops(cell2))
                    {
                        return(false);
                    }
                }
            }
            else if (CellHasCrops(cell))
            {
                return(false);
            }
            float minDistToFiresSq = distToFires * distToFires;
            float closestDistSq    = float.MaxValue;
            int   firesCount       = 0;

            RegionTraverser.BreadthFirstTraverse(cell, map, (Region from, Region to) => true, delegate(Region x)
            {
                List <Thing> list = x.ListerThings.ThingsInGroup(ThingRequestGroup.Fire);
                for (int i = 0; i < list.Count; i++)
                {
                    float num = cell.DistanceToSquared(list[i].Position);
                    if (!(num > minDistToFiresSq))
                    {
                        if (num < closestDistSq)
                        {
                            closestDistSq = num;
                        }
                        firesCount++;
                    }
                }
                return(closestDistSq <= minDistToFiresSq && firesCount >= 5);
            }, 15);
            if (closestDistSq <= minDistToFiresSq && firesCount >= 5)
            {
                return(false);
            }
            return(true);

            bool CellHasCrops(IntVec3 c)
            {
                Plant plant = c.GetPlant(map);

                if (plant != null && plant.sown)
                {
                    return(map.zoneManager.ZoneAt(c) is Zone_Growing);
                }
                return(false);
            }
        }
Esempio n. 5
0
 public static void InNoZoneEdgeArea_Postfix(this IntVec3 c, Map map, ref bool __result)
 {
     __result = c.CloseToEdge(map, ChangeMapEdge.Instance.GetNoZoneLimit());
 }
Esempio n. 6
0
 public static bool InNoZoneEdgeArea(this IntVec3 c, Map map)
 {
     return(c.CloseToEdge(map, NoZoneEdgeWidth));
 }