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)); } ); }