Skip to content

Commit

Permalink
New game update (#310)
Browse files Browse the repository at this point in the history
* fixes

* all is fixed

* fix no.2

* Update EXILED/Exiled.API/Extensions/RoleExtensions.cs

Co-authored-by: Bolton <[email protected]>

* Update EXILED/Exiled.Events/Patches/Events/Server/SelectingRespawnTeam.cs

Co-authored-by: Misaka-ZeroTwo <[email protected]>

* Update EXILED/Exiled.Events/Patches/Events/Server/SelectingRespawnTeam.cs

* team reborn

---------

Co-authored-by: Bolton <[email protected]>
Co-authored-by: Misaka-ZeroTwo <[email protected]>
  • Loading branch information
3 people authored Dec 13, 2024
1 parent 941aacd commit c8d8fd5
Show file tree
Hide file tree
Showing 16 changed files with 211 additions and 136 deletions.
14 changes: 1 addition & 13 deletions EXILED/Exiled.API/Extensions/RoleExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -256,19 +256,7 @@ public static Dictionary<AmmoType, ushort> GetStartingAmmo(this RoleTypeId roleT
};

/// <summary>
/// Gets the <see cref="Faction"/> associated with the provided <see cref="SpawnableTeamType"/>.
/// </summary>
/// <param name="spawnableTeamType">A member of the <see cref="SpawnableTeamType"/>enum.</param>
/// <returns><see cref="Faction"/> associated with the provided <paramref name="spawnableTeamType"/>.</returns>
public static Faction GetFaction(this SpawnableTeamType spawnableTeamType) => spawnableTeamType switch
{
SpawnableTeamType.ChaosInsurgency => Faction.FoundationEnemy,
SpawnableTeamType.NineTailedFox => Faction.FoundationStaff,
_ => Faction.Unclassified,
};

/// <summary>
/// Tries to get the <see cref="SpawnableFaction"/> associated with the provided <see cref="SpawnableTeamType"/> and <see cref="bool"/>.
/// Tries to get the <see cref="SpawnableFaction"/> associated with the provided <see cref="Faction"/> and <see cref="bool"/>.
/// </summary>
/// <param name="faction">A member of the <see cref="Faction"/>enum.</param>
/// <param name="spawnableFaction">The <see cref="SpawnableFaction"/> to return.</param>
Expand Down
2 changes: 1 addition & 1 deletion EXILED/Exiled.API/Features/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -831,7 +831,7 @@ public bool IsGodModeEnabled
/// <summary>
/// Gets the player's unit name.
/// </summary>
public string UnitName => Role.Base is PlayerRoles.HumanRole humanRole ? UnitNameMessageHandler.GetReceived(humanRole.AssignedSpawnableTeam, humanRole.UnitNameId) : string.Empty;
public string UnitName => Role is HumanRole humanRole ? humanRole.UnitName : string.Empty;

/// <summary>
/// Gets or sets the player's unit id.
Expand Down
52 changes: 4 additions & 48 deletions EXILED/Exiled.API/Features/Respawn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,21 +72,15 @@ public static GameObject ChaosVan
/// <remarks>This returns <see cref="SpawnableFaction.None">SpawnableFaction.None</see> unless a respawn has already started.</remarks>
public static SpawnableFaction NextKnownSpawnableFaction => WaveManager._nextWave is not null ? WaveManager._nextWave.GetSpawnableFaction() : SpawnableFaction.None;

/// <summary>
/// Gets the next known <see cref="SpawnableTeamType"/> that will spawn.
/// </summary>
/// <remarks>This returns <see cref="SpawnableFaction.None">SpawnableFaction.None</see> unless a respawn has already started.</remarks>
public static SpawnableTeamType NextKnownTeam => NextKnownSpawnableFaction.GetFaction().GetSpawnableTeam();

/// <summary>
/// Gets the current state of the <see cref="WaveManager"/>.
/// </summary>
public static WaveManager.WaveQueueState CurrentState => WaveManager.State;
public static WaveQueueState CurrentState => WaveManager.State;

/// <summary>
/// Gets a value indicating whether the respawn process for a <see cref="SpawnableWaveBase"/> is currently in progress..
/// </summary>
public static bool IsSpawning => WaveManager.State == WaveManager.WaveQueueState.WaveSpawning;
public static bool IsSpawning => WaveManager.State == WaveQueueState.WaveSpawning;

/// <summary>
/// Gets or sets a value indicating whether spawn protection is enabled.
Expand Down Expand Up @@ -165,18 +159,6 @@ public static bool TryGetWaveBases(Faction faction, out IEnumerable<SpawnableWav
return true;
}

/// <summary>
/// Tries to get an <see cref="IEnumerable{T}"/> of <see cref="SpawnableWaveBase"/>.
/// </summary>
/// <param name="spawnableTeamType">A <see cref="SpawnableTeamType"/> determining which waves to search for.</param>
/// <param name="spawnableWaveBases">The <see cref="IEnumerable{T}"/> containing found <see cref="SpawnableWaveBase"/>'s if there are any, otherwise <c>null</c>.</param>
/// <returns><c>true</c> if <paramref name="spawnableWaveBases"/> was successfully found. Otherwise, <c>false</c>.</returns>
/// <seealso cref="TryGetWaveBase{T}"/>
public static bool TryGetWaveBases(SpawnableTeamType spawnableTeamType, out IEnumerable<SpawnableWaveBase> spawnableWaveBases)
{
return TryGetWaveBases(spawnableTeamType.GetFaction(), out spawnableWaveBases);
}

/// <summary>
/// Advances the respawn timer for <see cref="TimeBasedWave"/>s.
/// </summary>
Expand All @@ -193,22 +175,6 @@ public static bool TryGetWaveBases(SpawnableTeamType spawnableTeamType, out IEnu
/// <remarks>This advances the timer for both the normal and mini wave.</remarks>
public static void AdvanceTimer(Faction faction, TimeSpan time) => AdvanceTimer(faction, (float)time.TotalSeconds);

/// <summary>
/// Advances the respawn timer for <see cref="TimeBasedWave"/>s.
/// </summary>
/// <param name="spawnableTeamType">The <see cref="SpawnableTeamType"/> whose <see cref="TimeBasedWave"/>'s timers are to be advanced.</param>
/// <param name="seconds">Number of seconds to advance the timers by.</param>
/// <remarks>This advances the timer for both the normal and mini wave.</remarks>
public static void AdvanceTimer(SpawnableTeamType spawnableTeamType, float seconds) => AdvanceTimer(spawnableTeamType.GetFaction(), seconds);

/// <summary>
/// Advances the respawn timer for <see cref="TimeBasedWave"/>s.
/// </summary>
/// <param name="spawnableTeamType">The <see cref="SpawnableTeamType"/> whose <see cref="TimeBasedWave"/>'s timers are to be advanced.</param>
/// <param name="time">A <see cref="TimeSpan"/> representing the amount of time to advance the timers by.</param>
/// <remarks>This advances the timer for both the normal and mini wave.</remarks>
public static void AdvanceTimer(SpawnableTeamType spawnableTeamType, TimeSpan time) => AdvanceTimer(spawnableTeamType.GetFaction(), time);

/// <summary>
/// Advances the respawn timer for <see cref="TimeBasedWave"/>s.
/// </summary>
Expand Down Expand Up @@ -243,7 +209,7 @@ public static void PlayEffect(SpawnableWaveBase wave)
}

/// <summary>
/// Summons the <see cref="SpawnableTeamType.NineTailedFox"/> chopper.
/// Summons the NTF chopper.
/// </summary>
public static void SummonNtfChopper()
{
Expand All @@ -252,7 +218,7 @@ public static void SummonNtfChopper()
}

/// <summary>
/// Summons the <see cref="SpawnableTeamType.ChaosInsurgency"/> van.
/// Summons the Chaos Insurgency van.
/// </summary>
/// <remarks>This will also trigger Music effect.</remarks>
/// <!--not sure if it actually plays the music, needs to be tested-->
Expand Down Expand Up @@ -360,16 +326,6 @@ public static bool SetTokens(SpawnableFaction spawnableFaction, int amount)
return false;
}

