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

Fix Respawn and RespawnEvent & TeamRespawnSelectedEvent #246

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions NwPluginAPI.Docs/log.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1264,3 +1264,6 @@
{"message":"Invalid link: '<a href=\"articles/gettingstarted/codeprerequisites.md#event-handlers\">Event handlers</a>'. The file articles/gettingstarted/codeprerequisites.md doesn't contain a bookmark named 'event-handlers'.","source":"BuildCommand.Postprocess.HandlePostProcessorsWithIncremental.HandlePostProcessors.Processing html.ValidateBookmark","file":"articles/toc.md","date_time":"2023-04-17T12:01:18.1694264Z","message_severity":"warning","code":"InvalidBookmark","correlation_id":"022C5718-6EA0-4F52-8713-8F5E77AF8928.2.198.1.3.1.21.2"}
{"message":"Invalid link: '[The `Config` class](gettingstarted/codeprerequisites.md#the-config-class)'. The file articles/gettingstarted/codeprerequisites.md doesn't contain a bookmark named 'the-config-class'.","source":"BuildCommand.Postprocess.HandlePostProcessorsWithIncremental.HandlePostProcessors.Processing html.ValidateBookmark","file":"articles/intro.md","line":"11","date_time":"2023-04-17T12:01:18.1694264Z","message_severity":"warning","code":"InvalidBookmark","correlation_id":"022C5718-6EA0-4F52-8713-8F5E77AF8928.2.198.1.3.1.21.3"}
{"message":"Invalid link: '[Event handlers](gettingstarted/codeprerequisites.md#event-handlers)'. The file articles/gettingstarted/codeprerequisites.md doesn't contain a bookmark named 'event-handlers'.","source":"BuildCommand.Postprocess.HandlePostProcessorsWithIncremental.HandlePostProcessors.Processing html.ValidateBookmark","file":"articles/intro.md","line":"12","date_time":"2023-04-17T12:01:18.1694264Z","message_severity":"warning","code":"InvalidBookmark","correlation_id":"022C5718-6EA0-4F52-8713-8F5E77AF8928.2.198.1.3.1.21.4"}
{"message":"Fail to find MSBuild >= 15.0 on machine. Please install Visual Studio 2017 or above with MSBuild >= 15.0: https://visualstudio.microsoft.com/vs/","source":"MetadataCommand.ExtractMetadata","date_time":"2024-12-14T19:25:18.6290761Z","message_severity":"warning","correlation_id":"993E186F-184C-4611-B874-6EDFB99E511A.1.1.1"}
{"message":"Error opening project W:/NwPluginAPI/NwPluginAPI/NwPluginAPI.csproj: Impossible de charger un ou plusieurs des types requis. Extrayez la propriété LoaderExceptions pour plus d'informations.. Ignored.","source":"MetadataCommand.ExtractMetadata","file":"W:/NwPluginAPI/NwPluginAPI/NwPluginAPI.csproj","date_time":"2024-12-14T19:25:19.8252825Z","message_severity":"warning","correlation_id":"993E186F-184C-4611-B874-6EDFB99E511A.1.1.5"}
{"message":"Error extracting metadata for W:/NwPluginAPI/NwPluginAPI/NwPluginAPI.csproj: System.NullReferenceException: La référence d'objet n'est pas définie à une instance d'un objet.\r\n à Microsoft.DocAsCode.Metadata.ManagedReference.ExtractMetadataWorker.<SaveAllMembersFromCacheAsync>d__13.MoveNext()\r\n--- Fin de la trace de la pile à partir de l'emplacement précédent au niveau duquel l'exception a été levée ---\r\n à System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n à System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n à Microsoft.DocAsCode.Metadata.ManagedReference.ExtractMetadataWorker.<ExtractMetadataAsync>d__11.MoveNext()","date_time":"2024-12-14T19:25:19.841786Z","message_severity":"error","code":"FatalError","correlation_id":"993E186F-184C-4611-B874-6EDFB99E511A.2"}
14 changes: 7 additions & 7 deletions NwPluginAPI/Core/Respawn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,25 +55,25 @@ public static float ChaosTokens
/// Gets the next team which will be spawned.
/// </summary>
[Obsolete]
public static SpawnableTeamType NextKnownTeam => SpawnableTeamType.None;
public static Faction NextKnownTeam => Faction.Unclassified;

