private static void UpdateSpawners(SpawnSystem self, bool eventSpawners) { if (Instances.TryGetValue(self, out var goodSpawnSystem)) { var activeSpawnersForBiome = goodSpawnSystem.Spawners.List.Where(spawner => spawner.Item.m_enabled && self.m_heightmap.HaveBiome(spawner.Item.m_biome)).ToList(); var spawner = goodSpawnSystem.Spawners.GetRandomItem(activeSpawnersForBiome); if ((!string.IsNullOrEmpty(spawner.m_requiredGlobalKey) && !ZoneSystem.instance.GetGlobalKey(spawner.m_requiredGlobalKey)) || (spawner.m_requiredEnvironments.Count > 0 && !EnvMan.instance.IsEnvironment(spawner.m_requiredEnvironments)) || (!spawner.m_spawnAtDay && EnvMan.instance.IsDay()) || (!spawner.m_spawnAtNight && EnvMan.instance.IsNight()) || SpawnSystem.GetNrOfInstances(spawner.m_prefab, Vector3.zero, 0f, eventSpawners, false) >= spawner.m_maxSpawned) { return; } if (self.FindBaseSpawnPoint(spawner, self.m_nearPlayers, out var vector, out var player) && (spawner.m_spawnDistance <= 0f || !SpawnSystem.HaveInstanceInRange(spawner.m_prefab, vector, spawner.m_spawnDistance))) { var groupSize = UnityEngine.Random.Range(spawner.m_groupSizeMin, spawner.m_groupSizeMax + 1); var groupRadius = groupSize > 1 ? spawner.m_groupRadius : 0f; var numberOfSpawnedMonsters = 0; for (var i = 0; i < groupSize * 2; i++) { var insideUnitCircle = UnityEngine.Random.insideUnitCircle; var spawnPoint = vector + new Vector3(insideUnitCircle.x, 0f, insideUnitCircle.y) * groupRadius; if (self.IsSpawnPointGood(spawner, ref spawnPoint)) { self.Spawn(spawner, spawnPoint + Vector3.up * spawner.m_groundOffset, eventSpawners); numberOfSpawnedMonsters++; if (numberOfSpawnedMonsters >= groupSize) { break; } } } Log.LogInfo($"Spawned {numberOfSpawnedMonsters} {spawner.m_prefab.name}"); } } else { Log.LogWarning($"Failed to find a spawner list for : {self.name}"); } }
// Token: 0x06000BCF RID: 3023 RVA: 0x0005413C File Offset: 0x0005233C private void UpdateSpawnList(List <SpawnSystem.SpawnData> spawners, DateTime currentTime, bool eventSpawners) { string str = eventSpawners ? "e_" : "b_"; int num = 0; foreach (SpawnSystem.SpawnData spawnData in spawners) { num++; if (spawnData.m_enabled && this.m_heightmap.HaveBiome(spawnData.m_biome)) { int stableHashCode = (str + spawnData.m_prefab.name + num.ToString()).GetStableHashCode(); DateTime d = new DateTime(this.m_nview.GetZDO().GetLong(stableHashCode, 0L)); TimeSpan timeSpan = currentTime - d; int num2 = Mathf.Min(spawnData.m_maxSpawned, (int)(timeSpan.TotalSeconds / (double)spawnData.m_spawnInterval)); if (num2 > 0) { this.m_nview.GetZDO().Set(stableHashCode, currentTime.Ticks); } for (int i = 0; i < num2; i++) { if (UnityEngine.Random.Range(0f, 100f) <= spawnData.m_spawnChance) { if ((!string.IsNullOrEmpty(spawnData.m_requiredGlobalKey) && !ZoneSystem.instance.GetGlobalKey(spawnData.m_requiredGlobalKey)) || (spawnData.m_requiredEnvironments.Count > 0 && !EnvMan.instance.IsEnvironment(spawnData.m_requiredEnvironments)) || (!spawnData.m_spawnAtDay && EnvMan.instance.IsDay()) || (!spawnData.m_spawnAtNight && EnvMan.instance.IsNight()) || SpawnSystem.GetNrOfInstances(spawnData.m_prefab, Vector3.zero, 0f, eventSpawners, false) >= spawnData.m_maxSpawned) { break; } Vector3 vector; Player player; if (this.FindBaseSpawnPoint(spawnData, this.m_nearPlayers, out vector, out player) && (spawnData.m_spawnDistance <= 0f || !SpawnSystem.HaveInstanceInRange(spawnData.m_prefab, vector, spawnData.m_spawnDistance))) { int num3 = UnityEngine.Random.Range(spawnData.m_groupSizeMin, spawnData.m_groupSizeMax + 1); float d2 = (num3 > 1) ? spawnData.m_groupRadius : 0f; int num4 = 0; for (int j = 0; j < num3 * 2; j++) { Vector2 insideUnitCircle = UnityEngine.Random.insideUnitCircle; Vector3 a = vector + new Vector3(insideUnitCircle.x, 0f, insideUnitCircle.y) * d2; if (this.IsSpawnPointGood(spawnData, ref a)) { this.Spawn(spawnData, a + Vector3.up * spawnData.m_groundOffset, eventSpawners); num4++; if (num4 >= num3) { break; } } } ZLog.Log(string.Concat(new object[] { "Spawned ", spawnData.m_prefab.name, " x ", num4 })); } } } } } }