/// <summary>
/// Starts the spawn sequence of the given <see cref="SpawnableTeamType"/>.
/// </summary>
/// <param name="spawnableTeamType">The <see cref="SpawnableTeamType"/> whose wave to spawn.</param>
/// <param name="isMini">Whether the wave should be a mini wave or not.</param>
public static void ForceWave(SpawnableTeamType spawnableTeamType, bool isMini = false)
{
ForceWave(spawnableTeamType.GetFaction(), isMini);
}

/// <summary>
/// Starts the spawn sequence of the given <see cref="Faction"/>.
/// </summary>
Expand Down
11 changes: 1 addition & 10 deletions EXILED/Exiled.API/Features/Roles/HumanRole.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,10 @@ internal HumanRole(HumanGameRole baseRole)
/// <inheritdoc/>
public override RoleTypeId Type => Base.RoleTypeId;

/// <summary>
/// Gets or sets the <see cref="SpawnableTeamType"/>.
/// </summary>
public SpawnableTeamType SpawnableTeamType
{
get => Base.AssignedSpawnableTeam;
set => Base.AssignedSpawnableTeam = value;
}

/// <summary>
/// Gets the player's unit name.
/// </summary>
public string UnitName => UnitNameMessageHandler.GetReceived(Base.AssignedSpawnableTeam, Base.UnitNameId);
public string UnitName => NamingRulesManager.ClientFetchReceived(Team, UnitNameId);