/// <summary>
/// Adds tickets to a specific team.
/// </summary>
/// <param name="team">The team to add tickets to.</param>
/// <param name="amount">The amount of tickets to add.</param>
public static void AddTickets(SpawnableTeamType team, float amount)
public static void AddTickets(Faction team, float amount)
{
switch (team)
{
case SpawnableTeamType.ChaosInsurgency:
case Faction.FoundationEnemy:
if (!WaveManager.TryGet(Faction.FoundationEnemy, out SpawnableWaveBase chaosWave) || chaosWave is not NtfSpawnWave chaosSpawnWave)
return;

chaosSpawnWave.RespawnTokens += (int)amount;
break;

case SpawnableTeamType.NineTailedFox:
case Faction.FoundationStaff:
if (!WaveManager.TryGet(Faction.FoundationStaff, out SpawnableWaveBase ntfWave) || ntfWave is not NtfSpawnWave ntfSpawnWave)
return;

Expand All @@ -87,11 +87,11 @@ public static void AddTickets(SpawnableTeamType team, float amount)
/// </summary>
/// <param name="team">The team to spawn.</param>
/// <param name="playEffects">Plays spawn effects.</param>
public static void Spawn(SpawnableTeamType team, bool playEffects = false)
public static void Spawn(Faction team, bool playEffects = false)
{
switch (team)
{
case SpawnableTeamType.ChaosInsurgency:
case Faction.FoundationEnemy:
if (!WaveManager.TryGet(Faction.FoundationEnemy, out SpawnableWaveBase chaosWave))
return;

Expand All @@ -100,7 +100,7 @@ public static void Spawn(SpawnableTeamType team, bool playEffects = false)
WaveManager.InitiateRespawn(chaosWave);
break;

case SpawnableTeamType.NineTailedFox:
case Faction.FoundationStaff:
if (!WaveManager.TryGet(Faction.FoundationStaff, out SpawnableWaveBase ntfWave))
return;

Expand Down
8 changes: 4 additions & 4 deletions NwPluginAPI/Events/Args/Server/TeamRespawnEvent.cs
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
using PluginAPI.Core;
using PluginAPI.Enums;
using PluginAPI.Core.Attributes;
using Respawning;
using System.Collections.Generic;
using PlayerRoles;

namespace PluginAPI.Events
namespace PluginAPI.Events.Args.Server
{
public class TeamRespawnEvent : IEventArguments
{
public ServerEventType BaseType { get; } = ServerEventType.TeamRespawn;
[EventArgument]
public SpawnableTeamType Team { get; set; }
public Faction Team { get; set; }
[EventArgument]
public List<Player> Players { get; set; } = new List<Player>();
[EventArgument]
public int NextWaveMaxSize { get; set; }

public TeamRespawnEvent(SpawnableTeamType team, List<ReferenceHub> spectators)
public TeamRespawnEvent(Faction team, List<ReferenceHub> spectators)
{
Team = team;

Expand Down
8 changes: 4 additions & 4 deletions NwPluginAPI/Events/Args/Server/TeamRespawnSelectedEvent.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
using PlayerRoles;
using PluginAPI.Enums;
using PluginAPI.Core.Attributes;
using Respawning;

namespace PluginAPI.Events
namespace PluginAPI.Events.Args.Server
{
public class TeamRespawnSelectedEvent : IEventArguments
{
public ServerEventType BaseType { get; } = ServerEventType.TeamRespawnSelected;
[EventArgument]
public SpawnableTeamType Team { get; }
public Faction Team { get; }

public TeamRespawnSelectedEvent(SpawnableTeamType team)
public TeamRespawnSelectedEvent(Faction team)
{
Team = team;
}
Expand Down
2 changes: 1 addition & 1 deletion NwPluginAPI/NwPluginAPI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,4 @@
<Reference Include="UnityEngine.CoreModule" HintPath="$(UNITY_REFERENCES)\UnityEngine.CoreModule.dll" />
<Reference Include="UnityEngine.PhysicsModule" HintPath="$(UNITY_REFERENCES)\UnityEngine.PhysicsModule.dll" />
</ItemGroup>
</Project>
</Project>
2 changes: 2 additions & 0 deletions TemplatePlugin/EventHandlers.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using PluginAPI.Events.Args.Server;

namespace TemplatePlugin
{
using PlayerRoles.PlayableScps.Scp173;
Expand Down
2 changes: 1 addition & 1 deletion TemplatePlugin/MainClass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ void OnInteractWithLocker(Player plr, Locker locker, LockerChamber chamber, bool
[PluginEvent(ServerEventType.PlayerInteractElevator)]
void OnInteractWithElevator(Player plr, ElevatorChamber elevator)
{
Log.Info($"Player &6{plr.Nickname}&r (&6{plr.UserId}&r) interacted with elevator in position &6{elevator.transform.position}&r with the destination in &6{elevator.CurrentDestination.transform.position}&r");
Log.Info($"Player &6{plr.Nickname}&r (&6{plr.UserId}&r) interacted with elevator in position &6{elevator.transform.position}&r with the destination in &6{elevator.CurSequence}&r");
}

[PluginEvent(ServerEventType.PlayerInteractScp330)]
Expand Down
2 changes: 1 addition & 1 deletion TemplatePlugin/TemplatePlugin.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@
<Reference Include="UnityEngine.CoreModule" HintPath="$(UNITY_REFERENCES)\UnityEngine.CoreModule.dll" />
<Reference Include="UnityEngine.PhysicsModule" HintPath="$(UNITY_REFERENCES)\UnityEngine.PhysicsModule.dll" />
</ItemGroup>
</Project>
</Project>