Пример #1
0
        // Token: 0x0600368E RID: 13966 RVA: 0x001A127C File Offset: 0x0019F67C
        private static void CalculateLocationCandidates(Map map, bool allowFogged = false, bool allowUnroofed = false, bool allowDigging = false, bool forceNew = false)
        {
            int minscore = (allowUnroofed ? 0 : (allowDigging ? 15000 : 10000));
            MapComponent_HiveGrid hiveGrid = map.HiveGrid();

            InfestationLikeCellFinder.locationCandidates.Clear();
            InfestationLikeCellFinder.CalculateTraversalDistancesToUnroofed(map);
            InfestationLikeCellFinder.CalculateClosedAreaSizeGrid(map);
            InfestationLikeCellFinder.CalculateDistanceToColonyBuildingGrid(map);
            for (int i = 0; i < map.Size.z; i++)
            {
                for (int j = 0; j < map.Size.x; j++)
                {
                    IntVec3 cell = new IntVec3(j, 0, i);
                    if (!forceNew || !(hiveGrid.Hivelist.Any(x => x.Position == cell) || hiveGrid.hiveLoclist.Any(x => x == cell)))
                    {
                    }
                    float scoreAt = InfestationLikeCellFinder.GetScoreAt(cell, map, allowFogged, allowUnroofed, allowDigging); // allowFogged

                    if (scoreAt > minscore)
                    {
                        //    Log.Message(string.Format("scoreAt {0} == {1}", cell, scoreAt));
                        InfestationLikeCellFinder.locationCandidates.Add(new InfestationLikeCellFinder.LocationCandidate(cell, scoreAt));
                    }
                }
            }
        }
        // Token: 0x06000E63 RID: 3683 RVA: 0x0006B874 File Offset: 0x00069C74
        protected override bool CanFireNowSub(IncidentParms parms)
        {
            Map map = (Map)parms.target;

            if (!InfestationLikeCellFinder.TryFindCell(out intVec, out lc, map, false, false, false, true))
            {
                if (!InfestationLikeCellFinder.TryFindCell(out intVec, out lc, map, true, false, false, true))
                {
                    if (!InfestationLikeCellFinder.TryFindCell(out intVec, out lc, map, true, true, false, true))
                    {
                        if (!InfestationLikeCellFinder.TryFindCell(out intVec, out lc, map, true, true, true, true))
                        {
                            return(false);
                        }
                    }
                }
            }
            bool result = base.CanFireNowSub(parms) && XenomorphHiveUtility.TotalSpawnedHiveLikesCount(map) < 1;

            return(result);

            /*
             * Map map = (Map)parms.target;
             * IntVec3 intVec = DropCellFinder.RandomDropSpot(map);
             * return base.CanFireNowSub(parms) && HiveLikeUtility.TotalSpawnedHiveLikesCount(map) < 100;
             */
        }
 // Token: 0x0600368D RID: 13965 RVA: 0x001A1070 File Offset: 0x0019F470
 public static void DebugDraw()
 {
     if (DebugViewSettings.drawInfestationChance)
     {
         if (InfestationLikeCellFinder.tmpCachedInfestationChanceCellColors == null)
         {
             InfestationLikeCellFinder.tmpCachedInfestationChanceCellColors = new List <Pair <IntVec3, float> >();
         }
         if (Time.frameCount % 8 == 0)
         {
             InfestationLikeCellFinder.tmpCachedInfestationChanceCellColors.Clear();
             Map      currentMap = Find.CurrentMap;
             CellRect cellRect   = Find.CameraDriver.CurrentViewRect;
             cellRect.ClipInsideMap(currentMap);
             cellRect = cellRect.ExpandedBy(1);
             InfestationLikeCellFinder.CalculateTraversalDistancesToUnroofed(currentMap);
             InfestationLikeCellFinder.CalculateClosedAreaSizeGrid(currentMap);
             InfestationLikeCellFinder.CalculateDistanceToColonyBuildingGrid(currentMap);
             float num = 0.001f;
             for (int i = 0; i < currentMap.Size.z; i++)
             {
                 for (int j = 0; j < currentMap.Size.x; j++)
                 {
                     IntVec3 cell    = new IntVec3(j, 0, i);
                     float   scoreAt = InfestationLikeCellFinder.GetScoreAt(cell, currentMap);
                     if (scoreAt > num)
                     {
                         num = scoreAt;
                     }
                 }
             }
             for (int k = 0; k < currentMap.Size.z; k++)
             {
                 for (int l = 0; l < currentMap.Size.x; l++)
                 {
                     IntVec3 intVec = new IntVec3(l, 0, k);
                     if (cellRect.Contains(intVec))
                     {
                         float scoreAt2 = InfestationLikeCellFinder.GetScoreAt(intVec, currentMap);
                         if (scoreAt2 > 7.5f)
                         {
                             float second = GenMath.LerpDouble(7.5f, num, 0f, 1f, scoreAt2);
                             InfestationLikeCellFinder.tmpCachedInfestationChanceCellColors.Add(new Pair <IntVec3, float>(intVec, second));
                         }
                     }
                 }
             }
         }
         for (int m = 0; m < InfestationLikeCellFinder.tmpCachedInfestationChanceCellColors.Count; m++)
         {
             IntVec3 first   = InfestationLikeCellFinder.tmpCachedInfestationChanceCellColors[m].First;
             float   second2 = InfestationLikeCellFinder.tmpCachedInfestationChanceCellColors[m].Second;
             CellRenderer.RenderCell(first, SolidColorMaterials.SimpleSolidColorMaterial(new Color(0f, 0f, 1f, second2), false));
         }
     }
     else
     {
         InfestationLikeCellFinder.tmpCachedInfestationChanceCellColors = null;
     }
 }
 // Token: 0x0600368B RID: 13963 RVA: 0x001A0E1C File Offset: 0x0019F21C
 public static bool TryFindCell(out IntVec3 cell, Map map)
 {
     //Log.Message(string.Format("Tick: 1"));
     InfestationLikeCellFinder.CalculateLocationCandidates(map);
     InfestationLikeCellFinder.LocationCandidate locationCandidate;
     if (!InfestationLikeCellFinder.locationCandidates.TryRandomElementByWeight((InfestationLikeCellFinder.LocationCandidate x) => x.score, out locationCandidate))
     {
         cell = IntVec3.Invalid;
         //Log.Message(string.Format("TryFindCell: {0} From !InfestationLikeCellFinder.TryFindCell(out loc, map)", cell));
         return(false);
     }
     cell = CellFinder.FindNoWipeSpawnLocNear(locationCandidate.cell, map, OGHiveLikeDefOf.HiveLike, Rot4.North, 2, (IntVec3 x) => InfestationLikeCellFinder.GetScoreAt(x, map) > 0f && x.GetFirstThing(map, OGHiveLikeDefOf.HiveLike) == null && x.GetFirstThing(map, ThingDefOf.TunnelHiveSpawner) == null);
     return(true);
 }
