Пример #1
0
        public bool IsValidPositionToSpawnShipChunk(Map map, IntVec3 position)
        {
            ThingDef chunkDef = ThingDefOf.ShipChunk;

            if ((position.InBounds(map) == false) ||
                position.Fogged(map) ||
                (position.Standable(map) == false) ||
                (position.Roofed(map) &&
                 position.GetRoof(map).isThickRoof))
            {
                return(false);
            }
            if (position.SupportsStructureType(map, chunkDef.terrainAffordanceNeeded) == false)
            {
                return(false);
            }
            List <Thing> thingList = position.GetThingList(map);

            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);
        }
Пример #2
0
        private bool TryCollideWithRoof(IntVec3 cell)
        {
            if (!cell.Roofed(Map))
            {
                return(false);
            }

            var bounds = CE_Utility.GetBoundsFor(cell, cell.GetRoof(Map));

            float dist;

            if (!bounds.IntersectRay(ShotLine, out dist))
            {
                return(false);
            }
            if (dist * dist > ExactMinusLastPos.sqrMagnitude)
            {
                return(false);
            }

            var point = ShotLine.GetPoint(dist);

            ExactPosition = point;
            landed        = true;

            if (DebugViewSettings.drawInterceptChecks)
            {
                MoteMaker.ThrowText(cell.ToVector3Shifted(), Map, "x", Color.red);
            }

            Impact(null);
            return(true);
        }
Пример #3
0
        public bool IsCellBlocked(IntVec3 cell, out string blockedBy)
        {
            Map map  = Map;
            var roof = cell.GetRoof(map);

            if (roof != null)
            {
                blockedBy = roof.LabelCap;
                return(true);
            }

            foreach (var thing in cell.GetThingList(map))
            {
                if (thing == this)
                {
                    continue;
                }

                if (thing is Building b)
                {
                    if (b.def.altitudeLayer >= AltitudeLayer.DoorMoveable)
                    {
                        blockedBy = b.LabelShortCap;
                        return(true);
                    }
                }
            }

            blockedBy = null;
            return(false);
        }
Пример #4
0
        public static bool CanPhysicallyDropInto(IntVec3 c, Map map, bool canRoofPunch, bool allowedIndoors = true)
        {
            if (!c.Walkable(map))
            {
                return(false);
            }
            RoofDef roof = c.GetRoof(map);

            if (roof != null)
            {
                if (!canRoofPunch)
                {
                    return(false);
                }
                if (roof.isThickRoof)
                {
                    return(false);
                }
            }
            if (!allowedIndoors)
            {
                Room room = c.GetRoom(map);
                if (room != null && !room.PsychologicallyOutdoors)
                {
                    return(false);
                }
            }
            return(true);
        }
        private static bool CanPhysicallyDropInto(IntVec3 c, Map map, bool canRoofPunch)
        {
            bool result;

            if (!c.Walkable(map))
            {
                result = false;
            }
            else
            {
                RoofDef roof = c.GetRoof(map);
                if (roof != null)
                {
                    if (!canRoofPunch)
                    {
                        return(false);
                    }
                    if (roof.isThickRoof)
                    {
                        return(false);
                    }
                }
                result = true;
            }
            return(result);
        }
Пример #6
0
        private static float GetMountainousnessScoreAt(IntVec3 cell, Map map)
        {
            float num  = 0f;
            int   num2 = 0;

            for (int i = 0; i < 700; i += 10)
            {
                IntVec3 c = cell + GenRadial.RadialPattern[i];
                if (c.InBounds(map))
                {
                    Building edifice = c.GetEdifice(map);
                    if (edifice != null && edifice.def.category == ThingCategory.Building && edifice.def.building.isNaturalRock)
                    {
                        num += 1f;
                    }
                    else if (c.Roofed(map) && c.GetRoof(map).isThickRoof)
                    {
                        num += 0.5f;
                    }

                    num2++;
                }
            }

            return(num / (float)num2);
        }
        public override bool Valid(LocalTargetInfo target, bool throwMessages = false)
        {
            Pawn    pawn = parent?.verb?.CasterPawn;
            Map     map  = parent?.verb?.CasterPawn?.Map;
            IntVec3 cell = target.Cell;

            if (map == null || pawn == null || cell == null)
            {
                return(false);
            }
            if (cell.GetRoofHolderOrImpassable(map) != null)
            {
                throwMessages = true;
                return(false);
            }
            if (cell.Roofed(map))
            {
                if (cell.GetRoof(map) == RoofDefOf.RoofRockThick)
                {
                    throwMessages = true;
                    return(false);
                }
            }
            return(base.Valid(target, throwMessages));
        }
        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);
        }
