private void SpawnZombie(ZombieGenerator.ZombieType type, bool appearDirectly) { ZombieGenerator.SpawnZombie(UI.MouseCell(), Find.CurrentMap, type, (zombie) => { if (appearDirectly) { zombie.rubbleCounter = Constants.RUBBLE_AMOUNT; zombie.state = ZombieState.Wandering; } zombie.Rotation = Rot4.South; var tickManager = Find.CurrentMap.GetComponent <TickManager>(); tickManager.allZombiesCached.Add(zombie); }); }
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; } } } } }
static IEnumerator SpawnEventProcess(Map map, int incidentSize, IntVec3 spot, Predicate <IntVec3> cellValidator, bool ignoreLimit) { var zombiesSpawning = 0; var counter = 1; var tickManager = map.GetComponent <TickManager>(); while (incidentSize > 0 && (ignoreLimit || tickManager.CanHaveMoreZombies()) && counter <= 10) { var cells = Tools.GetCircle(Constants.SPAWN_INCIDENT_RADIUS) .Select(vec => spot + vec) .Where(vec => cellValidator(vec)) .InRandomOrder() .Take(incidentSize) .ToList(); yield return(null); foreach (var cell in cells) { ZombieGenerator.SpawnZombie(cell, map, ZombieGenerator.ZombieType.Random, (zombie) => { tickManager.allZombiesCached.Add(zombie); }); incidentSize--; zombiesSpawning++; yield return(null); } counter++; } if (zombiesSpawning > 3) { var headline = "LetterLabelZombiesRising".Translate(); var text = "ZombiesRising".Translate(); if (ZombieSettings.Values.spawnHowType == SpawnHowType.AllOverTheMap) { headline = "LetterLabelZombiesRisingNearYourBase".Translate(); text = "ZombiesRisingNearYourBase".Translate(); } var location = new GlobalTargetInfo(spot, map); Find.LetterStack.ReceiveLetter(headline, text, LetterDefOf.ThreatSmall, location); var isSubstantialZombieCount = zombiesSpawning > Tools.CapableColonists(map) * 4; if (isSubstantialZombieCount && Constants.USE_SOUND && Prefs.VolumeAmbient > 0f) { SoundDef.Named("ZombiesRising").PlayOneShotOnCamera(null); } } }