Class UnityWaveService
Inheritance
UnityWaveService
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
_characterSpawnService
Declaration
protected ICharacterSpawnService _characterSpawnService
Field Value
_currentWaveIndex
Declaration
protected int _currentWaveIndex
Field Value
_eventDispatcher
Declaration
protected IEventDispatcherService _eventDispatcher
Field Value
_guid
Declaration
Field Value
_id
Declaration
Field Value
_logService
Declaration
protected ILogService _logService
Field Value
_spawnPointResolver
Declaration
protected ISpawnPointResolver _spawnPointResolver
Field Value
_waveConfigSOs
Declaration
protected List<IWaveConfig> _waveConfigSOs
Field Value
_waves
Declaration
protected List<WaveState> _waves
Field Value
Properties
AllWavesCleared
Declaration
public bool AllWavesCleared { get; }
Property Value
CurrentWaveIndex
Declaration
public int CurrentWaveIndex { get; }
Property Value
Guid
Declaration
public string Guid { get; set; }
Property Value
Id
Declaration
public string Id { get; set; }
Property Value
LogService
Declaration
public ILogService LogService { get; set; }
Property Value
TotalWaves
Declaration
public int TotalWaves { get; }
Property Value
Methods
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
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
GetCurrentWaveSnapshot()
Declaration
public WaveSnapshot GetCurrentWaveSnapshot()
Returns
IEditor_GetWaveConfigs()
Editor-only: returns the wave config SO list for inspector display.
Declaration
public IReadOnlyList<IWaveConfig> IEditor_GetWaveConfigs()
Returns
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
OnDestroy()
Declaration
protected void OnDestroy()
OnWaveCleared(EventDispatcherSignal)
Declaration
protected void OnWaveCleared(EventDispatcherSignal signal)
Parameters
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
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)
Declaration
protected virtual IEnumerator SpawnEntryCoroutine(SpawnEntry entry)
Parameters
Returns
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