public static Thing SpawnTunnels(ThingDef hiveDef, int hiveCount, Map map, IntVec3 cell, bool spawnAnywhereIfNoGoodCell = false, bool ignoreRoofedRequirement = false, string questTag = null, Faction faction = null) { ThingDef HiveDef = hiveDef ?? RimWorld.ThingDefOf.Hive; HiveDefExtension HiveExt = HiveDef.GetModExtension <HiveDefExtension>(); ThingDef TunnelDef = HiveExt?.TunnelDef ?? RimWorld.ThingDefOf.TunnelHiveSpawner; HiveDefExtension extension = HiveDef.GetModExtension <HiveDefExtension>(); if (extension != null && extension.TunnelDef != null) { TunnelDef = extension.TunnelDef; } Thing thing = GenSpawn.Spawn(ThingMaker.MakeThing(TunnelDef), cell, map, WipeMode.FullRefund); TunnelHiveSpawner hiveSpawner = thing as TunnelHiveSpawner; if (hiveSpawner != null) { if (hiveSpawner.faction == null && faction != null) { hiveSpawner.faction = faction; } } if (hiveSpawner.SpawnedFaction != null) { // Log.Message(hiveSpawner.Faction.def.defName + ": " + hiveSpawner.faction); } QuestUtility.AddQuestTag(thing, questTag); CompSpawnerHives spawnerHives = thing.TryGetComp <CompSpawnerHives>(); if (spawnerHives?.Props.tunnelDef != null) { TunnelDef = spawnerHives.Props.tunnelDef; } for (int i = 0; i < hiveCount - 1; i++) { cell = CompSpawnerHives.FindChildHiveLocation(thing.Position, map, HiveDef, HiveDef.GetCompProperties <CompProperties_SpawnerHives>(), ignoreRoofedRequirement, allowUnreachable: true); if (cell.IsValid) { thing = GenSpawn.Spawn(ThingMaker.MakeThing(TunnelDef), cell, map, WipeMode.FullRefund); hiveSpawner = thing as TunnelHiveSpawner; if (hiveSpawner != null) { if (hiveSpawner.faction == null && faction != null) { hiveSpawner.faction = faction; } } if (hiveSpawner.SpawnedFaction != null) { // Log.Message(hiveSpawner.Faction.def.defName + ": " + hiveSpawner.faction); } QuestUtility.AddQuestTag(thing, questTag); } } return(thing); }
public static bool TryFindCell(out IntVec3 cell, Map map, HiveDefExtension HiveExt) { CalculateLocationCandidates(map, HiveExt); if (!locationCandidates.TryRandomElementByWeight((LocationCandidate x) => x.score, out LocationCandidate result)) { cell = IntVec3.Invalid; return(false); } cell = CellFinder.FindNoWipeSpawnLocNear(result.cell, map, RimWorld.ThingDefOf.Hive, Rot4.North, 2, (IntVec3 x) => GetScoreAt(x, map, HiveExt) > 0f && x.GetFirstThing(map, RimWorld.ThingDefOf.Hive) == null && x.GetFirstThing(map, RimWorld.ThingDefOf.TunnelHiveSpawner) == null); return(true); }
// Token: 0x06005333 RID: 21299 RVA: 0x001BD108 File Offset: 0x001BB308 public bool TrySpawnChildHive(bool ignoreRoofedRequirement, out Hive newHive) { if (!this.CanSpawnChildHive) { newHive = null; return(false); } HiveDefExtension ext = null; if (this.parent.def.HasModExtension <HiveDefExtension>()) { ext = this.parent.def.GetModExtension <HiveDefExtension>(); } ThingDef thingDef = Props.hiveDef ?? this.parent.def; IntVec3 loc = CompSpawnerHives.FindChildHiveLocation(this.parent.OccupiedRect().AdjacentCells.RandomElement(), this.parent.Map, thingDef, this.Props, ignoreRoofedRequirement, false, CurrentRadius); if (!loc.IsValid) { newHive = null; Log.Warning("this !loc.IsValid"); return(false); } newHive = (Hive)ThingMaker.MakeThing(thingDef, null); if (newHive.Faction != this.parent.Faction) { newHive.SetFaction(this.parent.Faction, null); } Hive hive = this.parent as Hive; if (hive != null) { if (hive.CompDormant.Awake) { newHive.CompDormant.WakeUp(); } newHive.questTags = hive.questTags; } if (newHive.Ext?.TunnelDef != null) { TunnelHiveSpawner tunnel = (TunnelHiveSpawner)ThingMaker.MakeThing(newHive.Ext.TunnelDef, null); tunnel.hive = newHive; GenSpawn.Spawn(tunnel, loc, this.parent.Map, WipeMode.FullRefund); this.CalculateNextHiveSpawnTick(); } else { GenSpawn.Spawn(newHive, loc, this.parent.Map, WipeMode.FullRefund); this.CalculateNextHiveSpawnTick(); } return(true); }
protected override bool TryExecuteWorker(IncidentParms parms) { if (def.mechClusterBuilding == null) { return(false); } if (!def.mechClusterBuilding.HasModExtension <HiveDefExtension>()) { return(false); } HiveDefExtension ext = def.mechClusterBuilding.GetModExtension <HiveDefExtension>(); Map map = (Map)parms.target; if (parms.faction == null) { try { IEnumerable <Faction> factions = Find.FactionManager.AllFactions.Where(x => x.def.defName.Contains(ext.Faction.defName)); if (!factions.EnumerableNullOrEmpty()) { parms.faction = factions.RandomElement(); } else { parms.faction = FactionGenerator.NewGeneratedFaction(ext.Faction); } // Log.Message(parms.faction.def.defName); } catch (System.Exception) { Faction faction = Find.FactionManager.FirstFactionOfDef(ext.Faction); if (faction == null) { faction = FactionGenerator.NewGeneratedFaction(ext.Faction); } parms.faction = faction; } } CompProperties_SpawnerPawn spawnerPawn = def.mechClusterBuilding.GetCompProperties <CompProperties_SpawnerPawn>(); float points = spawnerPawn?.initialPawnsPoints ?? 250f; int count = Mathf.Max(GenMath.RoundRandom(parms.points / points), 1); Thing t = InfestationUtility.SpawnTunnels(def.mechClusterBuilding, count, map, true, true, faction: parms.faction); SendStandardLetter(parms, t); Find.TickManager.slower.SignalForceNormalSpeedShort(); return(true); }
// Token: 0x06003C69 RID: 15465 RVA: 0x0013F354 File Offset: 0x0013D554 protected override bool CanFireNowSub(IncidentParms parms) { Map map = (Map)parms.target; IntVec3 intVec; if (def.mechClusterBuilding == null) { return(false); } if (!def.mechClusterBuilding.HasModExtension <HiveDefExtension>()) { return(false); } ThingDef hiveDef = def.mechClusterBuilding; HiveDefExtension hive = hiveDef.GetModExtension <HiveDefExtension>(); return(this.TryFindCell(out intVec, map)); }
/* * public static void DebugDraw() * { * if (DebugViewSettings.drawInfestationChance) * { * if (tmpCachedInfestationChanceCellColors == null) * { * tmpCachedInfestationChanceCellColors = new List<Pair<IntVec3, float>>(); * } * if (Time.frameCount % 8 == 0) * { * tmpCachedInfestationChanceCellColors.Clear(); * Map currentMap = Find.CurrentMap; * CellRect currentViewRect = Find.CameraDriver.CurrentViewRect; * currentViewRect.ClipInsideMap(currentMap); * currentViewRect = currentViewRect.ExpandedBy(1); * CalculateTraversalDistancesToUnroofed(currentMap); * CalculateClosedAreaSizeGrid(currentMap); * CalculateDistanceToColonyBuildingGrid(currentMap); * float num = 0.001f; * for (int i = 0; i < currentMap.Size.z; i++) * { * for (int j = 0; j < currentMap.Size.x; j++) * { * float scoreAt = GetScoreAt(new IntVec3(j, 0, i), currentMap, HiveExt); * 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 (currentViewRect.Contains(intVec)) * { * float scoreAt2 = GetScoreAt(intVec, currentMap); * if (!(scoreAt2 <= 7.5f)) * { * float second = GenMath.LerpDouble(7.5f, num, 0f, 1f, scoreAt2); * tmpCachedInfestationChanceCellColors.Add(new Pair<IntVec3, float>(intVec, second)); * } * } * } * } * } * for (int m = 0; m < tmpCachedInfestationChanceCellColors.Count; m++) * { * IntVec3 first = tmpCachedInfestationChanceCellColors[m].First; * float second2 = tmpCachedInfestationChanceCellColors[m].Second; * CellRenderer.RenderCell(first, SolidColorMaterials.SimpleSolidColorMaterial(new Color(0f, 0f, 1f, second2))); * } * } * else * { * tmpCachedInfestationChanceCellColors = null; * } * } */ private static void CalculateLocationCandidates(Map map, HiveDefExtension HiveExt) { locationCandidates.Clear(); CalculateTraversalDistancesToUnroofed(map); CalculateClosedAreaSizeGrid(map); 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 = GetScoreAt(cell, map, HiveExt); if (!(scoreAt <= 0f)) { locationCandidates.Add(new LocationCandidate(cell, scoreAt)); } } } }
protected override bool CanFireNowSub(IncidentParms parms) { Map map = (Map)parms.target; if (def.mechClusterBuilding == null) { return(false); } if (!def.mechClusterBuilding.HasModExtension <HiveDefExtension>()) { return(false); } HiveDefExtension HiveExt = def.mechClusterBuilding.GetModExtension <HiveDefExtension>(); IntVec3 cell; if (/*base.CanFireNowSub(parms) && */ HiveUtility.TotalSpawnedHivesCount(map, def.mechClusterBuilding) < 30) { return(InfestationCellFinder.TryFindCell(out cell, map, HiveExt)); } return(false); }
public static Thing SpawnTunnels(ThingDef hiveDef, int hiveCount, Map map, bool spawnAnywhereIfNoGoodCell = false, bool ignoreRoofedRequirement = false, string questTag = null, Faction faction = null) { ThingDef HiveDef = hiveDef ?? RimWorld.ThingDefOf.Hive; HiveDefExtension HiveExt = HiveDef.GetModExtension <HiveDefExtension>(); ThingDef TunnelDef = HiveExt?.TunnelDef ?? RimWorld.ThingDefOf.TunnelHiveSpawner; if (!InfestationCellFinder.TryFindCell(out IntVec3 cell, map, HiveExt)) { 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); } } HiveDefExtension extension = HiveDef.GetModExtension <HiveDefExtension>(); if (extension != null && extension.TunnelDef != null) { TunnelDef = extension.TunnelDef; } Thing thing = GenSpawn.Spawn(ThingMaker.MakeThing(TunnelDef), cell, map, WipeMode.FullRefund); TunnelHiveSpawner hiveSpawner = thing as TunnelHiveSpawner; if (hiveSpawner != null) { if (hiveSpawner.faction == null && faction != null) { hiveSpawner.faction = faction; } } if (hiveSpawner.SpawnedFaction != null) { // Log.Message(hiveSpawner.Faction.def.defName + ": " + hiveSpawner.faction); } QuestUtility.AddQuestTag(thing, questTag); for (int i = 0; i < hiveCount - 1; i++) { cell = CompSpawnerHives.FindChildHiveLocation(thing.Position, map, HiveDef, HiveDef.GetCompProperties <CompProperties_SpawnerHives>(), ignoreRoofedRequirement, allowUnreachable: true); if (cell.IsValid) { thing = GenSpawn.Spawn(ThingMaker.MakeThing(TunnelDef), cell, map, WipeMode.FullRefund); hiveSpawner = thing as TunnelHiveSpawner; if (hiveSpawner != null) { if (hiveSpawner.faction == null && faction != null) { hiveSpawner.faction = faction; } } if (hiveSpawner.SpawnedFaction != null) { // Log.Message(hiveSpawner.Faction.def.defName+": "+ hiveSpawner.faction); } QuestUtility.AddQuestTag(thing, questTag); } } return(thing); }
// Token: 0x06003C6A RID: 15466 RVA: 0x0013F378 File Offset: 0x0013D578 protected override bool TryExecuteWorker(IncidentParms parms) { Map map = (Map)parms.target; IntVec3 intVec; if (def.mechClusterBuilding == null) { return(false); } if (!def.mechClusterBuilding.HasModExtension <HiveDefExtension>()) { return(false); } ThingDef hiveDef = def.mechClusterBuilding; HiveDefExtension hive = hiveDef.GetModExtension <HiveDefExtension>(); Faction faction = null; if (parms.faction != null) { faction = parms.faction; } else { if (hive.Faction != null) { IEnumerable <Faction> factions = CandidateFactions(map, hive.Faction.defName); if (!factions.EnumerableNullOrEmpty()) { faction = factions.RandomElement(); } else { faction = Find.FactionManager.FirstFactionOfDef(hive.Faction); } } else { return(false); } } if (!this.TryFindCell(out intVec, map)) { return(false); } List <Thing> list = new List <Thing>(); // Log.Message("TunnelRaidSpawner"); TunnelRaidSpawner tunnelHiveSpawner = (TunnelRaidSpawner)ThingMaker.MakeThing(ThingDefOf.Tunneler_ExtraHives, null); tunnelHiveSpawner.spawnHive = false; Rand.PushState(); tunnelHiveSpawner.initialPoints = Mathf.Max(parms.points * Rand.Range(0.3f, 0.6f), 200f); Rand.PopState(); tunnelHiveSpawner.spawnedByInfestationThingComp = true; tunnelHiveSpawner.ResultSpawnDelay = new FloatRange(0.1f, 0.5f); tunnelHiveSpawner.spawnablePawnKinds = faction.def.pawnGroupMakers.Where(x => x.kindDef == RimWorld.PawnGroupKindDefOf.Combat || x.kindDef == PawnGroupKindDefOf.Tunneler_ExtraHives).RandomElement().options; if (tunnelHiveSpawner.SpawnedFaction == null) { if (faction != null) { // Log.Message(faction.Name); tunnelHiveSpawner.SpawnedFaction = faction; } } // Log.Message("TunnelRaidSpawner "+ tunnelHiveSpawner.Faction); list.Add(tunnelHiveSpawner); List <Thing> outThings; Generate(out outThings); list.AddRange(outThings); SkyfallerMaker.SpawnSkyfaller(ThingDefOf.InfestedMeteoriteIncoming_ExtraHives, list, intVec, map); LetterDef baseLetterDef = list[list.Count - 1].def.building.isResourceRock ? LetterDefOf.PositiveEvent : LetterDefOf.NeutralEvent; string str = string.Format(this.def.letterText, list[list.Count - 1].def.label).CapitalizeFirst(); base.SendStandardLetter(this.def.letterLabel + ": " + list[list.Count - 1].def.LabelCap, str, baseLetterDef, parms, new TargetInfo(intVec, map, false), Array.Empty <NamedArgument>()); return(true); }
// Token: 0x06003E46 RID: 15942 RVA: 0x00148B70 File Offset: 0x00146D70 protected override bool TryExecuteWorker(IncidentParms parms) { Map map = (Map)parms.target; if (def.mechClusterBuilding == null) { Log.Error("Hivedef (def.mechClusterBuilding) not set"); return(false); } if (!def.mechClusterBuilding.HasModExtension <HiveDefExtension>()) { Log.Error("Hivedef (def.mechClusterBuilding) missing HiveExtension"); return(false); } ThingDef hiveDef = def.mechClusterBuilding; HiveDefExtension hive = hiveDef.GetModExtension <HiveDefExtension>(); if (hive == null) { return(false); } if (parms.faction == null) { try { parms.faction = Find.FactionManager.AllFactions.Where(x => x.def.defName.Contains(hive.Faction.defName)) /*.Where(x => (float)GenDate.DaysPassed >= x.def.earliestRaidDays)*/.RandomElement(); // Log.Message(parms.faction.def.defName); } catch (System.Exception) { parms.faction = Find.FactionManager.FirstFactionOfDef(hive.Faction); } } ThingDef tunnelDef = hive.TunnelDef ?? RimWorld.ThingDefOf.TunnelHiveSpawner; IncidentWorker_GrowZoneInfestation.tmpZones.Clear(); ExtraInfestationIncidentUtility.GetUsableGrowZones(map, IncidentWorker_GrowZoneInfestation.tmpZones); Zone_Growing growZone; IntVec3 intVec = IntVec3.Invalid; if (IncidentWorker_GrowZoneInfestation.tmpZones.TryRandomElementByWeight(x => x.Cells.Count, out growZone)) { intVec = CellFinder.FindNoWipeSpawnLocNear(growZone.Cells.RandomElement(), map, tunnelDef, Rot4.North, 2, (IntVec3 x) => x.Walkable(map) && x.GetFirstThing(map, hiveDef) == null && x.GetFirstThingWithComp <ThingComp>(map) == null && x.GetFirstThing(map, RimWorld.ThingDefOf.Hive) == null && x.GetFirstThing(map, RimWorld.ThingDefOf.TunnelHiveSpawner) == null && !x.Roofed(map) && x.UsesOutdoorTemperature(map)); if (intVec == growZone.Position) { Log.Error("intVec == growZone.Position"); return(false); } } else { RCellFinder.TryFindRandomPawnEntryCell(out intVec, map, 0); if (RCellFinder.TryFindRandomSpotJustOutsideColony(intVec, map, out intVec)) { Log.Warning("Found spot outside colony"); } else { Log.Warning("failed to find interesting location, use map edge"); } // intVec = CellFinder.FindNoWipeSpawnLocNear(intVec, map, hiveDef, Rot4.North, 10, (IntVec3 x) => x.Walkable(map) && x.GetFirstThing(map, hiveDef) == null && x.GetFirstThingWithComp<ThingComp>(map) == null && x.GetFirstThing(map, ThingDefOf.Hive) == null && x.GetFirstThing(map, ThingDefOf.TunnelHiveSpawner) == null && !x.Roofed(map) && x.UsesOutdoorTemperature(map)); } if (intVec == IntVec3.Invalid) { Log.Error("intVec == IntVec3.Invalid"); return(false); } CompProperties_SpawnerPawn spawnerPawn = def.mechClusterBuilding.GetCompProperties <CompProperties_SpawnerPawn>(); float points = spawnerPawn?.initialPawnsPoints ?? 250f; Thing t = InfestationUtility.SpawnTunnels(def.mechClusterBuilding, Mathf.Max(GenMath.RoundRandom(parms.points / points), 1), map, intVec, true, true, faction: parms.faction); /* * TunnelHiveSpawner tunnelHiveSpawner = (TunnelHiveSpawner)ThingMaker.MakeThing(tunnelDef, null); * tunnelHiveSpawner.spawnHive = true; * tunnelHiveSpawner.insectsPoints = Mathf.Clamp(parms.points * Rand.Range(0.3f, 0.6f), 200f, 1000f); * tunnelHiveSpawner.spawnedByInfestationThingComp = true; * GenSpawn.Spawn(tunnelHiveSpawner, intVec, map, WipeMode.FullRefund); */ base.SendStandardLetter(parms, new TargetInfo(intVec, map, false), Array.Empty <NamedArgument>()); return(true); }
// Token: 0x06003E46 RID: 15942 RVA: 0x00148B70 File Offset: 0x00146D70 protected override bool TryExecuteWorker(IncidentParms parms) { Map map = (Map)parms.target; if (def.mechClusterBuilding == null) { return(false); } if (!def.mechClusterBuilding.HasModExtension <HiveDefExtension>()) { return(false); } ThingDef hiveDef = def.mechClusterBuilding; HiveDefExtension hive = hiveDef.GetModExtension <HiveDefExtension>(); if (hive == null) { return(false); } HiveDefExtension ext = def.mechClusterBuilding.GetModExtension <HiveDefExtension>(); if (parms.faction == null) { try { parms.faction = Find.FactionManager.AllFactions.Where(x => x.def.defName.Contains(ext.Faction.defName)) /*.Where(x => (float)GenDate.DaysPassed >= x.def.earliestRaidDays)*/.RandomElement(); // Log.Message(parms.faction.def.defName); } catch (System.Exception) { parms.faction = Find.FactionManager.FirstFactionOfDef(ext.Faction); } } ThingDef tunnelDef = hive.TunnelDef ?? RimWorld.ThingDefOf.TunnelHiveSpawner; IncidentWorker_DeepDrillInfestation.tmpDrills.Clear(); DeepDrillInfestationIncidentUtility.GetUsableDeepDrills(map, IncidentWorker_DeepDrillInfestation.tmpDrills); Thing deepDrill; if (!IncidentWorker_DeepDrillInfestation.tmpDrills.TryRandomElement(out deepDrill)) { return(false); } IntVec3 intVec = CellFinder.FindNoWipeSpawnLocNear(deepDrill.Position, map, tunnelDef, Rot4.North, 2, (IntVec3 x) => x.Walkable(map) && x.GetFirstThing(map, deepDrill.def) == null && x.GetFirstThingWithComp <ThingComp>(map) == null && x.GetFirstThing(map, RimWorld.ThingDefOf.Hive) == null && x.GetFirstThing(map, RimWorld.ThingDefOf.TunnelHiveSpawner) == null); if (intVec == deepDrill.Position) { return(false); } TunnelHiveSpawner tunnelHiveSpawner = (TunnelHiveSpawner)ThingMaker.MakeThing(tunnelDef, null); tunnelHiveSpawner.spawnHive = false; Rand.PushState(); tunnelHiveSpawner.initialPoints = Mathf.Clamp(parms.points * Rand.Range(0.3f, 0.6f), 200f, 1000f); Rand.PopState(); tunnelHiveSpawner.spawnedByInfestationThingComp = true; GenSpawn.Spawn(tunnelHiveSpawner, intVec, map, WipeMode.FullRefund); deepDrill.TryGetComp <CompCreatesInfestations>().Notify_CreatedInfestation(); base.SendStandardLetter(parms, new TargetInfo(tunnelHiveSpawner.Position, map, false), Array.Empty <NamedArgument>()); return(true); }
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); }