Пример #5
0
        // Token: 0x06003694 RID: 13972 RVA: 0x001A1654 File Offset: 0x0019FA54
        private static void CalculateTraversalDistancesToUnroofed(Map map)
        {
            InfestationLikeCellFinder.tempUnroofedRegions.Clear();
            for (int i = 0; i < map.Size.z; i++)
            {
                for (int j = 0; j < map.Size.x; j++)
                {
                    IntVec3 intVec = new IntVec3(j, 0, i);
                    Region  region = intVec.GetRegion(map, RegionType.Set_Passable);
                    if (region != null && InfestationLikeCellFinder.NoRoofAroundAndWalkable(intVec, map))
                    {
                        InfestationLikeCellFinder.tempUnroofedRegions.Add(region);
                    }
                }
            }
            Dijkstra <Region> .Run(InfestationLikeCellFinder.tempUnroofedRegions, (Region x) => x.Neighbors, (Region a, Region b) => Mathf.Sqrt((float)a.extentsClose.CenterCell.DistanceToSquared(b.extentsClose.CenterCell)), InfestationLikeCellFinder.regionsDistanceToUnroofed, null);

            InfestationLikeCellFinder.tempUnroofedRegions.Clear();
        }
 // Token: 0x0600368E RID: 13966 RVA: 0x001A127C File Offset: 0x0019F67C
 private static void CalculateLocationCandidates(Map map, bool allowFogged)
 {
     InfestationLikeCellFinder.locationCandidates.Clear();
     InfestationLikeCellFinder.CalculateTraversalDistancesToUnroofed(map);
     InfestationLikeCellFinder.CalculateClosedAreaSizeGrid(map);
     InfestationLikeCellFinder.CalculateDistanceToColonyBuildingGrid(map);
     for (int i = 0; i < map.Size.z; i++)
     {
         for (int j = 0; j < map.Size.x; j++)
         {
             IntVec3 cell    = new IntVec3(j, 0, i);
             float   scoreAt = InfestationLikeCellFinder.GetScoreAt(cell, map, allowFogged); // allowFogged
             if (scoreAt > 0f)
             {
                 InfestationLikeCellFinder.locationCandidates.Add(new InfestationLikeCellFinder.LocationCandidate(cell, scoreAt));
             }
         }
     }
 }
        // Token: 0x06000E64 RID: 3684 RVA: 0x0006B8B4 File Offset: 0x00069CB4
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            Map map = (Map)parms.target;

            if (intVec == IntVec3.Invalid)
            {
                if (!InfestationLikeCellFinder.TryFindCell(out intVec, out lc, map, true, false, true, true))
                {
                    if (!InfestationLikeCellFinder.TryFindCell(out intVec, out lc, map, true, true, true, true))
                    {
                        return(false);
                    }
                }
            }
            int hivelikeCount = Mathf.Max(GenMath.RoundRandom(parms.points / 220f), 1);

            if (def.tags.Contains("TunnelLike"))
            {
                //Log.Message(string.Format("TunnelLike"));
                Thing t = this.SpawnTunnelLikeCluster(hivelikeCount, map, parms);
                base.SendStandardLetter(parms, new TargetInfo(intVec, map, false), Array.Empty <NamedArgument>());

                /*
                 * Map map = (Map)parms.target;
                 * int hiveCount = Mathf.Max(GenMath.RoundRandom(parms.points / 220f), 1);
                 * Thing t = this.SpawnTunnels(hiveCount, map);
                 * base.SendStandardLetter(t, null, new string[0]);
                 * Find.TickManager.slower.SignalForceNormalSpeedShort();
                 * return true;
                 */
            }
            else
            {
                //Log.Message(string.Format("HiveLike"));

                Thing t = this.SpawnHiveLikeCluster(hivelikeCount, map);
                base.SendStandardLetter(parms, new TargetInfo(intVec, map, false), Array.Empty <NamedArgument>());
            }
            Find.TickManager.slower.SignalForceNormalSpeedShort();
            return(true);
        }
        // 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);
        }
