diff --git a/EXILED/Exiled.Events/EventArgs/Server/RespawnedTeamEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Server/RespawnedTeamEventArgs.cs new file mode 100644 index 000000000..4aaa2b363 --- /dev/null +++ b/EXILED/Exiled.Events/EventArgs/Server/RespawnedTeamEventArgs.cs @@ -0,0 +1,43 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) Exiled Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- + +namespace Exiled.Events.EventArgs.Server +{ + using System.Collections.Generic; + using System.Linq; + + using Exiled.API.Features; + using Exiled.Events.EventArgs.Interfaces; + using Respawning; + + /// + /// Contains all information after team spawns. + /// + public class RespawnedTeamEventArgs : IExiledEvent + { + /// + /// Initializes a new instance of the class. + /// + /// + /// + public RespawnedTeamEventArgs(SpawnableTeamType team, IEnumerable hubs) + { + Players = hubs.Select(Player.Get); + Team = team; + } + + /// + /// Gets the list of spawned players. + /// + public IEnumerable Players { get; } + + /// + /// Gets the spawned team. + /// + public SpawnableTeamType Team { get; } + } +} diff --git a/EXILED/Exiled.Events/Events.cs b/EXILED/Exiled.Events/Events.cs index 178071bb7..4c5fcabc5 100644 --- a/EXILED/Exiled.Events/Events.cs +++ b/EXILED/Exiled.Events/Events.cs @@ -21,6 +21,7 @@ namespace Exiled.Events using PlayerRoles.Ragdolls; using PlayerRoles.RoleAssign; using PluginAPI.Events; + using Respawning; using UnityEngine.SceneManagement; /// @@ -70,7 +71,7 @@ public override void OnEnabled() Handlers.Map.ChangedIntoGrenade += Handlers.Internal.ExplodingGrenade.OnChangedIntoGrenade; CharacterClassManager.OnRoundStarted += Handlers.Server.OnRoundStarted; - + RespawnManager.ServerOnRespawned += Handlers.Server.OnRespawnedTeam; InventorySystem.InventoryExtensions.OnItemAdded += Handlers.Player.OnItemAdded; InventorySystem.InventoryExtensions.OnItemRemoved += Handlers.Player.OnItemRemoved; @@ -105,7 +106,7 @@ public override void OnDisabled() InventorySystem.InventoryExtensions.OnItemAdded -= Handlers.Player.OnItemAdded; InventorySystem.InventoryExtensions.OnItemRemoved -= Handlers.Player.OnItemRemoved; - + RespawnManager.ServerOnRespawned -= Handlers.Server.OnRespawnedTeam; RagdollManager.OnRagdollSpawned -= Handlers.Internal.RagdollList.OnSpawnedRagdoll; RagdollManager.OnRagdollRemoved -= Handlers.Internal.RagdollList.OnRemovedRagdoll; ItemPickupBase.OnPickupAdded -= Handlers.Internal.PickupEvent.OnSpawnedPickup; diff --git a/EXILED/Exiled.Events/Handlers/Server.cs b/EXILED/Exiled.Events/Handlers/Server.cs index 1b3d0481a..75be4d81c 100644 --- a/EXILED/Exiled.Events/Handlers/Server.cs +++ b/EXILED/Exiled.Events/Handlers/Server.cs @@ -7,6 +7,9 @@ namespace Exiled.Events.Handlers { + using System.Collections.Generic; + + using Respawning; #pragma warning disable SA1623 // Property summary documentation should match accessors using Exiled.Events.EventArgs.Player; @@ -53,6 +56,11 @@ public static class Server /// public static Event RespawningTeam { get; set; } = new(); + /// + /// Invoked after team spawns. + /// + public static Event RespawnedTeam { get; set; } = new(); + /// /// Invoked before adding an unit name. /// @@ -142,6 +150,13 @@ public static class Server /// The instance. public static void OnRespawningTeam(RespawningTeamEventArgs ev) => RespawningTeam.InvokeSafely(ev); + /// + /// Called after team spawns. + /// + /// + /// + public static void OnRespawnedTeam(SpawnableTeamType teamType, List hubs) => RespawnedTeam.InvokeSafely(new RespawnedTeamEventArgs(teamType, hubs)); + /// /// Called before adding an unit name. ///