Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Coordinated Spawns (Purple Edition) #531

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update EntitySpawner.cs
  • Loading branch information
MrPurple6411 committed Jan 20, 2024
commit 17dfbe11180f122ff8b4bac046187139375f88d7
8 changes: 4 additions & 4 deletions Nautilus/MonoBehaviours/EntitySpawner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ internal class EntitySpawner : MonoBehaviour
internal Int3 batchId;
internal IReadOnlyCollection<SpawnInfo> spawnInfos;
internal bool global;
private List<SpawnInfo> delayedSpawns = new List<SpawnInfo>();
private readonly List<SpawnInfo> _delayedSpawns = new List<SpawnInfo>();

private IEnumerator Start()
{
yield return SpawnAsync();
yield return new WaitUntil(() => delayedSpawns.Count == 0);
yield return new WaitUntil(() => _delayedSpawns.Count == 0);
Destroy(gameObject);
}

Expand Down Expand Up @@ -81,10 +81,10 @@ private IEnumerator SpawnAsync()

private IEnumerator WaitForCellLoaded(LargeWorldStreamer lws, GameObject prefab, SpawnInfo spawnInfo, string stringToLog)
{
delayedSpawns.Add(spawnInfo);
_delayedSpawns.Add(spawnInfo);
yield return new WaitUntil(() => lws.IsRangeActiveAndBuilt(new Bounds(spawnInfo.SpawnPosition, Vector3.one * 5)));
Spawn(prefab, spawnInfo, stringToLog);
delayedSpawns.Remove(spawnInfo);
_delayedSpawns.Remove(spawnInfo);
}

private void Spawn(GameObject prefab, SpawnInfo spawnInfo, string stringToLog)
Expand Down