public override void ExposeData() { base.ExposeData(); Scribe_Values.Look <int>(ref this.weatherEndingTick, "weatherEndingTick", 0, true); if (Scribe.mode == LoadSaveMode.PostLoadInit) { purpleFog.durationRange = new IntRange(10000, 10000); purpleFoggyRain.durationRange = new IntRange(10000, 10000); empStorm.durationRange = new IntRange(10000, 10000); foreach (Map map in AffectedMaps) { var comp = map.Parent.GetComponent <WorldObjectComp_InfectedTile>(); if (comp != null) { int count = map.listerThings.ThingsOfDef(PurpleIvyDefOf.PurpleIvy).Count; bool temp; this.fogProgress[map] = PurpleIvyUtils.getFogProgressWithOuterSources(count, comp, out temp); } else { Log.Message("3 Comp null - GameCondition_PurpleFog"); } } } }
public static void Postfix(Map __instance) { Log.Message("WeatherChecker: " + __instance.ToString()); bool comeFromOuterSource; var tempComp = new WorldObjectComp_InfectedTile(); tempComp.infectedTile = __instance.Tile; if (PurpleIvyUtils.getFogProgressWithOuterSources(0, tempComp, out comeFromOuterSource) > 0f && !__instance.gameConditionManager.ConditionIsActive(PurpleIvyDefOf.PurpleFogGameCondition)) { GameCondition_PurpleFog gameCondition = (GameCondition_PurpleFog)GameConditionMaker.MakeConditionPermanent (PurpleIvyDefOf.PurpleFogGameCondition); __instance.gameConditionManager.RegisterCondition(gameCondition); tempComp.parent = __instance.Parent; tempComp.StartInfection(); tempComp.gameConditionCaused = PurpleIvyDefOf.PurpleFogGameCondition; tempComp.counter = 0; tempComp.infected = false; tempComp.infectedTile = __instance.Tile; tempComp.radius = tempComp.GetRadius(); PurpleIvyData.TotalFogProgress[tempComp] = PurpleIvyUtils.getFogProgress(tempComp.counter); tempComp.fillRadius(); __instance.Parent.AllComps.Add(tempComp); } }
public override void Init() { LessonAutoActivator.TeachOpportunity(ConceptDefOf.ForbiddingDoors, OpportunityType.Critical); LessonAutoActivator.TeachOpportunity(ConceptDefOf.AllowedAreas, OpportunityType.Critical); purpleFog.durationRange = new IntRange(10000, 10000); purpleFoggyRain.durationRange = new IntRange(10000, 10000); empStorm.durationRange = new IntRange(10000, 10000); foreach (Map map in this.AffectedMaps) { this.fogProgress[map] = 0f; int count = map.listerThings.ThingsOfDef(PurpleIvyDefOf.PurpleIvy).Count; count += map.listerThings.ThingsOfDef(PurpleIvyDefOf.EggSac).Count; count += map.listerThings.ThingsOfDef(PurpleIvyDefOf.EggSacBeta).Count; count += map.listerThings.ThingsOfDef(PurpleIvyDefOf.EggSacGamma).Count; count += map.listerThings.ThingsOfDef(PurpleIvyDefOf.EggSacNestGuard).Count; count += map.listerThings.ThingsOfDef(PurpleIvyDefOf.ParasiteEgg).Count; count += map.listerThings.ThingsOfDef(PurpleIvyDefOf.GasPump).Count; count += map.listerThings.ThingsOfDef(PurpleIvyDefOf.GenTurretBase).Count; count += map.listerThings.ThingsOfDef(PurpleIvyDefOf.Turret_GenMortarSeed).Count; count += map.listerThings.ThingsOfDef(PurpleIvyDefOf.PI_Nest).Count; var comp = map.Parent.GetComponent <WorldObjectComp_InfectedTile>(); if (comp != null) { bool temp; this.fogProgress[map] = PurpleIvyUtils.getFogProgressWithOuterSources(count, comp, out temp); if (this.fogProgress[map] <= 0) { this.End(); Find.LetterStack.ReceiveLetter("PurpleFogReceded".Translate(), "PurpleFogRecededDesc".Translate(), LetterDefOf.PositiveEvent); } } else { Log.Message("1 Comp null - GameCondition_PurpleFog"); } weatherAge = map.weatherManager.curWeatherAge; bool fog = map.weatherManager.CurWeatherPerceived.overlayClasses .Contains(typeof(WeatherOverlay_Fog)); if (fog != true) { Log.Message("Transitioning to purple fog in the " + map); map.weatherManager.TransitionTo(purpleFog); } else { Log.Message("Transitioning to purple fog in the " + map); map.weatherManager.TransitionTo(WeatherDefOf.Clear); map.weatherManager.TransitionTo(purpleFog); map.weatherManager.curWeatherAge = weatherAge; } } }
public override float SkyTargetLerpFactor(Map map) { if (this.fogProgress.ContainsKey(map)) { return(this.fogProgress[map]); } else { Log.Error("Something went wrong with the map " + map + ". It was not represented in " + "the fogProgress dictionary."); bool temp; var comp = map.Parent.GetComponent <WorldObjectComp_InfectedTile>(); if (comp == null) { Log.Message("Adding new comp, due missing the one in the mapParent"); comp = new WorldObjectComp_InfectedTile(); int count = map.listerThings.ThingsOfDef(PurpleIvyDefOf.PurpleIvy).Count; count += map.listerThings.ThingsOfDef(PurpleIvyDefOf.EggSac).Count; count += map.listerThings.ThingsOfDef(PurpleIvyDefOf.EggSacBeta).Count; count += map.listerThings.ThingsOfDef(PurpleIvyDefOf.EggSacGamma).Count; count += map.listerThings.ThingsOfDef(PurpleIvyDefOf.EggSacNestGuard).Count; count += map.listerThings.ThingsOfDef(PurpleIvyDefOf.ParasiteEgg).Count; count += map.listerThings.ThingsOfDef(PurpleIvyDefOf.GasPump).Count; count += map.listerThings.ThingsOfDef(PurpleIvyDefOf.GenTurretBase).Count; count += map.listerThings.ThingsOfDef(PurpleIvyDefOf.Turret_GenMortarSeed).Count; count += map.listerThings.ThingsOfDef(PurpleIvyDefOf.PI_Nest).Count; comp.parent = map.Parent; comp.StartInfection(); comp.gameConditionCaused = PurpleIvyDefOf.PurpleFogGameCondition; comp.counter = count; comp.infectedTile = map.Tile; comp.radius = comp.GetRadius(); PurpleIvyData.TotalFogProgress[comp] = PurpleIvyUtils.getFogProgress(comp.counter); comp.fillRadius(); map.Parent.AllComps.Add(comp); PurpleIvyData.TotalFogProgress[comp] = PurpleIvyUtils.getFogProgress(count); this.fogProgress[map] = PurpleIvyUtils.getFogProgressWithOuterSources(count, comp, out temp); } else { this.fogProgress[map] = 0f; Log.Message("The fogProgress value is reset to 0"); } return(this.fogProgress[map]); } }
public override void GameComponentTick() { base.GameComponentTick(); bool temp; if (PurpleIvyData.BiomesDirty == true) { PurpleIvyUtils.UpdateBiomes(); } if (Find.TickManager.TicksGame % 3451 == 0) // same as for toxic weather { bool raidHappened = false; var tempComp = new WorldObjectComp_InfectedTile(); Log.Message("Total polluted biomes to check: " + PurpleIvyData.TotalPollutedBiomes.Count); foreach (var tile in PurpleIvyData.TotalPollutedBiomes) { var worldObjects = Find.WorldObjects.ObjectsAt(tile); foreach (var worldObject in worldObjects) { if (worldObject is Caravan caravan) { tempComp.infectedTile = caravan.Tile; float fogProgress = PurpleIvyUtils.getFogProgressWithOuterSources(0, tempComp, out temp); if (fogProgress > 0f) { foreach (Pawn p in caravan.pawns) { if (p.Faction != PurpleIvyData.AlienFaction && p.RaceProps.IsFlesh) { float num = fogProgress / 20; //TODO: balance it num *= p.GetStatValue(StatDefOf.ToxicSensitivity, true); if (num != 0f) { HealthUtility.AdjustSeverity(p, HediffDefOf.ToxicBuildup, num); } } } } if (raidHappened != true) { var infectedSites = getInfectedTilesNearby(worldObject.Tile); if (infectedSites != null && infectedSites.Count > 0) { if (fogProgress > 0.7f) { fogProgress = 0.7f; } int raidChance = (int)(fogProgress * 100); System.Random random = new System.Random(caravan.Tile); Log.Message("An attempt to ambush caravan, raid chance: " + raidChance.ToString() + " - fogProgress: " + fogProgress.ToString()); if (raidChance >= random.Next(1, 100)) { Log.Message("The caravan has been ambushed! RaidChance: " + raidChance.ToString() + " - fogProgress: " + fogProgress.ToString()); this.AlienAmbush(caravan, infectedSites.RandomElement()); raidHappened = true; } } } } else if (worldObject is MapParent mapParent) { tempComp.infectedTile = mapParent.Tile; float?fogProgress = null; if (raidHappened != true && mapParent.Map != null) { var infectedSites = getInfectedTilesNearby(mapParent.Tile); if (infectedSites != null && infectedSites.Count > 0) { fogProgress = PurpleIvyUtils.getFogProgressWithOuterSources(0, tempComp, out temp); int raidChance = (int)(fogProgress * 100) / 10; System.Random random = new System.Random(); int randomChance = random.Next(1, 100); Log.Message("An attempt to raid map, raid chance: " + raidChance.ToString() + " - randomChance: " + randomChance.ToString() + " - fogProgress: " + fogProgress.ToString()); if (raidChance >= randomChance) { Log.Message("Alien Raid! RaidChance: " + raidChance.ToString() + " - fogProgress: " + fogProgress.ToString() + " map: " + mapParent.Map.ToString()); this.AlienRaid(mapParent.Map, infectedSites.RandomElement()); raidHappened = true; } } } if (mapParent.Faction != Faction.OfPlayer && mapParent.Faction != PurpleIvyData.AlienFaction) { if (!fogProgress.HasValue) { fogProgress = PurpleIvyUtils.getFogProgressWithOuterSources(0, tempComp, out temp); } if (fogProgress > 0f) { int abandonChance = (int)(fogProgress * 100) / 10; System.Random random = new System.Random(Find.TickManager.TicksGame); Log.Message(mapParent.Faction.ToString()); Log.Message("An attempt to abandon NPC base, abandon chance: " + abandonChance.ToString() + " - fogProgress: " + fogProgress.ToString()); if (abandonChance >= random.Next(1, 100)) { Log.Message("NPC base abandoned! Chance: " + abandonChance.ToString() + " - fogProgress: " + fogProgress.ToString() + " base: " + mapParent.ToString()); Site site = (Site)WorldObjectMaker.MakeWorldObject(PurpleIvyDefOf.PI_AbandonedBase); site.Tile = mapParent.Tile; site.SetFaction(mapParent.Faction); mapParent.Destroy(); Find.LetterStack.ReceiveLetter("AbandonedBase".Translate(), "AbandonedBaseDesc".Translate(), LetterDefOf.NeutralEvent, site, mapParent.Faction, null, null, null); } else { int defeatChance = (int)(fogProgress * 100) / 10; random = new System.Random(Find.TickManager.TicksGame + mapParent.Tile); Log.Message(mapParent.Faction.ToString()); Log.Message("An attempt to defeat NPC base, defeat chance: " + abandonChance.ToString() + " - fogProgress: " + fogProgress.ToString()); if (defeatChance >= random.Next(1, 100)) { Log.Message("NPC base defeated! Chance: " + defeatChance.ToString() + " - fogProgress: " + fogProgress.ToString() + " base: " + mapParent.ToString()); Site site = (Site)WorldObjectMaker.MakeWorldObject(PurpleIvyDefOf.PI_DefeatedBase); site.Tile = mapParent.Tile; site.SetFaction(mapParent.Faction); mapParent.Destroy(); Find.LetterStack.ReceiveLetter("DefeatedBase".Translate(), "DefeatedBaseDesc".Translate(), LetterDefOf.NegativeEvent, site, mapParent.Faction, null, null, null); } } } } } } } } }
public override void GameConditionTick() { List <Map> affectedMaps = base.AffectedMaps; foreach (Map map in affectedMaps) { //Log.Message(map.weatherManager.curWeather + " - " + map.weatherManager.lastWeather, true); if (Find.TickManager.TicksGame % 60 == 0) // for performance { int count = map.listerThings.ThingsOfDef(PurpleIvyDefOf.PurpleIvy).Count; count += map.listerThings.ThingsOfDef(PurpleIvyDefOf.EggSac).Count; count += map.listerThings.ThingsOfDef(PurpleIvyDefOf.EggSacBeta).Count; count += map.listerThings.ThingsOfDef(PurpleIvyDefOf.EggSacGamma).Count; count += map.listerThings.ThingsOfDef(PurpleIvyDefOf.EggSacNestGuard).Count; count += map.listerThings.ThingsOfDef(PurpleIvyDefOf.ParasiteEgg).Count; count += map.listerThings.ThingsOfDef(PurpleIvyDefOf.GasPump).Count; count += map.listerThings.ThingsOfDef(PurpleIvyDefOf.GenTurretBase).Count; count += map.listerThings.ThingsOfDef(PurpleIvyDefOf.Turret_GenMortarSeed).Count; count += map.listerThings.ThingsOfDef(PurpleIvyDefOf.PI_Nest).Count; var comp = map.Parent.GetComponent <WorldObjectComp_InfectedTile>(); bool temp; if (comp != null) { this.fogProgress[map] = PurpleIvyUtils.getFogProgressWithOuterSources(count, comp, out temp); if (this.fogProgress[map] <= 0) { this.End(); Find.LetterStack.ReceiveLetter("PurpleFogReceded".Translate(), "PurpleFogRecededDesc".Translate(), LetterDefOf.PositiveEvent); } } else { Log.Message("2 Comp null - GameCondition_PurpleFog"); } Log.Message(map + " - total plants " + count.ToString() + " = fog progress - " + this.fogProgress[map].ToString(), true); weatherAge = map.weatherManager.curWeatherAge; bool fog = map.weatherManager.CurWeatherPerceived.overlayClasses .Contains(typeof(WeatherOverlay_Fog)); if (map.weatherManager.curWeather != purpleFog && Find.TickManager.TicksGame > this.weatherEndingTick || !map.weatherManager.curWeather.defName.StartsWith("PI_")) { weatherEndingTick = new IntRange(10000, 30000).RandomInRange + Find.TickManager.TicksGame; Log.Message("Transitioning to purple fog in the " + map, true); if (fog == true) { map.weatherManager.TransitionTo(WeatherDefOf.Clear); map.weatherManager.TransitionTo(purpleFog); } else { map.weatherManager.TransitionTo(purpleFog); } map.weatherManager.curWeatherAge = weatherAge; } } if (Find.TickManager.TicksGame % 3451 == 0) { Log.Message("weatherEndingTick: " + this.weatherEndingTick + " - TicksGame: " + Find.TickManager.TicksGame, true); if (this.weatherEndingTick < Find.TickManager.TicksGame && this.fogProgress[map] >= 0.20f) { if (Rand.Chance(this.fogProgress[map]) && map.weatherManager.curWeather != purpleFoggyRain) { WeatherOverlay_PurpleRain weatherOverlay = new WeatherOverlay_PurpleRain(); foreach (var overlay in purpleFoggyRain.Worker.overlays) { if (overlay is WeatherOverlay_PurpleRain) { overlay.worldOverlayMat = MaterialPool.MatFrom("Weather/PurpleRainOverlayWorld2", ShaderDatabase.MetaOverlay); break; } } weatherEndingTick = new IntRange(10000, 20000).RandomInRange + Find.TickManager.TicksGame; Log.Message("Transitioning to purple rain in the " + map, true); bool fog = map.weatherManager.CurWeatherPerceived.overlayClasses .Contains(typeof(WeatherOverlay_Fog)); weatherAge = map.weatherManager.curWeatherAge; if (fog == true) { map.weatherManager.TransitionTo(WeatherDefOf.Clear); map.weatherManager.TransitionTo(purpleFoggyRain); } else { map.weatherManager.TransitionTo(purpleFoggyRain); } map.weatherManager.curWeatherAge = weatherAge; Find.LetterStack.ReceiveLetter("PurpleRainTripleToxicDamage".Translate(), "PurpleRainTripleToxicDamageDesc".Translate(), LetterDefOf.NeutralEvent, null, null); } else if (Rand.Chance(this.fogProgress[map]) && map.weatherManager.curWeather != empStorm) { weatherEndingTick = new IntRange(10000, 20000).RandomInRange + Find.TickManager.TicksGame; Log.Message("Transitioning to emp storm in the " + map, true); bool fog = map.weatherManager.CurWeatherPerceived.overlayClasses .Contains(typeof(WeatherOverlay_Fog)); if (map.weatherManager.curWeather.defName.StartsWith("PI_")) { weatherAge = map.weatherManager.curWeatherAge; } if (fog == true) { map.weatherManager.TransitionTo(WeatherDefOf.Clear); map.weatherManager.TransitionTo(empStorm); } else { map.weatherManager.TransitionTo(empStorm); } map.weatherManager.curWeatherAge = weatherAge; Find.LetterStack.ReceiveLetter("EmpStormTripleToxicDamage".Translate(), "EmpStormTripleToxicDamageDesc".Translate(), LetterDefOf.NeutralEvent, null, null); } } this.DoPawnsToxicDamage(map); } } }
public override void MapComponentTick() { base.MapComponentTick(); if (Find.TickManager.TicksGame % 250 == 0) { var plants = this.map.listerThings.ThingsOfDef(PurpleIvyDefOf.PurpleIvy); //Log.Message("Checking orbital strike, " + this.OrbitalHelpActive + " - " + plants.Count); if (plants != null && ((this.OrbitalHelpActive == true && plants.Count > 0) || plants.Count > 2000)) // && Rand.Chance(PurpleIvyData.getFogProgress(plants.Count))) { if (this.OrbitalHelpActive == false) { this.OrbitalHelpActive = true; Find.LetterStack.ReceiveLetter("OrbitalHelpFromAncients".Translate(), "OrbitalHelpFromAncientsDesc".Translate(), LetterDefOf.NeutralEvent, new TargetInfo(plants.RandomElement().Position, map, false)); } PowerBeam powerBeam = (PowerBeam)GenSpawn.Spawn(PurpleIvyDefOf.PI_PowerBeam, plants.RandomElement().Position, this.map, 0); powerBeam.duration = 200; powerBeam.instigator = null; powerBeam.weaponDef = null; powerBeam.StartStrike(); } if ((plants.Count <= 0 || plants == null) && this.OrbitalHelpActive == true) { Log.Message("Orbital help"); this.OrbitalHelpActive = false; List <Pawn> list = new List <Pawn>(); var alpha = this.map.listerThings.ThingsOfDef(PurpleIvyDefOf.Genny_ParasiteAlpha); var beta = this.map.listerThings.ThingsOfDef(PurpleIvyDefOf.Genny_ParasiteBeta); var gamma = this.map.listerThings.ThingsOfDef(PurpleIvyDefOf.Genny_ParasiteGamma); var omega = this.map.listerThings.ThingsOfDef(PurpleIvyDefOf.Genny_ParasiteOmega); var guard = this.map.listerThings.ThingsOfDef(PurpleIvyDefOf.Genny_ParasiteNestGuard); int pawnCount = alpha.Count; pawnCount += beta.Count; pawnCount += gamma.Count; pawnCount += omega.Count; pawnCount += guard.Count; Predicate <IntVec3> predicate = delegate(IntVec3 c) { return(!GridsUtility.Fogged(c, map) && !GridsUtility.Roofed(c, map) && GenGrid.InBounds(c, map) && GenRadial.RadialCellsAround(c, 10, true).Where(x => map.thingGrid.ThingsListAt(x).Where(y => y.Faction == PurpleIvyData.AlienFaction) != null) != null); }; IntVec3 position = CellFinder.RandomClosewalkCellNear(this.map.Center, this.map, 500, predicate); foreach (var num in Enumerable.Range(1, pawnCount / 2)) { Faction faction = FactionUtility.DefaultFactionFrom(PurpleIvyDefOf.KorsolianFaction); Pawn NewPawn = PawnGenerator.GeneratePawn(PurpleIvyDefOf.KorsolianSoldier, faction); if (faction != null && faction != Faction.OfPlayer) { Lord lord = null; if (this.map.mapPawns.SpawnedPawnsInFaction(faction).Any((Pawn p) => p != NewPawn)) { lord = ((Pawn)GenClosest.ClosestThing_Global(NewPawn.Position, this.map.mapPawns.SpawnedPawnsInFaction(faction), 99999f, (Thing p) => p != NewPawn && ((Pawn)p).GetLord() != null, null)).GetLord(); } if (lord == null) { var lordJob = new LordJob_AssistColony(Faction.OfPlayer, position); //LordJob_DefendPoint lordJob = new LordJob_DefendPoint(position); lord = LordMaker.MakeNewLord(faction, lordJob, this.map, null); } lord.AddPawn(NewPawn); } Log.Message(NewPawn?.Faction?.def?.defName); list.Add(NewPawn); } DropPodUtility.DropThingsNear(position, this.map, list, 30, false, true, true, true); Find.LetterStack.ReceiveLetter("AncientsLandOnTheGround".Translate(), "AncientsLandOnTheGroundDesc".Translate(), LetterDefOf.NeutralEvent, new TargetInfo(position, map, false)); } //Log.Message("Alpha limit: " + PurpleIvySettings.TotalAlienLimit[PurpleIvyDefOf.Genny_ParasiteAlpha.defName]); //Log.Message("Beta limit: " + PurpleIvySettings.TotalAlienLimit[PurpleIvyDefOf.Genny_ParasiteBeta.defName]); //Log.Message("Gamma limit: " + PurpleIvySettings.TotalAlienLimit[PurpleIvyDefOf.Genny_ParasiteGamma.defName]); //Log.Message("Omega limit: " + PurpleIvySettings.TotalAlienLimit[PurpleIvyDefOf.Genny_ParasiteOmega.defName]); int count = plants.Count; bool comeFromOuterSource; var tempComp = new WorldObjectComp_InfectedTile(); tempComp.infectedTile = map.Tile; if (PurpleIvyUtils.getFogProgressWithOuterSources(count, tempComp, out comeFromOuterSource) > 0f && !map.gameConditionManager.ConditionIsActive(PurpleIvyDefOf.PurpleFogGameCondition)) { GameCondition_PurpleFog gameCondition = (GameCondition_PurpleFog)GameConditionMaker.MakeConditionPermanent (PurpleIvyDefOf.PurpleFogGameCondition); map.gameConditionManager.RegisterCondition(gameCondition); if (comeFromOuterSource == false) { Find.LetterStack.ReceiveLetter(gameCondition.LabelCap, gameCondition.LetterText, gameCondition.def.letterDef, new TargetInfo(map.Center, map, false)); } else { Find.LetterStack.ReceiveLetter("PurpleFogСomesFromInfectedSites".Translate(), "PurpleFogСomesFromInfectedSitesDesc".Translate(), LetterDefOf.ThreatBig, new TargetInfo(map.Center, map, false)); Log.Message("PurpleFogСomesFromInfectedSites: " + map.ToString() + " - " + Find.TickManager.TicksGame.ToString()); } if (map.Parent.GetComponent <WorldObjectComp_InfectedTile>() == null) { var comp = new WorldObjectComp_InfectedTile(); comp.parent = map.Parent; comp.StartInfection(); comp.gameConditionCaused = PurpleIvyDefOf.PurpleFogGameCondition; comp.counter = count; comp.infectedTile = map.Tile; comp.radius = comp.GetRadius(); PurpleIvyData.TotalFogProgress[comp] = PurpleIvyUtils.getFogProgress(comp.counter); comp.fillRadius(); map.Parent.AllComps.Add(comp); Log.Message("Adding comp to: " + map.Parent.ToString()); } } } if (Find.TickManager.TicksGame % 60000 == 0) { int count = 0; var alphaEggs = this.map.listerThings.ThingsOfDef(PurpleIvyDefOf.EggSac); var betaEggs = this.map.listerThings.ThingsOfDef(PurpleIvyDefOf.EggSacBeta); var gammaEggs = this.map.listerThings.ThingsOfDef(PurpleIvyDefOf.EggSacGamma); var nestsEggs = this.map.listerThings.ThingsOfDef(PurpleIvyDefOf.EggSacNestGuard); var omegaEggs = this.map.listerThings.ThingsOfDef(PurpleIvyDefOf.ParasiteEgg); Log.Message("Total PurpleIvy count on the map: " + this.map.listerThings.ThingsOfDef(PurpleIvyDefOf.PurpleIvy).Count.ToString(), true); count = this.map.listerThings.ThingsOfDef(PurpleIvyDefOf.Genny_ParasiteAlpha).Count; if (count > PurpleIvySettings.TotalAlienLimit[PurpleIvyDefOf.Genny_ParasiteAlpha.defName]) { foreach (var egg in alphaEggs) { var eggSac = (Building_EggSac)egg; eggSac.TryGetComp <AlienInfection>().stopSpawning = true; } } else { foreach (var egg in alphaEggs) { var eggSac = (Building_EggSac)egg; eggSac.TryGetComp <AlienInfection>().stopSpawning = false; } } Log.Message("Total Genny_ParasiteAlpha count on the map: " + count.ToString(), true); count = this.map.listerThings.ThingsOfDef(PurpleIvyDefOf.Genny_ParasiteBeta).Count; if (count > PurpleIvySettings.TotalAlienLimit[PurpleIvyDefOf.Genny_ParasiteBeta.defName]) { foreach (var egg in betaEggs) { var eggSac = (Building_EggSac)egg; eggSac.TryGetComp <AlienInfection>().stopSpawning = true; } } else { foreach (var egg in betaEggs) { var eggSac = (Building_EggSac)egg; eggSac.TryGetComp <AlienInfection>().stopSpawning = false; } } Log.Message("Total Genny_ParasiteBeta count on the map: " + count.ToString(), true); count = this.map.listerThings.ThingsOfDef(PurpleIvyDefOf.Genny_ParasiteGamma).Count; if (count > PurpleIvySettings.TotalAlienLimit[PurpleIvyDefOf.Genny_ParasiteGamma.defName]) { foreach (var egg in gammaEggs) { var eggSac = (Building_EggSac)egg; eggSac.TryGetComp <AlienInfection>().stopSpawning = true; } } else { foreach (var egg in gammaEggs) { var eggSac = (Building_EggSac)egg; eggSac.TryGetComp <AlienInfection>().stopSpawning = false; } } Log.Message("Total Genny_ParasiteGamma count on the map: " + count.ToString(), true); count = this.map.listerThings.ThingsOfDef(PurpleIvyDefOf.Genny_ParasiteOmega).Count; if (count > PurpleIvySettings.TotalAlienLimit[PurpleIvyDefOf.Genny_ParasiteOmega.defName]) { foreach (var egg in omegaEggs) { var eggSac = (Building_EggSac)egg; eggSac.TryGetComp <AlienInfection>().stopSpawning = true; } } else { foreach (var egg in omegaEggs) { var eggSac = (Building_EggSac)egg; eggSac.TryGetComp <AlienInfection>().stopSpawning = false; } } Log.Message("Total Genny_ParasiteOmega count on the map: " + count.ToString(), true); Log.Message("Total Genny_ParasiteNestGuard count on the map: " + this.map.listerThings.ThingsOfDef(PurpleIvyDefOf.Genny_ParasiteNestGuard).Count.ToString(), true); Log.Message("Total EggSac count on the map: " + alphaEggs.Count.ToString(), true); Log.Message("Total EggSac beta count on the map: " + betaEggs.Count.ToString(), true); Log.Message("Total EggSac gamma count on the map: " + gammaEggs.Count.ToString(), true); Log.Message("Total EggSac NestGuard count on the map: " + nestsEggs.Count.ToString(), true); Log.Message("Total ParasiteEgg count on the map: " + omegaEggs.Count.ToString(), true); Log.Message("Total GasPump count on the map: " + this.map.listerThings.ThingsOfDef(PurpleIvyDefOf.GasPump).Count.ToString(), true); Log.Message("Total GenTurretBase count on the map: " + this.map.listerThings.ThingsOfDef(PurpleIvyDefOf.GenTurretBase).Count.ToString(), true); Log.Message("Total Turret_GenMortarSeed count on the map: " + this.map.listerThings.ThingsOfDef(PurpleIvyDefOf.Turret_GenMortarSeed).Count.ToString(), true); Log.Message("Total Nest count on the map: " + this.map.listerThings.ThingsOfDef(PurpleIvyDefOf.PI_Nest).Count.ToString(), true); } }
public override void Generate(Map map, GenStepParams parms) { var intVec = new IntVec3(); var invalid = IntVec3.Invalid; var flag = !RCellFinder.TryFindRandomCellNearTheCenterOfTheMapWith((IntVec3 sq) => sq.Standable(map) && !sq.Roofed(map) && !sq.Fogged(map) && sq.CanBeSeenOver(map) && sq.Walkable(map) && sq.InBounds(map) , map, out intVec); if (flag) { invalid = IntVec3.Invalid; intVec = CellFinderLoose.RandomCellWith( sq => sq.Standable(map) && !sq.Roofed(map) && !sq.Fogged(map) && sq.CanBeSeenOver(map) && sq.Walkable(map) && sq.InBounds(map), map); } var meteor = ThingMaker.MakeThing(ThingDef.Named("PI_Meteorite")); GenSpawn.Spawn(meteor, intVec, map); var radius = GetRadius(map); Log.Message("Radius: " + radius.ToString()); var radialCells = GenRadial.RadialCellsAround(meteor.Position, radius, true) .ToList(); var plantCount = 0; var infectedComp = map.Parent.GetComponent <WorldObjectComp_InfectedTile>(); var counter = infectedComp.counter; const float origGrowth = 1f; var newivyGrowth = 1f; foreach (IntVec3 vec in radialCells) { if (SpreadBuilding(vec, map)) { continue; } if (plantCount >= counter || !vec.InBounds(map) || !vec.Standable(map)) { continue; } var newivy = new Plant(); newivy = (Plant)ThingMaker.MakeThing(ThingDef.Named("PurpleIvy")); GenSpawn.Spawn(newivy, vec, map); newivy.Growth = newivyGrowth; newivyGrowth -= (origGrowth / (float)counter); plantCount++; } var alphaParasitesCount = map.listerThings.ThingsOfDef(PurpleIvyDefOf.EggSac).Count * 10; int betaParasitesCount = map.listerThings.ThingsOfDef(PurpleIvyDefOf.EggSacBeta).Count * 10; int gammaParasitesCount = map.listerThings.ThingsOfDef(PurpleIvyDefOf.EggSacGamma).Count * 10; var omegaParasitesCount = map.listerThings.ThingsOfDef(PurpleIvyDefOf.ParasiteEgg).Count * 10; alphaParasitesCount -= (infectedComp.AlienPowerSpent / 50); betaParasitesCount = (infectedComp.AlienPowerSpent / 50); gammaParasitesCount = (infectedComp.AlienPowerSpent / 50); omegaParasitesCount -= (infectedComp.AlienPowerSpent / 50); foreach (var i in Enumerable.Range(1, alphaParasitesCount)) { var spawnPlace = radialCells.Where(x => x.Walkable(map)).RandomElement(); radialCells.Remove(spawnPlace); var pawnKindDef = PawnKindDef.Named(PurpleIvyData.Genny_ParasiteAlpha.RandomElement()); var newPawn = PawnGenerator.GeneratePawn(pawnKindDef, null); newPawn.ageTracker.AgeBiologicalTicks = 40000; newPawn.ageTracker.AgeChronologicalTicks = 40000; GenSpawn.Spawn(newPawn, spawnPlace, map); } foreach (var i in Enumerable.Range(1, betaParasitesCount)) { var spawnPlace = radialCells.Where(x => x.Walkable(map)).RandomElement(); radialCells.Remove(spawnPlace); var pawnKindDef = PawnKindDef.Named(PurpleIvyData.Genny_ParasiteBeta.RandomElement()); var newPawn = PawnGenerator.GeneratePawn(pawnKindDef, null); newPawn.ageTracker.AgeBiologicalTicks = 40000; newPawn.ageTracker.AgeChronologicalTicks = 40000; GenSpawn.Spawn(newPawn, spawnPlace, map); } foreach (var i in Enumerable.Range(1, gammaParasitesCount)) { var spawnPlace = radialCells.Where(x => x.Walkable(map)).RandomElement(); radialCells.Remove(spawnPlace); var pawnKindDef = PawnKindDef.Named(PurpleIvyData.Genny_ParasiteGamma.RandomElement()); var newPawn = PawnGenerator.GeneratePawn(pawnKindDef, null); newPawn.ageTracker.AgeBiologicalTicks = 40000; newPawn.ageTracker.AgeChronologicalTicks = 40000; GenSpawn.Spawn(newPawn, spawnPlace, map); } foreach (var i in Enumerable.Range(1, omegaParasitesCount)) { var spawnPlace = radialCells.Where(x => x.Walkable(map)).RandomElement(); radialCells.Remove(spawnPlace); var pawnKindDef = PawnKindDef.Named(PurpleIvyData.Genny_ParasiteOmega.RandomElement()); var newPawn = PawnGenerator.GeneratePawn(pawnKindDef, null); newPawn.ageTracker.AgeBiologicalTicks = 40000; newPawn.ageTracker.AgeChronologicalTicks = 40000; GenSpawn.Spawn(newPawn, spawnPlace, map); } foreach (var ivy in map.listerThings.ThingsOfDef(PurpleIvyDefOf.PurpleIvy).Cast <Plant_Ivy>().Where(ivy => ivy.Growth > 0.1f)) { ivy.CanMutate = false; } var count = map.listerThings.ThingsOfDef(PurpleIvyDefOf.PurpleIvy).Count; Log.Message("New map created! plants - " + map.listerThings.ThingsOfDef(PurpleIvyDefOf.PurpleIvy).Count.ToString()); var comp = map.Parent.GetComponent <WorldObjectComp_InfectedTile>(); if (comp != null && PurpleIvyUtils.getFogProgressWithOuterSources(count, comp, out var temp) > 0f) { GameCondition_PurpleFog gameCondition = (GameCondition_PurpleFog)GameConditionMaker.MakeConditionPermanent (PurpleIvyDefOf.PurpleFogGameCondition); map.gameConditionManager.RegisterCondition(gameCondition); } Log.Message("Total PurpleIvy count on the map: " + map.listerThings.ThingsOfDef(PurpleIvyDefOf.PurpleIvy).Count.ToString(), true); Log.Message("Total Genny_ParasiteAlpha count on the map: " + map.listerThings.ThingsOfDef(PurpleIvyDefOf.Genny_ParasiteAlpha).Count.ToString(), true); Log.Message("Total Genny_ParasiteBeta count on the map: " + map.listerThings.ThingsOfDef(PurpleIvyDefOf.Genny_ParasiteBeta).Count.ToString(), true); Log.Message("Total Genny_ParasiteGamma count on the map: " + map.listerThings.ThingsOfDef(PurpleIvyDefOf.Genny_ParasiteGamma).Count.ToString(), true); Log.Message("Total Genny_ParasiteOmega count on the map: " + map.listerThings.ThingsOfDef(PurpleIvyDefOf.Genny_ParasiteOmega).Count.ToString(), true); Log.Message("Total Genny_ParasiteNestGuard count on the map: " + map.listerThings.ThingsOfDef(PurpleIvyDefOf.Genny_ParasiteNestGuard).Count.ToString(), true); Log.Message("Total EggSac count on the map: " + map.listerThings.ThingsOfDef(PurpleIvyDefOf.EggSac).Count.ToString(), true); Log.Message("Total EggSac beta count on the map: " + map.listerThings.ThingsOfDef(PurpleIvyDefOf.EggSacBeta).Count.ToString(), true); Log.Message("Total EggSac gamma count on the map: " + map.listerThings.ThingsOfDef(PurpleIvyDefOf.EggSacGamma).Count.ToString(), true); Log.Message("Total EggSac NestGuard count on the map: " + map.listerThings.ThingsOfDef(PurpleIvyDefOf.EggSacNestGuard).Count.ToString(), true); Log.Message("Total ParasiteEgg count on the map: " + map.listerThings.ThingsOfDef(PurpleIvyDefOf.ParasiteEgg).Count.ToString(), true); Log.Message("Total GasPump count on the map: " + map.listerThings.ThingsOfDef(PurpleIvyDefOf.GasPump).Count.ToString(), true); Log.Message("Total GenTurretBase count on the map: " + map.listerThings.ThingsOfDef(PurpleIvyDefOf.GenTurretBase).Count.ToString(), true); Log.Message("Total Turret_GenMortarSeed count on the map: " + map.listerThings.ThingsOfDef(PurpleIvyDefOf.Turret_GenMortarSeed).Count.ToString(), true); }