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..7336b67a65 100644 --- a/EXILED/Exiled.API/Features/Doors/Door.cs +++ b/EXILED/Exiled.API/Features/Doors/Door.cs @@ -293,6 +293,7 @@ public static Door Get(DoorVariant doorVariant) if (doorVariant == null) return null; + if (doorVariant.Rooms == null) { doorVariant.RegisterRooms(); diff --git a/EXILED/Exiled.Events/EventArgs/Map/SpawningItemEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Map/SpawningItemEventArgs.cs index 4476b88419..c289c6b692 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; diff --git a/EXILED/Exiled.Events/Patches/Events/Map/SpawningItem.cs b/EXILED/Exiled.Events/Patches/Events/Map/SpawningItem.cs index df768a3048..2e74a6d8b0 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))] @@ -40,6 +45,9 @@ private static IEnumerable Transpiler(IEnumerable Transpiler(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];