WaitingList
It is a simple waiting list script.
var wl = new WaitingList();
wl.Add(() => {
Debug.Log("Enable a new player");
});
wl.Add(() => {
// if false, dont spawn player and continue to try
if (...) {
Debug.Log("Enable player 2");
return true;
}
return false;
});
// force try invoke functions if seats left and not locked
wl.Invoke();
wl.SeatsLeft = 1; // automatically calls Invoke function
// Lock the list (example : we can spawn players only between levels)
wl.Locked = true;
// unloke the list automatically calls Invoke function
wl.Locked = false;
// randomize the action calls
wl.Random = true;