Пример #9
0
 private bool IsNaturalRoofAt(IntVec3 c, Map map)
 {
     if (c.Roofed(map))
     {
         return(c.GetRoof(map).isNatural);
     }
     return(false);
 }
Пример #10
0
 private static float GetScoreAt(IntVec3 cell, Map map)
 {
     if ((float)(int)InfestationCellFinder.distToColonyBuilding[cell] > 30.0)
     {
         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)
     {
         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 < -17.0)
         {
             return(0f);
         }
         float mountainousnessScoreAt = InfestationCellFinder.GetMountainousnessScoreAt(cell, map);
         if (mountainousnessScoreAt < 0.17000000178813934)
         {
             return(0f);
         }
         int   num  = InfestationCellFinder.StraightLineDistToUnroofed(cell, map);
         float num2 = (float)(InfestationCellFinder.regionsDistanceToUnroofed.TryGetValue(region, out num2) ? Mathf.Min(num2, (float)((float)num * 4.0)) : ((float)num * 1.1499999761581421));
         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 = (float)(1.0 - Mathf.Clamp((float)(InfestationCellFinder.DistToBlocker(cell, map) / 11.0), 0f, 0.6f));
         float num6 = Mathf.InverseLerp(-17f, -7f, temperature);
         float f    = num2 * num3 * num5 * mountainousnessScoreAt * num4 * num6;
         f = Mathf.Pow(f, 1.2f);
         if (f < 7.5)
         {
             return(0f);
         }
         return(f);
     }
     return(0f);
 }
Пример #11
0
        private bool CellImmuneToDamage(IntVec3 c)
        {
            if (c.Roofed(base.Map) && c.GetRoof(base.Map).isThickRoof)
            {
                return(true);
            }
            Building edifice = c.GetEdifice(base.Map);

            return(edifice != null && edifice.def.category == ThingCategory.Building && (edifice.def.building.isNaturalRock || (edifice.def == RimWorld.ThingDefOf.Wall && edifice.Faction == null)));
        }
Пример #12
0
 private static void Prefix(RoofGrid __instance, ref IntVec3 c, ref RoofDef def)
 {
     try
     {
         if (def != null && !def.isNatural)
         {
             Map map      = Traverse.Create(__instance).Field("map").GetValue <Map>();
             var ZTracker = Current.Game.GetComponent <ZLevelsManager>();
             var upperMap = ZTracker.GetUpperLevel(map.Tile, map);
             if (upperMap != null && upperMap.terrainGrid.TerrainAt(c) == ZLevelsDefOf.ZL_OutsideTerrain)
             {
                 upperMap.terrainGrid.SetTerrain(c, ZLevelsDefOf.ZL_RoofTerrain);
             }
         }
         else if (def == null)
         {
             Map map = Traverse.Create(__instance).Field("map").GetValue <Map>();
             if (c.GetRoof(map) == RoofDefOf.RoofConstructed)
             {
                 var ZTracker = Current.Game.GetComponent <ZLevelsManager>();
                 Map upperMap = ZTracker.GetUpperLevel(map.Tile, map);
                 if (upperMap != null)
                 {
                     upperMap.terrainGrid.SetTerrain(c, ZLevelsDefOf.ZL_OutsideTerrain);
                     var thingList = c.GetThingList(upperMap);
                     for (int i = thingList.Count - 1; i >= 0; i--)
                     {
                         if (!(thingList[i] is Mineable || thingList[i] is Blueprint || thingList[i] is Frame))
                         {
                             //Log.Message(thingList[i] + " going down 3");
                             ZTracker.SimpleTeleportThing(thingList[i], c, map, false, 10);
                         }
                     }
                     ZLogger.Message("Removing roof " + c.GetRoof(map), true);
                 }
             }
         }
     }
     catch (Exception ex)
     {
         //Log.Error("Error in Patch_SetRoof: " + ex);
     };
 }
