SR SpawnerPickers - Smehi/WaveOne GitHub Wiki

SpawnerPickers allow you to determine how the enemies per wave are chosen. Here the contents of the picker don't really matter. What we are after is the ISpawnerPicker interface. All custom spawner pickers implement this interface. This means that using the pickers is the same no matter which implementation we use.

ISpawnerPicker methods

void SetListSize(int size)

This is used to set the size in the picker. The picker has to have a reference to the size so it can correctly pick the next enemy.

For example in your Spawner script you would do something like this:

private ISpawnerPicker spawnerPicker;

private IEnumerator WaveDeployment()
{
    ...

    // Get a reference to the picker by searching for the interface.
    // Then set the size with the amount of enemies for that wave.
    spawnerPicker = GetComponent<ISpawnerPicker>();
    spawnerPicker.SetListSize(waves[currentWave].enemies.Count);

    ...
}

int GetIndex()

Get next index in the way that the picker is set up (InOrder/ReverseOrder/etc.).

To use this in your Spawner script:

private IEnumerator WaveDeployment()
{
    ...

    // Set your index by getting the index.
    int enemyIndex = spawnerPicker.GetIndex();

    // Spawn that enemy.
    Instantiate(waves[currentWave].enemies[enemyIndex].gameObject);
    
    ...
}
⚠️ **GitHub.com Fallback** ⚠️