Skip to content
This repository has been archived by the owner on Jan 19, 2025. It is now read-only.

Commit

Permalink
Fix some patches & RespawnedTeamEventArgs partial fix
Browse files Browse the repository at this point in the history
  • Loading branch information
xNexusACS committed Dec 3, 2024
1 parent 004a1ab commit 052f36c
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 80 deletions.
5 changes: 3 additions & 2 deletions Exiled.Events/EventArgs/Server/RespawnedTeamEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ namespace Exiled.Events.EventArgs.Server
using Exiled.API.Features;
using Exiled.Events.EventArgs.Interfaces;
using Respawning;
using Respawning.Waves;

/// <summary>
/// Contains all information after a team has spawned.
Expand All @@ -24,7 +25,7 @@ public class RespawnedTeamEventArgs : IExiledEvent
/// </summary>
/// <param name="hubs"><inheritdoc cref="Players"/></param>
/// <param name="team"><inheritdoc cref="Team"/></param>
public RespawnedTeamEventArgs(SpawnableTeamType team, IEnumerable<ReferenceHub> hubs)
public RespawnedTeamEventArgs(SpawnableWaveBase team, IEnumerable<ReferenceHub> hubs)
{
Players = hubs.Select(Player.Get);
Team = team;
Expand All @@ -38,6 +39,6 @@ public RespawnedTeamEventArgs(SpawnableTeamType team, IEnumerable<ReferenceHub>
/// <summary>
/// Gets the spawned team.
/// </summary>
public SpawnableTeamType Team { get; }
public SpawnableWaveBase Team { get; }
}
}
9 changes: 4 additions & 5 deletions Exiled.Events/Events.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ namespace Exiled.Events
using CentralAuth;
using Exiled.API.Interfaces;
using Exiled.Events.Features;
using HarmonyLib;
using InventorySystem.Items.Pickups;
using InventorySystem.Items.Usables;
using PlayerRoles.Ragdolls;
Expand Down Expand Up @@ -62,7 +61,7 @@ public override void OnEnabled()
PlayerAuthenticationManager.OnInstanceModeChanged -= RoleAssigner.CheckLateJoin;

SceneManager.sceneUnloaded += Handlers.Internal.SceneUnloaded.OnSceneUnloaded;
MapGeneration.SeedSynchronizer.OnMapGenerated += Handlers.Internal.MapGenerated.OnMapGenerated;
MapGeneration.SeedSynchronizer.OnGenerationFinished += Handlers.Internal.MapGenerated.OnMapGenerated;
UsableItemsController.ServerOnUsingCompleted += Handlers.Internal.Round.OnServerOnUsingCompleted;
Handlers.Server.WaitingForPlayers += Handlers.Internal.Round.OnWaitingForPlayers;
Handlers.Server.RestartingRound += Handlers.Internal.Round.OnRestartingRound;
Expand All @@ -77,7 +76,7 @@ public override void OnEnabled()
InventorySystem.InventoryExtensions.OnItemAdded += Handlers.Player.OnItemAdded;
InventorySystem.InventoryExtensions.OnItemRemoved += Handlers.Player.OnItemRemoved;

RespawnManager.ServerOnRespawned += Handlers.Server.OnRespawnedTeam;
WaveManager.OnWaveSpawned += Handlers.Server.OnRespawnedTeam;

RagdollManager.OnRagdollSpawned += Handlers.Internal.RagdollList.OnSpawnedRagdoll;
RagdollManager.OnRagdollRemoved += Handlers.Internal.RagdollList.OnRemovedRagdoll;
Expand Down Expand Up @@ -110,7 +109,7 @@ public override void OnDisabled()
Unpatch();

SceneManager.sceneUnloaded -= Handlers.Internal.SceneUnloaded.OnSceneUnloaded;
MapGeneration.SeedSynchronizer.OnMapGenerated -= Handlers.Internal.MapGenerated.OnMapGenerated;
MapGeneration.SeedSynchronizer.OnGenerationFinished -= Handlers.Internal.MapGenerated.OnMapGenerated;
UsableItemsController.ServerOnUsingCompleted -= Handlers.Internal.Round.OnServerOnUsingCompleted;

Handlers.Server.WaitingForPlayers -= Handlers.Internal.Round.OnWaitingForPlayers;
Expand All @@ -126,7 +125,7 @@ public override void OnDisabled()
InventorySystem.InventoryExtensions.OnItemAdded -= Handlers.Player.OnItemAdded;
InventorySystem.InventoryExtensions.OnItemRemoved -= Handlers.Player.OnItemRemoved;

RespawnManager.ServerOnRespawned -= Handlers.Server.OnRespawnedTeam;
WaveManager.OnWaveSpawned -= Handlers.Server.OnRespawnedTeam;

RagdollManager.OnRagdollSpawned -= Handlers.Internal.RagdollList.OnSpawnedRagdoll;
RagdollManager.OnRagdollRemoved -= Handlers.Internal.RagdollList.OnRemovedRagdoll;
Expand Down
4 changes: 2 additions & 2 deletions Exiled.Events/Handlers/Server.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ namespace Exiled.Events.Handlers
using System.Collections.Generic;

using Respawning;
using Respawning.Waves;

#pragma warning disable SA1623 // Property summary documentation should match accessors

using Exiled.Events.EventArgs.Player;
using Exiled.Events.EventArgs.Server;
using Exiled.Events.Features;