Пример #13
0
        public virtual void Tick(AirstrikeInstance instance, int tick)
        {
            if (IsDone)
            {
                return;
            }

            IsDone = tick >= ExplodeOnTick;
            if (IsDone)
            {
                // Check for overhead mountain.
                var roof = Cell.GetRoof(instance.Map);
                if (roof != null && roof.isThickRoof)
                {
                    return;
                }

                // Explode!
                if (ProjectileDef == null)
                {
                    Core.Warn("Null projectile def, explosion not spawned...");
                    return;
                }

                if (CECompat.IsCEActive)
                {
                    // Combat extended explosions.
                    var proj = ThingMaker.MakeThing(ProjectileDef, null);
                    GenSpawn.Spawn(proj, Cell, instance.Map);

                    exactPosition ??= AccessTools.Property(AccessTools.TypeByName("CombatExtended.ProjectileCE"), "ExactPosition");
                    impactCEMethod ??= AccessTools.Method("CombatExtended.ProjectileCE:ImpactSomething");
                    launchCEMethod ??= AccessTools.Method("CombatExtended.ProjectileCE:Launch", new Type[] { typeof(Thing), typeof(Vector2), typeof(float), typeof(float), typeof(float), typeof(float), typeof(Thing) });

                    try
                    {
                        exactPosition.SetValue(proj, Cell.ToVector3ShiftedWithAltitude(AltitudeLayer.Building));
                        launchCEMethod.Invoke(proj, new object[] { instance.Instigator, Cell.ToVector3Shifted().WorldToFlat(), -1f, -1f, 0f, -1f, null });
                        //impactCEMethod.Invoke(proj, emptyArgs);
                    }
                    catch
                    {
                        //Core.Error("Error in CE explosion invocation", e);
                    }
                }
                else
                {
                    // Regular game explosions.
                    var proj = GenSpawn.Spawn(ProjectileDef, Cell, instance.Map) as Projectile;
                    proj.Launch(instance.Instigator, Cell, Cell, ProjectileHitFlags.IntendedTarget);
                    impactMethod.Invoke(proj, emptyArgs);
                }
            }
        }
Пример #14
0
 public override bool IsSameSpawned(IntVec3 at, Map map)
 {
     try
     {
         return(at.GetRoof(map).Equals(roof));
     }
     catch
     {
         return(false);
     }
 }
Пример #15
0
 public static bool IsValidPositionToSpawnDropPod(Map map, IntVec3 position)
 {
     if ((position.InBounds(map) == false) ||
         position.Fogged(map) ||
         (position.Standable(map) == false) ||
         (position.Roofed(map) &&
          position.GetRoof(map).isThickRoof))
     {
         return(false);
     }
     return(true);
 }
Пример #16
0
 private static void Prefix(RoofGrid __instance, ref IntVec3 c, ref RoofDef def, Map ___map)
 {
     try
     {
         if (def != null && !def.isNatural)
         {
             var ZTracker = ZUtils.ZTracker;
             var upperMap = ZTracker.GetUpperLevel(___map.Tile, ___map);
             if (upperMap != null && upperMap.terrainGrid.TerrainAt(c) == ZLevelsDefOf.ZL_OutsideTerrain)
             {
                 upperMap.terrainGrid.SetTerrain(c, ZLevelsDefOf.ZL_RoofTerrain);
             }
         }
         else if (def == null)
         {
             if (c.GetRoof(___map) == RoofDefOf.RoofConstructed)
             {
                 var ZTracker = ZUtils.ZTracker;
                 Map upperMap = ZTracker.GetUpperLevel(___map.Tile, ___map);
                 if (upperMap != null)
                 {
                     upperMap.terrainGrid.SetTerrain(c, ZLevelsDefOf.ZL_OutsideTerrain);
                     var thingList = c.GetThingList(upperMap);
                     for (int i = thingList.Count - 1; i >= 0; i--)
                     {
                         if (thingList[i].IsAllowedToSpawnBelow())
                         {
                             ZTracker.TeleportThing(thingList[i], c, ___map, false, 10);
                         }
                     }
                     ZLogger.Message("Removing roof " + c.GetRoof(___map));
                 }
             }
         }
     }
     catch (Exception ex)
     {
         //Log.Error("Error in Patch_SetRoof: " + ex);
     };
 }
 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;
 }
        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);
        }
