public void IncreaseZombiePopulation() { if (populationSpawnCounter-- < 0) { populationSpawnCounter = (int)GenMath.LerpDouble(0, 1000, 300, 20, Math.Max(100, Math.Min(1000, currentColonyPoints))); if (GenDate.DaysPassedFloat < ZombieSettings.Values.daysBeforeZombiesCome) { return; } if (ZombieSettings.Values.spawnWhenType == SpawnWhenType.InEventsOnly) { return; } var numberOfZombies = ZombieCount() + Tools.generator.ZombiesQueued(map); if (numberOfZombies < GetMaxZombieCount()) { switch (ZombieSettings.Values.spawnHowType) { case SpawnHowType.AllOverTheMap: { var cell = CellFinderLoose.RandomCellWith(Tools.ZombieSpawnLocator(map), map, 4); if (cell.IsValid) { Tools.generator.SpawnZombieAt(map, cell, false); } return; } case SpawnHowType.FromTheEdges: { IntVec3 cell; if (CellFinder.TryFindRandomEdgeCellWith(Tools.ZombieSpawnLocator(map), map, CellFinder.EdgeRoadChance_Neutral, out cell)) { Tools.generator.SpawnZombieAt(map, cell, false); } return; } default: { Log.Error("Unknown spawn type " + ZombieSettings.Values.spawnHowType); return; } } } } }
public void IncreaseZombiePopulation() { if (GenDate.DaysPassedFloat < ZombieSettings.Values.daysBeforeZombiesCome) { return; } if (ZombieSettings.Values.spawnWhenType == SpawnWhenType.InEventsOnly) { return; } if (populationSpawnCounter-- < 0) { populationSpawnCounter = (int)GenMath.LerpDouble(0, 1000, 300, 20, Math.Max(100, Math.Min(1000, currentColonyPoints))); if (CanHaveMoreZombies()) { switch (ZombieSettings.Values.spawnHowType) { case SpawnHowType.AllOverTheMap: { var cell = CellFinderLoose.RandomCellWith(Tools.ZombieSpawnLocator(map), map, 4); if (cell.IsValid) { ZombieGenerator.SpawnZombie(cell, map, ZombieGenerator.ZombieType.Random, (zombie) => { allZombiesCached.Add(zombie); }); } return; } case SpawnHowType.FromTheEdges: { if (CellFinder.TryFindRandomEdgeCellWith(Tools.ZombieSpawnLocator(map), map, CellFinder.EdgeRoadChance_Neutral, out var cell)) { ZombieGenerator.SpawnZombie(cell, map, ZombieGenerator.ZombieType.Random, (zombie) => { allZombiesCached.Add(zombie); }); } return; } default: { Log.Error("Unknown spawn type " + ZombieSettings.Values.spawnHowType); return; } } } } }
public void IncreaseZombiePopulation() { if (GenDate.DaysPassedFloat < ZombieSettings.Values.daysBeforeZombiesCome) { return; } if (ZombieSettings.Values.spawnWhenType == SpawnWhenType.InEventsOnly) { return; } var zombieCount = ZombieCount() + Tools.generator.ZombiesQueued(map); var zombieDestCount = GetMaxZombieCount(); if (zombieCount < zombieDestCount) { switch (ZombieSettings.Values.spawnHowType) { case SpawnHowType.AllOverTheMap: { var cell = CellFinderLoose.RandomCellWith(Tools.ZombieSpawnLocator(map), map, 4); if (cell.IsValid) { Tools.generator.SpawnZombieAt(map, cell); } return; } case SpawnHowType.FromTheEdges: { IntVec3 cell; if (CellFinder.TryFindRandomEdgeCellWith(Tools.ZombieSpawnLocator(map), map, CellFinder.EdgeRoadChance_Neutral, out cell)) { Tools.generator.SpawnZombieAt(map, cell); } return; } default: { Log.Error("Unknown spawn type " + ZombieSettings.Values.spawnHowType); return; } } } }
public static bool TryExecute(Map map, int incidentSize, IntVec3 spot, bool ignoreLimit = false) { var cellValidator = Tools.ZombieSpawnLocator(map, true); var spotValidator = SpotValidator(map, cellValidator); for (var counter = 1; counter <= 10; counter++) { if (spot.IsValid) { break; } if (ZombieSettings.Values.spawnHowType == SpawnHowType.AllOverTheMap) { var tickManager = map.GetComponent <TickManager>(); if (tickManager == null) { return(false); } var center = tickManager != null ? tickManager.centerOfInterest : IntVec3.Invalid; if (center.IsValid == false) { center = Tools.CenterOfInterest(map); } RCellFinder.TryFindRandomSpotJustOutsideColony(center, map, null, out spot, spotValidator); } else { var success = MultiVersionMethods.TryFindRandomPawnEntryCell(out spot, map, 0.5f, spotValidator, out spot, map, 0.5f, true, spotValidator); if (success == false) { spot = IntVec3.Invalid; } } } if (spot.IsValid == false) { return(false); } Find.CameraDriver.StartCoroutine(SpawnEventProcess(map, incidentSize, spot, cellValidator, ignoreLimit)); return(true); }
public Predicate <IntVec3> SpotValidator(Map map) { var cellValidator = Tools.ZombieSpawnLocator(map); return(cell => { var count = 0; var vecs = Tools.GetCircle(Constants.SPAWN_INCIDENT_RADIUS).ToList(); foreach (var vec in vecs) { if (cellValidator(cell + vec)) { if (++count >= Constants.MIN_ZOMBIE_SPAWN_CELL_COUNT) { break; } } } return count >= Constants.MIN_ZOMBIE_SPAWN_CELL_COUNT; }); }
public override bool TryExecute(IncidentParms parms) { if (GenDate.DaysPassedFloat < ZombieSettings.Values.daysBeforeZombiesCome) { return(false); } var map = (Map)parms.target; var zombieCount = (int)(zombieCountFactor * ZombieSettings.Values.baseNumberOfZombiesinEvent) + 1; zombieCount *= Math.Max(1, map.mapPawns.FreeColonists.Count()); var spotValidator = SpotValidator(map); IntVec3 spot = IntVec3.Invalid; string headline = ""; string text = ""; for (int counter = 1; counter <= 10; counter++) { if (ZombieSettings.Values.spawnHowType == SpawnHowType.AllOverTheMap) { RCellFinder.TryFindRandomSpotJustOutsideColony(Tools.CenterOfInterest(map), map, null, out spot, spotValidator); headline = "LetterLabelZombiesRisingNearYourBase".Translate(); text = "ZombiesRisingNearYourBase".Translate(); } else { RCellFinder.TryFindRandomPawnEntryCell(out spot, map, 0.5f, spotValidator); headline = "LetterLabelZombiesRising".Translate(); text = "ZombiesRising".Translate(); } if (spot.IsValid) { break; } } if (spot.IsValid == false) { return(false); } var cellValidator = Tools.ZombieSpawnLocator(map); while (zombieCount > 0) { Tools.GetCircle(Constants.SPAWN_INCIDENT_RADIUS) .Select(vec => spot + vec) .Where(vec => cellValidator(vec)) .InRandomOrder() .Take(zombieCount) .Do(cell => { Tools.generator.SpawnZombieAt(map, cell); zombieCount--; }); } var location = new GlobalTargetInfo(spot, map); Find.LetterStack.ReceiveLetter(headline, text, LetterDefOf.BadUrgent, location); SoundDef.Named("ZombiesRising").PlayOneShotOnCamera(null); return(true); }
public static bool TryExecute(Map map, int incidentSize) { var spotValidator = SpotValidator(map); var spot = IntVec3.Invalid; var headline = ""; var text = ""; for (var counter = 1; counter <= 10; counter++) { if (ZombieSettings.Values.spawnHowType == SpawnHowType.AllOverTheMap) { var tickManager = map.GetComponent <TickManager>(); var center = tickManager != null ? tickManager.centerOfInterest : IntVec3.Invalid; if (center.IsValid == false) { center = Tools.CenterOfInterest(map); } RCellFinder.TryFindRandomSpotJustOutsideColony(center, map, null, out spot, spotValidator); headline = "LetterLabelZombiesRisingNearYourBase".Translate(); text = "ZombiesRisingNearYourBase".Translate(); } else { RCellFinder.TryFindRandomPawnEntryCell(out spot, map, 0.5f, spotValidator); headline = "LetterLabelZombiesRising".Translate(); text = "ZombiesRising".Translate(); } if (spot.IsValid) { break; } } if (spot.IsValid == false) { return(false); } var cellValidator = Tools.ZombieSpawnLocator(map, true); while (incidentSize > 0) { Tools.GetCircle(Constants.SPAWN_INCIDENT_RADIUS) .Select(vec => spot + vec) .Where(vec => cellValidator(vec)) .InRandomOrder() .Take(incidentSize) .Do(cell => { Tools.generator.SpawnZombieAt(map, cell, true); incidentSize--; }); } var location = new GlobalTargetInfo(spot, map); Find.LetterStack.ReceiveLetter(headline, text, LetterDefOf.BadUrgent, location); if (Constants.USE_SOUND) { SoundDef.Named("ZombiesRising").PlayOneShotOnCamera(null); } return(true); }