Пример #9
0
        // Token: 0x06000E65 RID: 3685 RVA: 0x0006B914 File Offset: 0x00069D14
        private Thing SpawnTunnels(int hivelikeCount, Map map)
        {
            IntVec3 loc;

            if (!InfestationLikeCellFinder.TryFindCell(out loc, map))
            {
                Log.Message(string.Format("TryFindCell: {0} From !InfestationLikeCellFinder.TryFindCell(out loc, map)", !InfestationLikeCellFinder.TryFindCell(out loc, map)));
                return(null);
            }
            ThingDef_HiveLike thingDef = (ThingDef_HiveLike)this.def.shipPart;
            Thing             thing    = GenSpawn.Spawn(ThingMaker.MakeThing(thingDef.TunnelDef, null), loc, map, WipeMode.FullRefund);

            for (int i = 0; i < hivelikeCount - 1; i++)
            {
                loc = CompSpawnerHiveLikes.FindChildHiveLocation(thing.Position, map, this.def.shipPart, this.def.shipPart.GetCompProperties <CompProperties_SpawnerHiveLikes>(), true, true);
                Log.Message(string.Format("loc: {0} to check", !InfestationLikeCellFinder.TryFindCell(out loc, map)));
                if (loc.IsValid)
                {
                    thing = GenSpawn.Spawn(ThingMaker.MakeThing(thingDef.TunnelDef, null), loc, map, WipeMode.FullRefund);
                    Log.Message(string.Format("spawning: {0} @ {1}", thing.Label, loc));
                }
            }
            return(thing);
        }