Пример #19
0
        public static Thing SpawnTunnels(int hiveCount, Map map, bool spawnAnywhereIfNoGoodCell = false, bool ignoreRoofedRequirement = false, string questTag = null)
        {
            if (!InfestationCellFinder.TryFindCell(out var cell, map))
            {
                if (!spawnAnywhereIfNoGoodCell)
                {
                    return(null);
                }
                if (!RCellFinder.TryFindRandomCellNearTheCenterOfTheMapWith(delegate(IntVec3 x)
                {
                    if (!x.Standable(map) || x.Fogged(map))
                    {
                        return(false);
                    }
                    bool flag = false;
                    int num = GenRadial.NumCellsInRadius(3f);
                    for (int j = 0; j < num; j++)
                    {
                        IntVec3 c = x + GenRadial.RadialPattern[j];
                        if (c.InBounds(map))
                        {
                            RoofDef roof = c.GetRoof(map);
                            if (roof != null && roof.isThickRoof)
                            {
                                flag = true;
                                break;
                            }
                        }
                    }
                    return(flag ? true : false);
                }, map, out cell))
                {
                    return(null);
                }
            }
            Thing thing = GenSpawn.Spawn(ThingMaker.MakeThing(ThingDefOf.TunnelHiveSpawner), cell, map, WipeMode.FullRefund);

            QuestUtility.AddQuestTag(thing, questTag);
            for (int i = 0; i < hiveCount - 1; i++)
            {
                cell = CompSpawnerHives.FindChildHiveLocation(thing.Position, map, ThingDefOf.Hive, ThingDefOf.Hive.GetCompProperties <CompProperties_SpawnerHives>(), ignoreRoofedRequirement, allowUnreachable: true);
                if (cell.IsValid)
                {
                    thing = GenSpawn.Spawn(ThingMaker.MakeThing(ThingDefOf.TunnelHiveSpawner), cell, map, WipeMode.FullRefund);
                    QuestUtility.AddQuestTag(thing, questTag);
                }
            }
            return(thing);
        }
Пример #20
0
        private bool CellImmuneToDamage(IntVec3 c)
        {
            bool result;

            if (c.Roofed(base.Map) && c.GetRoof(base.Map).isThickRoof)
            {
                result = true;
            }
            else
            {
                Building edifice = c.GetEdifice(base.Map);
                result = (edifice != null && edifice.def.category == ThingCategory.Building && (edifice.def.building.isNaturalRock || (edifice.def == ThingDefOf.Wall && edifice.Faction == null)));
            }
            return(result);
        }
Пример #21
0
 public override AcceptanceReport AllowsPlacing(BuildableDef checkingDef, IntVec3 loc, Rot4 rot, Map map, Thing thingToIgnore = null, Thing thing = null)
 {
     if (loc.GetRoof(map) != null)
     {
         if (AvaliUtility.BuildingInPosition(map, loc, checkingDef) != null)
         {
             return(new AcceptanceReport("SpaceAlreadyOccupied".Translate()));
         }
         else
         {
             return(true);
         }
     }
     return(new AcceptanceReport("MustPlaceUnderRoof".Translate()));
 }
        public override AcceptanceReport AllowsPlacing(BuildableDef checkDef, IntVec3 loc, Rot4 rot, Map map, Thing thingtoIgnore = null)
        {
            if (InfestationBaitSettings.mapDict == null)
            {
                Log.Error("Error:Bait Dictionary was not initialized!");
                return(new AcceptanceReport("InfestationBait_AcceptanceReportFailed_notInitialized".Translate()));
            }

            if (!loc.Roofed(map) || !loc.GetRoof(map).isThickRoof)
            {
                return(new AcceptanceReport("InfestationBait_AcceptanceReportFailed_Roof".Translate()));
            }

            if (InfestationBaitSettings.mapDict.ContainsKey(map))
            {
                return(new AcceptanceReport("InfestationBait_AcceptanceReportFailed_exist".Translate()));
            }

            return(AcceptanceReport.WasAccepted);
        }
Пример #23
0
        private static float GetScoreAt(IntVec3 cell, Map map)
        {
            if (!cell.Walkable(map))
            {
                return(0f);
            }

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

            var temperature = cell.GetTemperature(map);

            if (temperature < -20f)
            {
                return(0f);
            }

            var score = 1f;

            if (!cell.Roofed(map))
            {
                score *= .03f;
            }
            else if (!cell.GetRoof(map).isThickRoof)
            {
                score *= .5f;
            }

            var mountainousnessScoreAt = GetMountainousnessScoreAt(cell, map);

            if (mountainousnessScoreAt < 0.17f)
            {
                score *= .3f;
            }

            return(score);
        }