/// <summary>
/// Gets or sets the <see cref="UnitNameId"/>.
Expand Down
54 changes: 35 additions & 19 deletions EXILED/Exiled.API/Features/Waves/TimedWave.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@
namespace Exiled.API.Features.Waves
{
using System.Collections.Generic;

using System.Linq;

using Exiled.API.Enums;
using PlayerRoles;

using Respawning;

using Respawning.Announcements;
using Respawning.Waves;

/// <summary>
Expand Down Expand Up @@ -55,13 +54,30 @@ public class TimedWave
/// <summary>
/// Gets the team of this wave.
/// </summary>
public SpawnableTeamType Team => timedWave.TargetFaction.GetSpawnableTeam();
public Team Team => timedWave.TargetFaction.GetSpawnableTeam();

/// <summary>
/// Gets the spawnable faction for this wave.
/// </summary>
public SpawnableFaction SpawnableFaction => Faction switch
{
Faction.FoundationStaff when IsMiniWave => SpawnableFaction.NtfMiniWave,
Faction.FoundationStaff => SpawnableFaction.NtfWave,
Faction.FoundationEnemy when IsMiniWave => SpawnableFaction.ChaosMiniWave,
_ => SpawnableFaction.ChaosWave
};

/// <summary>
/// Gets the maximum amount of people that can spawn in this wave.
/// </summary>
public int MaxAmount => timedWave.MaxWaveSize;

/// <summary>
/// Gets the <see cref="WaveAnnouncementBase"/> for this wave.
/// </summary>
/// <remarks>Wave must implement <see cref="IAnnouncedWave"/>.</remarks>
public WaveAnnouncementBase Announcement => timedWave is IAnnouncedWave announcedWave ? announcedWave.Announcement : null;

/// <summary>
/// Get the timed waves for the specified faction.
/// </summary>
Expand All @@ -88,28 +104,22 @@ public static bool TryGetTimedWaves(Faction faction, out List<TimedWave> waves)
}

/// <summary>
/// Get the timed wave for the specified team.
/// Get the timed waves for the specified faction.
/// </summary>
/// <param name="team">
/// The team to get the wave for.
/// </param>
/// <param name="waves">
/// The waves if found.
/// </param>
/// <returns>
/// A value indicating whether the wave were found.
/// </returns>
public static bool TryGetTimedWaves(SpawnableTeamType team, out List<TimedWave> waves)
/// <param name="team">The faction to get the waves for.</param>
/// <param name="waves">The waves if found.</param>
/// <returns>A value indicating whether the wave were found.</returns>
public static bool TryGetTimedWaves(Team team, out List<TimedWave> waves)
{
if (team == SpawnableTeamType.None)
List<SpawnableWaveBase> spawnableWaveBases = WaveManager.Waves.Where(w => w is TimeBasedWave wave && wave.TargetFaction.GetSpawnableTeam() == team).ToList();
if(!spawnableWaveBases.Any())
{
waves = null;
return false;
}

Faction faction = team == SpawnableTeamType.NineTailedFox ? Faction.FoundationStaff : Faction.FoundationEnemy;

return TryGetTimedWaves(faction, out waves);
waves = spawnableWaveBases.Select(w => new TimedWave((TimeBasedWave)w)).ToList();
return true;
}

/// <summary>
Expand Down Expand Up @@ -175,5 +185,11 @@ public static List<TimedWave> GetTimedWaves()
/// The amount of people to populate.
/// </param>
public void PopulateQueue(Queue<RoleTypeId> queue, int amount) => timedWave.PopulateQueue(queue, amount);