Пример #10
0
        // Token: 0x0600368B RID: 13963 RVA: 0x001A0E1C File Offset: 0x0019F21C
        public static bool TryFindCell(out IntVec3 cell, out IntVec3 locationC, Map map, bool allowFogged = false, bool allowUnroofed = false, bool allowDigging = false, bool forceNew = false)
        {
            InfestationLikeCellFinder.CalculateLocationCandidates(map, allowFogged, allowUnroofed, allowDigging, forceNew);
            if (!forceNew)
            {
                //    Log.Message("exsisting hivelocs allowed");
                if (!map.HiveGrid().Hivelist.NullOrEmpty())
                {
                    cell      = map.HiveGrid().Hivelist.RandomElement().Position;
                    locationC = map.HiveGrid().Hivelist.RandomElement().Position;
                    return(true);
                }
                if (!map.HiveGrid().HiveLoclist.NullOrEmpty())
                {
                    cell      = map.HiveGrid().HiveLoclist.RandomElement();
                    locationC = map.HiveGrid().HiveLoclist.RandomElement();
                    return(true);
                }
            }

            Predicate <IntVec3> validator = delegate(IntVec3 y)
            {
                if (y.GetTerrain(map).HasTag("Water") || y.InNoBuildEdgeArea(map))
                {
                    return(false);
                }
                bool roofed    = (!allowUnroofed && y.Roofed(map)) || allowUnroofed;
                bool score     = InfestationLikeCellFinder.GetScoreAt(y, map, allowFogged, allowUnroofed, allowDigging) > 0f;
                bool XenohiveA = y.GetFirstThing(map, XenomorphDefOf.RRY_Xenomorph_Hive) == null;
                bool XenohiveB = y.GetFirstThing(map, XenomorphDefOf.RRY_Xenomorph_Hive_Child) == null;
                bool filled    = y.Filled(map) && !allowDigging;
                bool edifice   = y.GetEdifice(map).DestroyedOrNull() || allowDigging;
                bool building  = y.GetFirstBuilding(map).DestroyedOrNull() || allowDigging;
                bool thing     = !y.GetThingList(map).Any(x => x.GetType() == typeof(Building_XenomorphCocoon) || x.GetType() == typeof(Building_XenoEgg) || x.GetType() == typeof(HiveLike)) || !forceNew;

                bool result = score && XenohiveA && XenohiveB && !filled && edifice && building && thing && roofed;
                return(result);
            };

            if (!InfestationLikeCellFinder.locationCandidates.Where(y => validator(y.cell)).TryRandomElementByWeight((InfestationLikeCellFinder.LocationCandidate x) => x.score, out LocationCandidate locationCandidate))
            {
                //    Log.Message(string.Format("Cant find any suitable location candidates"));
                cell = IntVec3.Invalid;
                if (!InfestationCellFinder.TryFindCell(out cell, map))
                {
                    if (!map.HiveGrid().PotentialHiveLoclist.NullOrEmpty())
                    {
                        if (map.HiveGrid().PotentialHiveLoclist.Any(x => (x.X < 50 || x.Z < 50) && (!forceNew || !x.HiveLoc.GetThingList(map).Any(y => y.GetType() == typeof(HiveLike)))))
                        {
                            //    Log.Message(string.Format("PotentialHiveLoclist location candidates 50 {0}", forceNew));
                            cell      = map.HiveGrid().PotentialHiveLoclist.Where(x => (x.X < 50 || x.Z < 50) && (!forceNew || !x.HiveLoc.GetThingList(map).Any(y => y.GetType() == typeof(HiveLike)))).RandomElement().HiveLoc;
                            locationC = cell;
                        }
                        else
                        if (map.HiveGrid().PotentialHiveLoclist.Any(x => (x.X < 75 || x.Z < 75) && (!forceNew || !x.HiveLoc.GetThingList(map).Any(y => y.GetType() == typeof(HiveLike)))))
                        {
                            //    Log.Message(string.Format("PotentialHiveLoclist location candidates 75 {0}", forceNew));
                            cell      = map.HiveGrid().PotentialHiveLoclist.Where(x => (x.X < 75 || x.Z < 75) && (!forceNew || !x.HiveLoc.GetThingList(map).Any(y => y.GetType() == typeof(HiveLike)))).RandomElement().HiveLoc;
                            locationC = cell;
                        }
                        else
                        {
                            //    Log.Message(string.Format("PotentialHiveLoclist location candidates {0}", forceNew));
                            cell      = map.HiveGrid().PotentialHiveLoclist.Where(x => (!forceNew || !x.HiveLoc.GetThingList(map).Any(y => y.GetType() == typeof(HiveLike)))).RandomElement().HiveLoc;
                            locationC = cell;
                        }
                        return(true);
                    }

                    cell      = IntVec3.Invalid;
                    locationC = IntVec3.Invalid;
                    return(false);
                }
            }
            locationC = locationCandidate.cell;
            cell      = CellFinder.FindNoWipeSpawnLocNear(locationCandidate.cell, map, XenomorphDefOf.RRY_Xenomorph_Hive, Rot4.North, 2, validator);
            ThingDef td = XenomorphDefOf.RRY_Xenomorph_Hive_Slime;

            GenSpawn.Spawn(td, cell, map);
            return(true);
        }