Пример #24
0
 // Punch the roof, if needed
 public static void DoRoofPunch(IntVec3 position)
 {
     var roof = position.GetRoof();
     // If there was actually a roof
     if (roof != null)
     {
         // If we can punch through
         if (!roof.soundPunchThrough.NullOrUndefined())
         {
             // Play punch sound
             roof.soundPunchThrough.PlayOneShot(position);
         }
         // If the roof def is to leave filth
         if (roof.filthLeaving != null)
         {
             // Drop some filth
             for (var j = 0; j < 3; j++)
             {
                 FilthMaker.MakeFilth(position, roof.filthLeaving);
             }
         }
     }
 }
        private static string GetReportFromCell(IntVec3 cell, Map map)
        {
            if (!cell.InBounds(map))
            {
                return("OutOfBounds".Translate().CapitalizeFirst());
            }
            if (cell.Fogged(map))
            {
                return("ShuttleCannotLand_Fogged".Translate().CapitalizeFirst());
            }
            if (!cell.Walkable(map))
            {
                return("ShuttleCannotLand_Unwalkable".Translate().CapitalizeFirst());
            }
            RoofDef roof = cell.GetRoof(map);

            if (roof != null && (roof.isNatural || roof.isThickRoof))
            {
                return("MessageTransportPodsDestinationIsInvalid".Translate().CapitalizeFirst());
            }
            List <Thing> thingList = cell.GetThingList(map);

            for (int i = 0; i < thingList.Count; i++)
            {
                Thing thing = thingList[i];
                if (thing is IActiveDropPod || thing is Skyfaller || thing.def.category == ThingCategory.Item || thing.def.category == ThingCategory.Building)
                {
                    return("BlockedBy".Translate(thing).CapitalizeFirst());
                }
                PlantProperties plant = thing.def.plant;
                if (plant != null && plant.IsTree)
                {
                    return("BlockedBy".Translate(thing).CapitalizeFirst());
                }
            }
            return(null);
        }
        // Token: 0x06003689 RID: 13961 RVA: 0x001A0DA8 File Offset: 0x0019F1A8
        private static bool CanPhysicallyDropInto(IntVec3 c, Map map, bool canRoofPunch)
        {
            if (!c.Walkable(map))
            {
                return(false);
            }
            RoofDef roof = c.GetRoof(map);

            if (roof != null)
            {
                if (!canRoofPunch)
                {
                    return(false);
                }

                /*
                 * if (roof.isThickRoof)
                 * {
                 *  return false;
                 * }
                 */
            }
            return(true);
        }
 private bool IsNaturalRoofAt(IntVec3 c, Map map)
 {
     return(c.Roofed(map) && c.GetRoof(map).isNatural);
 }
        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;
        }