/// <summary>
/// Plays the announcement for this wave.
/// </summary>
/// <remarks>Wave must implement <see cref="IAnnouncedWave"/>.</remarks>
public void PlayAnnouncement() => Announcement?.PlayAnnouncement();
}
}
4 changes: 2 additions & 2 deletions EXILED/Exiled.API/Features/Waves/WaveTimer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,12 @@ public static bool TryGetWaveTimers(Faction faction, out List<WaveTimer> waves)
}

/// <summary>
/// Gets the wave timers for the specified team.
/// Get the wave timers for the specified faction.
/// </summary>
/// <param name="team">The team.</param>
/// <param name="waves">The waves, if any.</param>
/// <returns>A bool indicating if waves were found.</returns>
public static bool TryGetWaveTimers(SpawnableTeamType team, out List<WaveTimer> waves)
public static bool TryGetWaveTimers(Team team, out List<WaveTimer> waves)
{
if (!TimedWave.TryGetTimedWaves(team, out List<TimedWave> timedWaves))
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// -----------------------------------------------------------------------
// <copyright file="AnnouncingChaosEntranceEventArgs.cs" company="ExMod Team">
// Copyright (c) ExMod Team. All rights reserved.
// Licensed under the CC BY-SA 3.0 license.
// </copyright>
// -----------------------------------------------------------------------

namespace Exiled.Events.EventArgs.Map
{
using Exiled.API.Features.Waves;
using Exiled.Events.EventArgs.Interfaces;
using Respawning.Announcements;

/// <summary>
/// Contains all information before Chaos wave entrance.
/// </summary>
public class AnnouncingChaosEntranceEventArgs : IDeniableEvent
{
/// <summary>
/// Initializes a new instance of the <see cref="AnnouncingChaosEntranceEventArgs"/> class.
/// </summary>
/// <param name="announcement"><inheritdoc cref="Wave"/></param>
/// <param name="isAllowed"><inheritdoc cref="IsAllowed"/></param>
public AnnouncingChaosEntranceEventArgs(WaveAnnouncementBase announcement, bool isAllowed = true)
{
Wave = TimedWave.GetTimedWaves().Find(x => x.Announcement == announcement);
IsAllowed = isAllowed;
}

/// <summary>
/// Gets the entering wave.
/// </summary>
public TimedWave Wave { get; }

/// <inheritdoc/>
public bool IsAllowed { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,6 @@ public AnnouncingNtfEntranceEventArgs(int scpsLeft, string unitName, int unitNum
/// <summary>
/// Gets or sets a value indicating whether the NTF spawn will be announced by C.A.S.S.I.E.
/// </summary>
public bool IsAllowed { get; set; }
public bool IsAllowed { get; set; } // TODO possibly not working
}
}
10 changes: 5 additions & 5 deletions EXILED/Exiled.Events/EventArgs/Server/RespawningTeamEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ namespace Exiled.Events.EventArgs.Server
using System.Collections.Generic;

using Exiled.API.Features;
using Exiled.API.Features.Waves;
using Exiled.Events.EventArgs.Interfaces;
using PlayerRoles;
using Respawning;
using Respawning.Waves;

/// <summary>
/// Contains all information before spawning a wave of <see cref="SpawnableTeamType.NineTailedFox" /> or
/// <see cref="SpawnableTeamType.ChaosInsurgency" />.
/// Contains all information before spawning a wave.
/// </summary>
public class RespawningTeamEventArgs : IDeniableEvent
{
Expand All @@ -40,7 +40,7 @@ public RespawningTeamEventArgs(List<Player> players, int maxRespawn, SpawnableWa
Players = players;
MaximumRespawnAmount = maxRespawn;
SpawnQueue = WaveSpawner.SpawnQueue;
Wave = wave;
Wave = new TimedWave((TimeBasedWave)wave);
IsAllowed = true;
}

Expand Down Expand Up @@ -70,12 +70,12 @@ public int MaximumRespawnAmount
/// <summary>
/// Gets or sets a value indicating what the next wave is.
/// </summary>
public SpawnableWaveBase Wave { get; set; }
public TimedWave Wave { get; set; }

/// <summary>
/// Gets a value indicating what the next respawnable team is.
/// </summary>
public SpawnableTeamType NextKnownTeam => Wave.TargetFaction.GetSpawnableTeam();
public Faction NextKnownTeam => Wave.Faction;

/// <summary>
/// Gets or sets a value indicating whether the spawn can occur.
Expand Down
Loading

0 comments on commit c8d8fd5

Please sign in to comment.