public void RecalculateVisibleMap() { Tools.UpdateStoryTellerDifficulty(); if (visibleGridUpdateCounter-- < 0) { visibleGridUpdateCounter = Constants.TICKMANAGER_RECALCULATE_DELAY.SecondsToTicks(); currentColonyPoints = Tools.ColonyPoints(); allZombiesCached = AllZombies().ToList(); var home = map.areaManager.Home; if (home.TrueCount > 0) { var cells = home.ActiveCells.ToArray(); var cellCount = cells.Length; allZombiesCached.Do(zombie => zombie.wanderDestination = cells[Constants.random.Next() % cellCount]); centerOfInterest = new IntVec3( (int)Math.Round(cells.Average(c => c.x)), 0, (int)Math.Round(cells.Average(c => c.z)) ); } else { centerOfInterest = Tools.CenterOfInterest(map); allZombiesCached.Do(zombie => zombie.wanderDestination = centerOfInterest); } } }
public void RecalculateVisibleMap() { currentColonyPoints = Tools.ColonyPoints(); prioritizedZombies = AllZombies().ToList(); var home = map.areaManager.Home; if (home.TrueCount > 0) { prioritizedZombies.Do(zombie => zombie.wanderDestination = home.ActiveCells.RandomElement()); } else { var center = Tools.CenterOfInterest(map); prioritizedZombies.Do(zombie => zombie.wanderDestination = center); } var grid = map.GetGrid(); prioritizedZombies.Sort( delegate(Zombie z1, Zombie z2) { var v1 = grid.Get(z1.Position).timestamp; var v2 = grid.Get(z2.Position).timestamp; var order = v2.CompareTo(v1); if (order != 0) { return(order); } var d1 = z1.Position.DistanceToSquared(z1.wanderDestination); var d2 = z2.Position.DistanceToSquared(z2.wanderDestination); return(d1.CompareTo(d2)); } ); }
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 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); }