Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ModifyToken #2148

Merged
merged 6 commits into from
Oct 24, 2023
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
15 changes: 11 additions & 4 deletions Exiled.API/Features/Respawn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public static float TimeUntilNextPhase
public static float ChaosTickets
{
get => RespawnTokensManager.Counters[0].Amount;
set => RespawnTokensManager.GrantTokens(SpawnableTeamType.ChaosInsurgency, value);
set => RespawnTokensManager.ModifyTokens(SpawnableTeamType.ChaosInsurgency, value);
}

/// <summary>
Expand All @@ -103,7 +103,7 @@ public static float ChaosTickets
public static float NtfTickets
{
get => RespawnTokensManager.Counters[1].Amount;
set => RespawnTokensManager.GrantTokens(SpawnableTeamType.NineTailedFox, value);
set => RespawnTokensManager.ModifyTokens(SpawnableTeamType.NineTailedFox, value);
}

/// <summary>
Expand Down Expand Up @@ -195,14 +195,21 @@ public static void SummonChaosInsurgencyVan(bool playMusic = true)
/// </summary>
/// <param name="team">The <see cref="SpawnableTeamType"/> to grant tickets to.</param>
/// <param name="amount">The amount of tickets to grant.</param>
public static void GrantTickets(SpawnableTeamType team, float amount) => RespawnTokensManager.GrantTokens(team, amount);
public static void GrantTickets(SpawnableTeamType team, float amount) => RespawnTokensManager.ModifyTokens(team, Math.Max(0, amount));

/// <summary>
/// Removes tickets from a <see cref="SpawnableTeamType"/>.
/// </summary>
/// <param name="team">The <see cref="SpawnableTeamType"/> to remove tickets from.</param>
/// <param name="amount">The amount of tickets to remove.</param>
public static void RemoveTickets(SpawnableTeamType team, float amount) => RespawnTokensManager.RemoveTokens(team, amount);
public static void RemoveTickets(SpawnableTeamType team, float amount) => RespawnTokensManager.ModifyTokens(team, Math.Min(0, amount));

/// <summary>
/// Modify tickets from a <see cref="SpawnableTeamType"/>.
/// </summary>
/// <param name="team">The <see cref="SpawnableTeamType"/> to modify tickets from.</param>
/// <param name="amount">The amount of tickets to modify.</param>
public static void ModifyTickets(SpawnableTeamType team, float amount) => RespawnTokensManager.ModifyTokens(team, amount);

/// <summary>
/// Forces a spawn of the given <see cref="SpawnableTeamType"/>.
Expand Down
Loading