From 5c4b4bee218cfa4e58b1728fd510e97d8008a273 Mon Sep 17 00:00:00 2001
From: Undid-Iridium <24619207+Undid-Iridium@users.noreply.github.com>
Date: Fri, 30 May 2025 20:23:52 -0400
Subject: [PATCH 1/5] a
---
.../Patches/Events/Map/SpawningItem.cs | 35 ++++++++++++-------
1 file changed, 23 insertions(+), 12 deletions(-)
diff --git a/EXILED/Exiled.Events/Patches/Events/Map/SpawningItem.cs b/EXILED/Exiled.Events/Patches/Events/Map/SpawningItem.cs
index df768a3048..757a6fe07a 100644
--- a/EXILED/Exiled.Events/Patches/Events/Map/SpawningItem.cs
+++ b/EXILED/Exiled.Events/Patches/Events/Map/SpawningItem.cs
@@ -10,22 +10,27 @@ namespace Exiled.Events.Patches.Events.Map
using System.Collections.Generic;
using System.Reflection.Emit;
+ using API.Features;
using API.Features.Doors;
- using API.Features.Pickups;
using API.Features.Pools;
- using Exiled.Events.Attributes;
- using Exiled.Events.EventArgs.Map;
- using Handlers;
+ using Attributes;
+
+ using EventArgs.Map;
+
using HarmonyLib;
+
using Interactables.Interobjects.DoorUtils;
+
using MapGeneration.Distributors;
using static HarmonyLib.AccessTools;
+ using Map = Handlers.Map;
+
///
/// Patches .
- /// Adds the event.
+ /// Adds the event.
///
[EventPatch(typeof(Map), nameof(Map.SpawningItem))]
[HarmonyPatch(typeof(ItemDistributor), nameof(ItemDistributor.ServerRegisterPickup))]
@@ -49,6 +54,8 @@ private static IEnumerable Transpiler(IEnumerable instruction.Calls(Method(typeof(ItemDistributor), nameof(ItemDistributor.SpawnPickup)))) + offset;
+ Log.Info("\n\nWoooooooooooooooooa\n\n");
+
newInstructions.InsertRange(
index,
new[]
@@ -57,24 +64,28 @@ private static IEnumerable Transpiler(IEnumerable), "TryGetValue", new[] { typeof(string), typeof(DoorNametagExtension).MakeByRefType() })),
+ new(OpCodes.Pop),
// initiallySpawn = false
- new CodeInstruction(OpCodes.Ldc_I4_0).MoveLabelsFrom(newInstructions[lastIndex]),
+ new CodeInstruction(OpCodes.Ldc_I4_0).WithLabels(skip),
new(OpCodes.Stloc_S, initiallySpawn.LocalIndex),
// door = doorNametagExtension.TargetDoor
- new(OpCodes.Ldloc_2),
+ new(OpCodes.Ldloc_1),
new(OpCodes.Ldfld, Field(typeof(DoorVariantExtension), nameof(DoorVariantExtension.TargetDoor))),
new(OpCodes.Stloc_S, door.LocalIndex),
// ipb
- new CodeInstruction(OpCodes.Ldloc_1).WithLabels(skip),
+ new CodeInstruction(OpCodes.Ldarg_0),
// initiallySpawn
new(OpCodes.Ldloc_S, initiallySpawn.LocalIndex),
From 9e69d27c628f92877a157051561d491daeadc4d8 Mon Sep 17 00:00:00 2001
From: Undid-Iridium <24619207+Undid-Iridium@users.noreply.github.com>
Date: Thu, 5 Jun 2025 18:34:42 -0400
Subject: [PATCH 2/5] a
---
EXILED/Exiled.API/Exiled.API.csproj | 13 +++++++++-
EXILED/Exiled.API/Features/Doors/Door.cs | 4 +++
.../EventArgs/Map/SpawningItemEventArgs.cs | 6 +++++
.../Patches/Events/Map/SpawningItem.cs | 26 +++++++------------
4 files changed, 32 insertions(+), 17 deletions(-)
diff --git a/EXILED/Exiled.API/Exiled.API.csproj b/EXILED/Exiled.API/Exiled.API.csproj
index c8737a790c..0d86a22672 100644
--- a/EXILED/Exiled.API/Exiled.API.csproj
+++ b/EXILED/Exiled.API/Exiled.API.csproj
@@ -41,7 +41,18 @@
- if not "$(EXILED_DEV_PLUGINAPI_REFERENCE)"=="" copy /y "$(OutputPath)$(AssemblyName).dll" "$(EXILED_DEV_PLUGINAPI_REFERENCE)\dependencies\" && if not "$(EXILED_DEV_REFERENCES)"=="" copy /y "$(OutputPath)$(AssemblyName).dll" "$(EXILED_DEV_REFERENCES)\Plugins\dependencies\"
+
+ if not "$(EXILED_DEV_PLUGINAPI_REFERENCE)"=="" (
+ copy /y "$(OutputPath)$(AssemblyName).dll" "$(EXILED_DEV_PLUGINAPI_REFERENCE)\dependencies\"
+ )
+ if not "$(EXILED_DEV_REFERENCES)"=="" (
+ copy /y "$(OutputPath)$(AssemblyName).dll" "$(EXILED_DEV_REFERENCES)\Plugins\dependencies\"
+ )
+ if not "$(EXILED_DEV_PLUGINAPI_REFERENCE_GLOBAL)"=="" (
+ if not exist "$(EXILED_DEV_PLUGINAPI_REFERENCE_GLOBAL)\dependencies\global" mkdir "$(EXILED_DEV_PLUGINAPI_REFERENCE_GLOBAL)\dependencies\global"
+ copy /y "$(OutputPath)$(AssemblyName).dll" "$(EXILED_DEV_PLUGINAPI_REFERENCE_GLOBAL)\dependencies\global\"
+ )
+
if [[ ! -z "$EXILED_DEV_REFERENCES" ]]; then cp "$(OutputPath)$(AssemblyName).dll" "$EXILED_DEV_REFERENCES/Plugins/dependencies/"; fi
diff --git a/EXILED/Exiled.API/Features/Doors/Door.cs b/EXILED/Exiled.API/Features/Doors/Door.cs
index e4fbd1e770..25f428161b 100644
--- a/EXILED/Exiled.API/Features/Doors/Door.cs
+++ b/EXILED/Exiled.API/Features/Doors/Door.cs
@@ -290,14 +290,18 @@ public Vector3 Scale
/// A wrapper object.
public static Door Get(DoorVariant doorVariant)
{
+ Log.Info($"uh is door null? {doorVariant == null}");
if (doorVariant == null)
return null;
+ Log.Info($"uh is door room null? {doorVariant.Rooms == null}");
+
if (doorVariant.Rooms == null)
{
doorVariant.RegisterRooms();
}
+ Log.Info($"uh is door not in door variant to door? {DoorVariantToDoor.ContainsKey(doorVariant)}");
// Exiled door must be created after the `RegisterRooms` call
return DoorVariantToDoor[doorVariant];
}
diff --git a/EXILED/Exiled.Events/EventArgs/Map/SpawningItemEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Map/SpawningItemEventArgs.cs
index 4476b88419..088076dced 100644
--- a/EXILED/Exiled.Events/EventArgs/Map/SpawningItemEventArgs.cs
+++ b/EXILED/Exiled.Events/EventArgs/Map/SpawningItemEventArgs.cs
@@ -7,6 +7,8 @@
namespace Exiled.Events.EventArgs.Map
{
+ using API.Features;
+
using Exiled.API.Features.Doors;
using Exiled.API.Features.Pickups;
using Exiled.Events.EventArgs.Interfaces;
@@ -32,9 +34,13 @@ public class SpawningItemEventArgs : IDeniableEvent, IPickupEvent
///
public SpawningItemEventArgs(ItemPickupBase pickupBase, bool shouldInitiallySpawn, DoorVariant door)
{
+ Log.Info("pickup (spawning item event)");
Pickup = Pickup.Get(pickupBase);
+ Log.Info("TriggerDoor (spawning item event)");
TriggerDoor = Door.Get(door);
+ Log.Info("ShouldInitiallySpawn (spawning item event)");
ShouldInitiallySpawn = shouldInitiallySpawn;
+ Log.Info("Done (spawning item event)");
}
///
diff --git a/EXILED/Exiled.Events/Patches/Events/Map/SpawningItem.cs b/EXILED/Exiled.Events/Patches/Events/Map/SpawningItem.cs
index 757a6fe07a..d0ccc71118 100644
--- a/EXILED/Exiled.Events/Patches/Events/Map/SpawningItem.cs
+++ b/EXILED/Exiled.Events/Patches/Events/Map/SpawningItem.cs
@@ -45,6 +45,7 @@ private static IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable), "TryGetValue", new[] { typeof(string), typeof(DoorNametagExtension).MakeByRefType() })),
- new(OpCodes.Pop),
-
- // initiallySpawn = false
- new CodeInstruction(OpCodes.Ldc_I4_0).WithLabels(skip),
+ // initiallySpawn = true
+ new CodeInstruction(OpCodes.Ldc_I4_1),
new(OpCodes.Stloc_S, initiallySpawn.LocalIndex),
- // door = doorNametagExtension.TargetDoor
+ // door = doorNametagExtension.TargetDoor if not null, otherwise, null door
+ new(OpCodes.Ldloc_1),
+ new(OpCodes.Brfalse, skip),
new(OpCodes.Ldloc_1),
new(OpCodes.Ldfld, Field(typeof(DoorVariantExtension), nameof(DoorVariantExtension.TargetDoor))),
- new(OpCodes.Stloc_S, door.LocalIndex),
+ new(OpCodes.Br, storeData),
+ new CodeInstruction(OpCodes.Ldnull).WithLabels(skip),
+ new CodeInstruction(OpCodes.Stloc, door.LocalIndex).WithLabels(storeData),
// ipb
- new CodeInstruction(OpCodes.Ldarg_0),
+ new CodeInstruction(OpCodes.Ldarg_1),
// initiallySpawn
new(OpCodes.Ldloc_S, initiallySpawn.LocalIndex),
From 6a9b08ee7325dec10e1b08a17b04fa21cb1b48f1 Mon Sep 17 00:00:00 2001
From: Undid-Iridium <24619207+Undid-Iridium@users.noreply.github.com>
Date: Thu, 5 Jun 2025 19:38:14 -0400
Subject: [PATCH 3/5] Someone in their infinite wisdom forgot to check if the
event object even existed in this scenario
---
.../Patches/Events/Map/SpawningItem.cs | 21 ++++++++++++-------
1 file changed, 14 insertions(+), 7 deletions(-)
diff --git a/EXILED/Exiled.Events/Patches/Events/Map/SpawningItem.cs b/EXILED/Exiled.Events/Patches/Events/Map/SpawningItem.cs
index d0ccc71118..2e74a6d8b0 100644
--- a/EXILED/Exiled.Events/Patches/Events/Map/SpawningItem.cs
+++ b/EXILED/Exiled.Events/Patches/Events/Map/SpawningItem.cs
@@ -45,6 +45,8 @@ private static IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable instruction.Calls(Method(typeof(ItemDistributor), nameof(ItemDistributor.SpawnPickup)))) + offset;
- Log.Info("\n\nWoooooooooooooooooa\n\n");
-
newInstructions.InsertRange(
index,
new[]
@@ -122,20 +122,27 @@ private static IEnumerable Transpiler(IEnumerable i.opcode == OpCodes.Ldfld) + offset;
+ index = newInstructions.FindLastIndex(i => i.LoadsField(Field(typeof(DoorVariantExtension), nameof(DoorVariantExtension.TargetDoor)))) + offset;
+
+ newInstructions[index].WithLabels(allowOriginalLogic);
- newInstructions.RemoveRange(index, 2);
+ int temp_instr = newInstructions.FindLastIndex(i => i.Calls(PropertyGetter(typeof(UnityEngine.Component), nameof(UnityEngine.Component.gameObject)))) - 1;
+ newInstructions[temp_instr].WithLabels(loadGameObjectLocation);
newInstructions.InsertRange(index, new[]
{
// ev.Door.Base
- new CodeInstruction(OpCodes.Ldloc_S, ev.LocalIndex),
+ new CodeInstruction(OpCodes.Ldloc, ev.LocalIndex),
+ new(OpCodes.Brfalse, allowOriginalLogic),
+ new CodeInstruction(OpCodes.Ldloc, ev.LocalIndex),
+ new(OpCodes.Callvirt, PropertyGetter(typeof(SpawningItemEventArgs), nameof(SpawningItemEventArgs.TriggerDoor))),
+ new(OpCodes.Brfalse, allowOriginalLogic),
+ new CodeInstruction(OpCodes.Ldloc, ev.LocalIndex),
new(OpCodes.Callvirt, PropertyGetter(typeof(SpawningItemEventArgs), nameof(SpawningItemEventArgs.TriggerDoor))),
new(OpCodes.Callvirt, PropertyGetter(typeof(Door), nameof(Door.Base))),
+ new(OpCodes.Br, loadGameObjectLocation),
});
-
newInstructions[newInstructions.Count - 1].WithLabels(returnLabel);
-
for (int z = 0; z < newInstructions.Count; z++)
yield return newInstructions[z];
From 265ed558cdd513b8e3beeed13bc5796416918ed0 Mon Sep 17 00:00:00 2001
From: Undid-Iridium <24619207+Undid-Iridium@users.noreply.github.com>
Date: Thu, 5 Jun 2025 19:39:55 -0400
Subject: [PATCH 4/5] c
---
EXILED/Exiled.API/Features/Doors/Door.cs | 3 ---
1 file changed, 3 deletions(-)
diff --git a/EXILED/Exiled.API/Features/Doors/Door.cs b/EXILED/Exiled.API/Features/Doors/Door.cs
index 25f428161b..7336b67a65 100644
--- a/EXILED/Exiled.API/Features/Doors/Door.cs
+++ b/EXILED/Exiled.API/Features/Doors/Door.cs
@@ -290,18 +290,15 @@ public Vector3 Scale
/// A wrapper object.
public static Door Get(DoorVariant doorVariant)
{
- Log.Info($"uh is door null? {doorVariant == null}");
if (doorVariant == null)
return null;
- Log.Info($"uh is door room null? {doorVariant.Rooms == null}");
if (doorVariant.Rooms == null)
{
doorVariant.RegisterRooms();
}
- Log.Info($"uh is door not in door variant to door? {DoorVariantToDoor.ContainsKey(doorVariant)}");
// Exiled door must be created after the `RegisterRooms` call
return DoorVariantToDoor[doorVariant];
}
From f0af8f00b449b8b50d33f857ef40572241341493 Mon Sep 17 00:00:00 2001
From: Undid-Iridium <24619207+Undid-Iridium@users.noreply.github.com>
Date: Thu, 5 Jun 2025 19:40:13 -0400
Subject: [PATCH 5/5] c
---
EXILED/Exiled.Events/EventArgs/Map/SpawningItemEventArgs.cs | 4 ----
1 file changed, 4 deletions(-)
diff --git a/EXILED/Exiled.Events/EventArgs/Map/SpawningItemEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Map/SpawningItemEventArgs.cs
index 088076dced..c289c6b692 100644
--- a/EXILED/Exiled.Events/EventArgs/Map/SpawningItemEventArgs.cs
+++ b/EXILED/Exiled.Events/EventArgs/Map/SpawningItemEventArgs.cs
@@ -34,13 +34,9 @@ public class SpawningItemEventArgs : IDeniableEvent, IPickupEvent
///
public SpawningItemEventArgs(ItemPickupBase pickupBase, bool shouldInitiallySpawn, DoorVariant door)
{
- Log.Info("pickup (spawning item event)");
Pickup = Pickup.Get(pickupBase);
- Log.Info("TriggerDoor (spawning item event)");
TriggerDoor = Door.Get(door);
- Log.Info("ShouldInitiallySpawn (spawning item event)");
ShouldInitiallySpawn = shouldInitiallySpawn;
- Log.Info("Done (spawning item event)");
}
///