Пример #29
0
        /*
         * // Token: 0x0600368B RID: 13963 RVA: 0x001A0E1C File Offset: 0x0019F21C
         * public static bool TryFindCell(out IntVec3 cell, out IntVec3 locationC, Map map, bool allowFogged = true)
         * {
         *  ThingDef namedA = XenomorphDefOf.RRY_Xenomorph_Humanoid_Cocoon;
         *  ThingDef namedB = XenomorphDefOf.RRY_Xenomorph_Animal_Cocoon;
         *  InfestationLikeCellFinder.CalculateLocationCandidates(map, allowFogged);
         *  Predicate<IntVec3> validator = delegate (IntVec3 y)
         *  {
         *      bool score = InfestationLikeCellFinder.GetScoreAt(y, map, allowFogged) > 0f;
         *      bool XenohiveA = y.GetFirstThing(map, XenomorphDefOf.RRY_XenomorphHive) == null;
         *      bool XenohiveB = y.GetFirstThing(map, XenomorphDefOf.RRY_XenomorphHive_Child) == null;
         *      bool filled = y.Filled(map);
         *      bool edifice = y.GetEdifice(map).DestroyedOrNull();
         *      bool building = y.GetFirstBuilding(map).DestroyedOrNull();
         *      bool thingA = y.GetFirstThing(map, namedA).DestroyedOrNull();
         *      bool thingB = y.GetFirstThing(map, namedB).DestroyedOrNull();
         *  //    Log.Message(string.Format("Cell: {0}, score: {1}, XenohiveA: {2}, XenohiveB: {3}, !filled: {4}, edifice: {5}, building: {6}, thingA: {7}, thingB: {8}\nResult: {9}", y, GetScoreAt(y, map, allowFogged), XenohiveA, XenohiveB, !filled, edifice, building, thingA, thingB, score && XenohiveA && XenohiveB && !filled && edifice && building && thingA && thingB));
         *      return score && XenohiveA && XenohiveB && !filled && edifice && building && thingA && thingB;
         *  };
         *  if (!InfestationLikeCellFinder.locationCandidates.TryRandomElementByWeight((InfestationLikeCellFinder.LocationCandidate x) => x.score, out LocationCandidate locationCandidate))
         *  {
         *      cell = IntVec3.Invalid;
         *      locationC = IntVec3.Invalid;
         *      if (!InfestationCellFinder.TryFindCell(out cell, map))
         *      {
         *          cell = IntVec3.Invalid;
         *          return false;
         *      }
         *  }
         *  locationC = locationCandidate.cell;
         *  cell = CellFinder.FindNoWipeSpawnLocNear(locationCandidate.cell, map, XenomorphDefOf.RRY_XenomorphHive, Rot4.North, 2, (IntVec3 x) => InfestationLikeCellFinder.GetScoreAt(x, map, allowFogged) > 0f && x.GetFirstThing(map, XenomorphDefOf.RRY_XenomorphHive) == null && x.GetFirstThing(map, OGHiveLikeDefOf.TunnelHiveLikeSpawner) == null && x.GetFirstThing(map, XenomorphDefOf.RRY_Xenomorph_Humanoid_Cocoon) == null && x.GetFirstThing(map, XenomorphDefOf.RRY_Xenomorph_Animal_Cocoon) == null);
         *  ThingDef td = XenomorphDefOf.RRY_Hive_Slime;
         *  GenSpawn.Spawn(td, cell, map);
         *  return true;
         * }
         */
        // Token: 0x0600368C RID: 13964 RVA: 0x001A0EAC File Offset: 0x0019F2AC
        public static float GetScoreAt(IntVec3 cell, Map map, bool allowFogged = false, bool allowUnroofed = false, bool allowDigging = false)
        {
            if (cell.GetTerrain(map).HasTag("Water") || cell.GetTerrain(map).defName.Contains("Water") || cell.GetTerrain(map).defName.Contains("Marsh"))
            {
                return(0f);
            }
            if ((!cell.Walkable(map) && !cell.GetFirstMineable(map).DestroyedOrNull() && !allowDigging))
            {
                return(0f);
            }
            if (cell.Fogged(map) && !allowFogged)
            {
                return(0f);
            }
            if (InfestationLikeCellFinder.CellHasBlockingThings(cell, map) && !allowDigging)
            {
                return(0f);
            }
            if ((!cell.Roofed(map) || !cell.GetRoof(map).isThickRoof) && !allowUnroofed)
            {
                return(0f);
            }
            Region region = cell.GetRegion(map, RegionType.Set_Passable);

            if (region == null && !allowDigging)
            {
                return(0f);
            }
            if (InfestationLikeCellFinder.closedAreaSize[cell] < 2 && !allowDigging)
            {
                return(0f);
            }
            float temperature = cell.GetTemperature(map);

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

            //    Log.Message(String.Format("{0} mountainousnessScoreAt: {1}", cell, mountainousnessScoreAt), true);
            if (mountainousnessScoreAt < (allowDigging ? 0.5f : 0.17f))
            {
                //    Log.Message(String.Format("{0} faield due to Low Mountainousness Score",cell), true);
                return(0f);
            }
            int   num = InfestationLikeCellFinder.StraightLineDistToUnroofed(cell, map);
            float num2;

            if (region == null)
            {
                num2 = (float)num * 1.15f;
            }
            else
            {
                if (!InfestationLikeCellFinder.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(InfestationLikeCellFinder.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);
            }
            if ((float)InfestationLikeCellFinder.distToColonyBuilding[cell] < 20f)
            {
                num7 = (int)(num7 * 0.75f);
            }
            if (map.areaManager.Home[cell])
            {
                num7 = (int)(num7 * 0.75f);
            }
            return(num7);
        }
Пример #30
0
 private bool GoodRoofForCavePlant(IntVec3 c)
 {
     return(c.GetRoof(map)?.isNatural ?? false);
 }
Пример #31
0
 public static bool GoodRoofForCavePlant2(Map map2, IntVec3 c)
 {
     return(c.GetRoof(map2)?.isNatural ?? false);
 }
Пример #32
0
        public void MouseoverReadoutOnGUI()
        {
            if (Find.MainTabsRoot.OpenTab != null)
            {
                return;
            }
            GenUI.DrawTextWinterShadow(new Rect(256f, (float)(Screen.height - 256), -256f, 256f));
            Text.Font = GameFont.Small;
            GUI.color = new Color(1f, 1f, 1f, 0.8f);
            IntVec3 c = Gen.MouseCell();

            if (!c.InBounds())
            {
                return;
            }
            float num = 0f;
            Rect  rect;

            if (c.Fogged())
            {
                rect = new Rect(MouseoverReadout.BotLeft.x, (float)Screen.height - MouseoverReadout.BotLeft.y - num, 999f, 999f);
                Widgets.Label(rect, "Undiscovered".Translate());
                GUI.color = Color.white;
                return;
            }
            rect = new Rect(MouseoverReadout.BotLeft.x, (float)Screen.height - MouseoverReadout.BotLeft.y - num, 999f, 999f);
            Widgets.Label(rect, Find.GlowGrid.PsychGlowAt(c).GetLabel() + " (" + Find.GlowGrid.GameGlowAt(c).ToStringPercent() + ")");
            num += 19f;
            rect = new Rect(MouseoverReadout.BotLeft.x, (float)Screen.height - MouseoverReadout.BotLeft.y - num, 999f, 999f);
            TerrainDef terrain = c.GetTerrain();

            if (terrain != this.cachedTerrain)
            {
                this.cachedTerrainString = terrain.LabelCap + ((terrain.passability != Traversability.Impassable) ? (" (" + "WalkSpeed".Translate(new object[]
                {
                    this.SpeedPercentString((float)terrain.pathCost)
                }) + ")") : null);
                this.cachedTerrain = terrain;
            }
            Widgets.Label(rect, this.cachedTerrainString);
            num += 19f;
            Zone zone = c.GetZone();

            if (zone != null)
            {
                rect = new Rect(MouseoverReadout.BotLeft.x, (float)Screen.height - MouseoverReadout.BotLeft.y - num, 999f, 999f);
                string label = zone.label;
                Widgets.Label(rect, label);
                num += 19f;
            }
            float depth = Find.SnowGrid.GetDepth(c);

            if ((double)depth > 0.03)
            {
                rect = new Rect(MouseoverReadout.BotLeft.x, (float)Screen.height - MouseoverReadout.BotLeft.y - num, 999f, 999f);
                SnowCategory snowCategory = SnowUtility.GetSnowCategory(depth);
                string       label2       = SnowUtility.GetDescription(snowCategory) + " (" + "WalkSpeed".Translate(new object[]
                {
                    this.SpeedPercentString((float)SnowUtility.MovementTicksAddOn(snowCategory))
                }) + ")";
                Widgets.Label(rect, label2);
                num += 19f;
            }
            List <Thing> list = Find.ThingGrid.ThingsListAt(c);

            for (int i = 0; i < list.Count; i++)
            {
                Thing thing = list[i];
                if (thing.def.category != ThingCategory.Mote)
                {
                    rect = new Rect(MouseoverReadout.BotLeft.x, (float)Screen.height - MouseoverReadout.BotLeft.y - num, 999f, 999f);
                    string labelMouseover = thing.LabelMouseover;
                    Widgets.Label(rect, labelMouseover);
                    num += 19f;
                }
            }
            RoofDef roof = c.GetRoof();

            if (roof != null)
            {
                rect = new Rect(MouseoverReadout.BotLeft.x, (float)Screen.height - MouseoverReadout.BotLeft.y - num, 999f, 999f);
                Widgets.Label(rect, roof.LabelCap);
                num += 19f;
            }
            GUI.color = Color.white;
        }
Пример #33
0
        private bool GoodRoofForCavePlant(IntVec3 c)
        {
            RoofDef roof = c.GetRoof(this.map);

            return(roof != null && roof.isNatural);
        }