/// <summary> /// Instantiates and returns prefabs on all spawn points. /// </summary> public IEnumerable <GameObject> SpawnAndReturn(int max, Actor caller, bool isForced = false) { if (Secondary != null && Random.Range(0f, 1f) <= SecondaryChance) { foreach (var actor in Secondary.SpawnAndReturn(max, caller)) { yield return(actor); } } else { if (!isForced && Time.timeSinceLevelLoad - _lastTime < MinInterval) { yield break; } _lastTime = Time.timeSinceLevelLoad; foreach (var point in Points) { if (PrefabOverride == null || PrefabOverride.Length == 0) { yield return(point.Spawn(caller)); } else if (point.Prefabs == null || point.Prefabs.Length == 0 || !OnlyOverrideEmptySpawnPoints) { yield return(SpawnPoint.SpawnPrefab(PrefabOverride[Random.Range(0, PrefabOverride.Length)], point.transform.position, caller)); } else { yield return(point.Spawn(caller)); } } } }
/// <summary> /// Instantiates and returns prefabs on all spawn points. /// </summary> public IEnumerable <GameObject> SpawnAndReturn(SpawnGroup group, Actor caller, bool isForced = false) { if (!isForced && Time.timeSinceLevelLoad - _lastTime < MinInterval) { return(_empty); } _lastTime = Time.timeSinceLevelLoad; if (PrefabOverride == null || PrefabOverride.Length == 0) { return(group.SpawnAndReturn(Random.Range(MinCount, MaxCount), caller, true)); } else { return(group.SpawnAndReturn(Random.Range(MinCount, MaxCount), PrefabOverride, caller, true)); } }