logo SERENITY
Game Systems Foundation
Search Results for

    Show / Hide Table of Contents

    Class UnityWaveService

    Unity MonoBehaviour implementation of IWaveService and IUnityWaveRuntime. Manages wave progression within a stage. Stores wave SO references for spawn entry access. Supports spawn-point resolution via ISpawnPointResolver (hybrid prefab authoring). Delegates actor spawning/pooling to ICharacterSpawnService.

    Inheritance
    object
    UnityWaveService
    Implements
    IWaveService
    IService
    IFoundationSettings
    IUnityWaveRuntime
    Namespace: Serenity.Wave.Infrastructure.Services
    Assembly: Serenity.UnityWave.Infrastructure.dll
    Syntax
    public class UnityWaveService : MonoBehaviour, IWaveService, IService, IFoundationSettings, IUnityWaveRuntime

    Constructors

    UnityWaveService()

    Declaration
    public UnityWaveService()

    Fields

    LOG_CATEGORY

    Declaration
    protected const string LOG_CATEGORY = "WaveService"
    Field Value
    Type Description
    string

    _characterSpawnService

    Declaration
    protected ICharacterSpawnService _characterSpawnService
    Field Value
    Type Description
    ICharacterSpawnService

    _currentWaveIndex

    Declaration
    protected int _currentWaveIndex
    Field Value
    Type Description
    int

    _eventDispatcher

    Declaration
    protected IEventDispatcherService _eventDispatcher
    Field Value
    Type Description
    IEventDispatcherService

    _guid

    Declaration
    protected string _guid
    Field Value
    Type Description
    string

    _id

    Declaration
    protected string _id
    Field Value
    Type Description
    string

    _logService

    Declaration
    protected ILogService _logService
    Field Value
    Type Description
    ILogService

    _spawnPointResolver

    Declaration
    protected ISpawnPointResolver _spawnPointResolver
    Field Value
    Type Description
    ISpawnPointResolver

    _waveConfigSOs

    Declaration
    protected List<IWaveConfig> _waveConfigSOs
    Field Value
    Type Description
    List<IWaveConfig>

    _waves

    Declaration
    protected List<WaveState> _waves
    Field Value
    Type Description
    List<WaveState>

    Properties

    AllWavesCleared

    Declaration
    public bool AllWavesCleared { get; }
    Property Value
    Type Description
    bool

    CurrentWaveIndex

    Declaration
    public int CurrentWaveIndex { get; }
    Property Value
    Type Description
    int

    Guid

    Declaration
    public string Guid { get; set; }
    Property Value
    Type Description
    string

    Id

    Declaration
    public string Id { get; set; }
    Property Value
    Type Description
    string

    LogService

    Declaration
    public ILogService LogService { get; set; }
    Property Value
    Type Description
    ILogService

    TotalWaves

    Declaration
    public int TotalWaves { get; }
    Property Value
    Type Description
    int

    Methods

    ConfigureFromWaveSet(IWaveSet)

    Configures waves from a UnityWaveSetSO. Stores SO references for spawn entry access.

    Declaration
    public void ConfigureFromWaveSet(IWaveSet waveSetSO)
    Parameters
    Type Name Description
    IWaveSet waveSetSO

    The wave set to configure from.

    ConfigureWaves(WaveConfig[])

    Declaration
    public void ConfigureWaves(WaveConfig[] configs)
    Parameters
    Type Name Description
    WaveConfig[] configs

    ConfigureWaves(int, int[])

    Declaration
    public void ConfigureWaves(int totalWaves, int[] actorsPerWave)
    Parameters
    Type Name Description
    int totalWaves
    int[] actorsPerWave

    Editor_ForceAdvanceToNextWave()

    Editor-only: force-clears the current wave and starts the next one. Calls RecordActorRemoved() until the wave is cleared, then calls StartNextWave(). Safe to call only in Play mode.

    Declaration
    public void Editor_ForceAdvanceToNextWave()

    Editor_GetWaves()

    Editor-only: returns the internal wave state list for inspector display.

    Declaration
    public IReadOnlyList<WaveState> Editor_GetWaves()
    Returns
    Type Description
    IReadOnlyList<WaveState>

    GetCurrentWaveSnapshot()

    Declaration
    public WaveSnapshot GetCurrentWaveSnapshot()
    Returns
    Type Description
    WaveSnapshot

    IEditor_GetWaveConfigs()

    Editor-only: returns the wave config SO list for inspector display.

    Declaration
    public IReadOnlyList<IWaveConfig> IEditor_GetWaveConfigs()
    Returns
    Type Description
    IReadOnlyList<IWaveConfig>

    InitializeService(ILogService)

    Initializes the service with required dependencies.

    Declaration
    public void InitializeService(ILogService logService)
    Parameters
    Type Name Description
    ILogService logService

    The logging service for diagnostic output.

    OnAllWavesCleared(EventDispatcherSignal)

    Declaration
    protected void OnAllWavesCleared(EventDispatcherSignal signal)
    Parameters
    Type Name Description
    EventDispatcherSignal signal

    OnDestroy()

    Declaration
    protected void OnDestroy()

    OnWaveCleared(EventDispatcherSignal)

    Declaration
    protected void OnWaveCleared(EventDispatcherSignal signal)
    Parameters
    Type Name Description
    EventDispatcherSignal signal

    RecordActorRemoved()

    Declaration
    public void RecordActorRemoved()

    ReleaseCurrentWaveActors()

    Releases all currently active actors via the character spawn service and stops all active spawn coroutines to prevent late spawns from a previous wave.

    Declaration
    protected void ReleaseCurrentWaveActors()

    ScheduleCurrentWaveSpawns()

    Reads the current wave's IWaveConfig and starts a coroutine for each SpawnEntry, honouring SpawnDelay and Count. Must be called after IWaveService.StartNextWave.

    Declaration
    public void ScheduleCurrentWaveSpawns()

    SetSpawnDependencies(IEventDispatcherService, ICharacterSpawnService)

    Injects the event dispatcher and character spawn service required for spawn scheduling and wave-cleared event handling. Called once by the installer after service creation.

    Declaration
    public void SetSpawnDependencies(IEventDispatcherService eventDispatcher, ICharacterSpawnService characterSpawnService)
    Parameters
    Type Name Description
    IEventDispatcherService eventDispatcher
    ICharacterSpawnService characterSpawnService

    SetSpawnPointResolver(ISpawnPointResolver)

    Sets the spawn point resolver used to map spawn-entry IDs to world poses. Typically provided by UnityStageService after instantiating the stage prefab.

    Declaration
    public void SetSpawnPointResolver(ISpawnPointResolver resolver)
    Parameters
    Type Name Description
    ISpawnPointResolver resolver

    The resolver extracted from the stage prefab, or null to clear.

    SpawnEntryCoroutine(SpawnEntry)

    Coroutine that waits for SpawnDelay seconds, then spawns Count actors at the designated spawn point. Delegates instantiation/pooling to ICharacterSpawnService.

    Declaration
    protected virtual IEnumerator SpawnEntryCoroutine(SpawnEntry entry)
    Parameters
    Type Name Description
    SpawnEntry entry
    Returns
    Type Description
    IEnumerator

    StartNextWave()

    Declaration
    public void StartNextWave()

    TryGetCurrentWaveSO(out IWaveConfig)

    Gets the wave SO for the current wave index. Provides access to spawn entries and other Unity-only authoring data.

    Declaration
    public bool TryGetCurrentWaveSO(out IWaveConfig waveSO)
    Parameters
    Type Name Description
    IWaveConfig waveSO

    The current wave's ScriptableObject if available.

    Returns
    Type Description
    bool

    True if a wave SO is available for the current index.

    TryResolveSpawnPose(string, out SpawnPose)

    Resolves a spawn-entry's string-based spawn-point ID to a world SpawnPose. Returns false if the resolver is not set or the ID is unknown.

    Declaration
    public bool TryResolveSpawnPose(string spawnPointId, out SpawnPose pose)
    Parameters
    Type Name Description
    string spawnPointId

    The string identifier authored in the SpawnEntry.

    SpawnPose pose

    The resolved pose, or default if not found.

    Returns
    Type Description
    bool

    True if the spawn point was resolved; false otherwise.

    Implements

    IWaveService
    IService
    IFoundationSettings
    IUnityWaveRuntime
    In this article
    © 2026 Serenity. All Rights Reserved