Expand Down Expand Up @@ -197,7 +197,7 @@ public static class Server
/// </summary>
/// <param name="teamType"><inheritdoc cref="RespawnedTeamEventArgs.Team"/></param>
/// <param name="hubs"><inheritdoc cref="RespawnedTeamEventArgs.Players"/></param>
public static void OnRespawnedTeam(SpawnableTeamType teamType, List<ReferenceHub> hubs) => RespawnedTeam.InvokeSafely(new RespawnedTeamEventArgs(teamType, hubs));
public static void OnRespawnedTeam(SpawnableWaveBase teamType, List<ReferenceHub> hubs) => RespawnedTeam.InvokeSafely(new RespawnedTeamEventArgs(teamType, hubs));

/// <summary>
/// Called before adding an unit name.
Expand Down
54 changes: 0 additions & 54 deletions Exiled.Events/Patches/Generic/AddRespawnTargetMultiplierConfig.cs

This file was deleted.

10 changes: 4 additions & 6 deletions Exiled.Events/Patches/Generic/LiftList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,24 @@

namespace Exiled.Events.Patches.Generic
{
using System.Collections.Generic;

using API.Features;

using HarmonyLib;
using Interactables.Interobjects;

/// <summary>
/// Patches <see cref="ElevatorManager.RefreshChambers"/>.
/// Patches <see cref="ElevatorManager.SpawnChamber"/>.
/// </summary>
[HarmonyPatch(typeof(ElevatorManager), nameof(ElevatorManager.RefreshChambers))]
[HarmonyPatch(typeof(ElevatorManager), nameof(ElevatorManager.SpawnAllChambers))]
internal class LiftList
{
private static void Postfix()
{
Lift.ElevatorChamberToLift.Clear();

foreach (KeyValuePair<ElevatorManager.ElevatorGroup, ElevatorChamber> lift in ElevatorManager.SpawnedChambers)
foreach (ElevatorChamber lift in ElevatorChamber.AllChambers)
{
Lift.Get(lift.Value);
Lift.Get(lift);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions Exiled.Events/Patches/Generic/PickupControlPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ namespace Exiled.Events.Patches.Generic

#pragma warning disable SA1402 /// File may only contain a single type.
/// <summary>
/// Patches <see cref="InventoryExtensions.ServerCreatePickup(ItemBase, PickupSyncInfo, Vector3, Quaternion, bool, Action{ItemPickupBase})"/> to save scale for pickups and control <see cref="Pickup.IsSpawned"/> property.
/// Patches <see cref="InventoryExtensions.ServerCreatePickup(ItemBase, PickupSyncInfo?, Vector3, Quaternion, bool, Action{ItemPickupBase})"/> to save scale for pickups and control <see cref="Pickup.IsSpawned"/> property.
/// </summary>
[HarmonyPatch(typeof(InventoryExtensions), nameof(InventoryExtensions.ServerCreatePickup), typeof(ItemBase), typeof(PickupSyncInfo), typeof(Vector3), typeof(Quaternion), typeof(bool), typeof(Action<ItemPickupBase>))]
[HarmonyPatch(typeof(InventoryExtensions), nameof(InventoryExtensions.ServerCreatePickup), typeof(ItemBase), typeof(PickupSyncInfo?), typeof(Vector3), typeof(Quaternion), typeof(bool), typeof(Action<ItemPickupBase>))]
internal static class PickupControlPatch
{
private static IEnumerable<CodeInstruction> Transpiler(
Expand Down
2 changes: 1 addition & 1 deletion Exiled.Events/Patches/Generic/TargetOffset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ internal static class TargetOffset
private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
{
static bool IsField(CodeInstruction instruction) => instruction.opcode == OpCodes.Ldfld
&& (FieldInfo)instruction.operand == Field(typeof(RoundSummary), nameof(RoundSummary._chaosTargetCount));
&& (FieldInfo)instruction.operand == Field(typeof(RoundSummary), nameof(RoundSummary._extraTargets));

List<CodeInstruction> newInstructions = ListPool<CodeInstruction>.Pool.Get(instructions);

Expand Down
22 changes: 14 additions & 8 deletions Exiled.Events/Patches/Generic/TeleportList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,26 @@

namespace Exiled.Events.Patches.Generic
{
#pragma warning disable SA1313
#pragma warning disable SA1402
using API.Features;
using HarmonyLib;
using MapGeneration;

/// <summary>
/// Patches <see cref="ImageGenerator.GenerateMap(int, string, out string)"/>.
/// Patches <see cref="PocketDimensionTeleport.Awake"/>.
/// </summary>
[HarmonyPatch(typeof(ImageGenerator), nameof(ImageGenerator.GenerateMap))]
[HarmonyPatch(typeof(PocketDimensionTeleport), nameof(PocketDimensionTeleport.Awake))]
internal class TeleportList
{
private static void Prefix()
{
Map.TeleportsValue.Clear();
Map.TeleportsValue.AddRange(UnityEngine.Object.FindObjectsOfType<PocketDimensionTeleport>());
}
private static void Postfix(PocketDimensionTeleport __instance) => Map.TeleportsValue.Add(__instance);
}

/// <summary>
/// Patches <see cref="PocketDimensionTeleport.OnDestroy"/>.
/// </summary>
[HarmonyPatch(typeof(PocketDimensionTeleport), nameof(PocketDimensionTeleport.OnDestroy))]
internal class TeleportListRemove
{
private static void Postfix(PocketDimensionTeleport __instance) => Map.TeleportsValue.Remove(__instance);
}
}

0 comments on commit 052f36c

Please sign in to comment.