Пример #11
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);
        }
Пример #12
0
        // Token: 0x06000E63 RID: 3683 RVA: 0x0006B874 File Offset: 0x00069C74
        protected override bool CanFireNowSub(IncidentParms parms)
        {
            Map map = (Map)parms.target;

            return(base.CanFireNowSub(parms) && HiveLikeUtility.TotalSpawnedHiveLikesCount(map) < 30 && InfestationLikeCellFinder.TryFindCell(out intVec, map));

            /*
             * Map map = (Map)parms.target;
             * IntVec3 intVec = DropCellFinder.RandomDropSpot(map);
             * return base.CanFireNowSub(parms) && HiveLikeUtility.TotalSpawnedHiveLikesCount(map) < 100;
             */
        }
        // Token: 0x0600368C RID: 13964 RVA: 0x001A0EAC File Offset: 0x0019F2AC
        private static float GetScoreAt(IntVec3 cell, Map map, bool allowFogged)
        {
            if ((float)InfestationLikeCellFinder.distToColonyBuilding[cell] < 20f)
            {
                return(0f);
            }
            if (!cell.Walkable(map) && !allowFogged)
            {
                return(0f);
            }
            if (cell.Fogged(map) && !allowFogged)
            {
                return(0f);
            }
            if (InfestationLikeCellFinder.CellHasBlockingThings(cell, map) && !allowFogged)
            {
                return(0f);
            }
            if (!cell.Roofed(map) || !cell.GetRoof(map).isThickRoof&& !allowFogged)
            {
                return(0f);
            }
            Region region = cell.GetRegion(map, RegionType.Set_Passable);

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

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

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

            if (!InfestationLikeCellFinder.regionsDistanceToUnroofed.TryGetValue(region, out float 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);
            }
            return(num7);
        }