Skip to content
Merged
Changes from all commits
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
73 changes: 73 additions & 0 deletions EXILED/Exiled.API/Features/Respawn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,26 @@ public static void ForceWave(SpawnableWaveBase spawnableWaveBase)
WaveManager.Spawn(spawnableWaveBase);
}

/// <summary>
/// Pauses a specific respawn wave by removing it from the active wave list and adding it to the paused wave list.
/// </summary>
/// <param name="spawnableFaction">The <see cref="SpawnableFaction"/> representing the wave to pause.</param>
public static void PauseWave(SpawnableFaction spawnableFaction)
{
if (TryGetWaveBase(spawnableFaction, out SpawnableWaveBase spawnableWaveBase))
{
if (!PausedWaves.Contains(spawnableWaveBase))
{
PausedWaves.Add(spawnableWaveBase);
}

if (WaveManager.Waves.Contains(spawnableWaveBase))
{
WaveManager.Waves.Remove(spawnableWaveBase);
}
}
}

/// <summary>
/// Pauses respawn waves by removing them from <see cref="WaveManager.Waves">WaveManager.Waves</see> and storing them in <see cref="PausedWaves"/>.
/// </summary>
Expand All @@ -399,6 +419,21 @@ public static void PauseWaves()
WaveManager.Waves.Clear();
}

/// <summary>
/// Pauses the specified list of respawn waves by iterating through each wave
/// and pausing it using the <see cref="PauseWave(SpawnableFaction)"/> method.
/// </summary>
/// <param name="spawnableFactions">
/// A list of <see cref="SpawnableFaction"/> instances representing the waves to pause.
/// </param>
public static void PauseWaves(List<SpawnableFaction> spawnableFactions)
{
foreach (SpawnableFaction spawnableFaction in spawnableFactions)
{
PauseWave(spawnableFaction);
}
}

/// <summary>
/// Resumes respawn waves by filling <see cref="WaveManager.Waves">WaveManager.Waves</see> with values stored in <see cref="PausedWaves"/>.
/// </summary>
Expand All @@ -411,6 +446,29 @@ public static void ResumeWaves()
PausedWaves.Clear();
}

/// <summary>
/// Restarts a specific respawn wave by adding it back to the active wave list
/// and removing it from the paused wave list if necessary.
/// </summary>
/// <param name="spawnableFaction">
/// The <see cref="SpawnableFaction"/> representing the wave to restart.
/// </param>
public static void RestartWave(SpawnableFaction spawnableFaction)
{
if (TryGetWaveBase(spawnableFaction, out SpawnableWaveBase spawnableWaveBase))
{
if (!WaveManager.Waves.Contains(spawnableWaveBase))
{
WaveManager.Waves.Add(spawnableWaveBase);
}

if (PausedWaves.Contains(spawnableWaveBase))
{
PausedWaves.Remove(spawnableWaveBase);
}
}
}

/// <summary>
/// Restarts respawn waves by clearing <see cref="WaveManager.Waves">WaveManager.Waves</see> and filling it with new values..
/// </summary>
Expand All @@ -423,6 +481,21 @@ public static void RestartWaves()
PausedWaves.Clear();
}

/// <summary>
/// Restarts the specified respawn waves by iterating through each wave
/// and restarting it using the <see cref="RestartWave(SpawnableFaction)"/> method.
/// </summary>
/// <param name="spawnableFactions">
/// A list of <see cref="SpawnableFaction"/> instances representing the waves to restart.
/// </param>
public static void RestartWaves(List<SpawnableFaction> spawnableFactions)
{
foreach (SpawnableFaction spawnableFaction in spawnableFactions)
{
RestartWave(spawnableFaction);
}
}

/// <summary>
/// Tries to get the influence value of a given <see cref="Faction"/>.
/// </summary>
Expand Down