diff --git a/Exiled.API/Features/Map.cs b/Exiled.API/Features/Map.cs index 96ce18c60f..c2c512a983 100644 --- a/Exiled.API/Features/Map.cs +++ b/Exiled.API/Features/Map.cs @@ -147,7 +147,7 @@ public static int Seed /// /// Gets the . /// - public static AmbientSoundPlayer AmbientSoundPlayer => ambientSoundPlayer != null ? ambientSoundPlayer : (ambientSoundPlayer = ReferenceHub.HostHub.GetComponent()); + public static AmbientSoundPlayer AmbientSoundPlayer => ambientSoundPlayer ??= ReferenceHub.HostHub.GetComponent(); /// /// Broadcasts a message to all players. diff --git a/Exiled.Events/Patches/Generic/PickupControlPatch.cs b/Exiled.Events/Patches/Generic/PickupControlPatch.cs index ef2a4edf29..536f312faa 100644 --- a/Exiled.Events/Patches/Generic/PickupControlPatch.cs +++ b/Exiled.Events/Patches/Generic/PickupControlPatch.cs @@ -26,9 +26,8 @@ namespace Exiled.Events.Patches.Generic using static HarmonyLib.AccessTools; -#pragma warning disable SA1402 /// File may only contain a single type. /// - /// Patches to save scale for pickups and control property. + /// Patches to save scale for pickups. /// [HarmonyPatch(typeof(InventoryExtensions), nameof(InventoryExtensions.ServerCreatePickup), typeof(ItemBase), typeof(PickupSyncInfo), typeof(Vector3), typeof(Quaternion), typeof(bool), typeof(Action))] internal static class PickupControlPatch @@ -44,9 +43,10 @@ private static IEnumerable Transpiler( newInstructions.InsertRange(index, new CodeInstruction[] { - // pickup = Pickup.Get(pickupBase); + // Pickup.Get(pickupBase); new(OpCodes.Ldloc_0), new(OpCodes.Call, Method(typeof(Pickup), nameof(Pickup.Get), new[] { typeof(ItemPickupBase) })), + new(OpCodes.Pop), /* // Item.Get(itemBase); @@ -55,36 +55,6 @@ private static IEnumerable Transpiler( // pickup.GetItemInfo(item); new(OpCodes.Callvirt, Method(typeof(Pickup), nameof(Pickup.GetItemInfo))),*/ - - // pickup.IsSpawned = spawn - new(OpCodes.Ldarg_S, 4), - new(OpCodes.Callvirt, PropertySetter(typeof(Pickup), nameof(Pickup.IsSpawned))), - }); - - for (int z = 0; z < newInstructions.Count; z++) - yield return newInstructions[z]; - - ListPool.Pool.Return(newInstructions); - } - } - - /// - /// Patches to control property for delayed spawned pickup. - /// - [HarmonyPatch(typeof(ItemDistributor), nameof(ItemDistributor.SpawnPickup))] - internal static class TriggerPickupControlPatch - { - private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) - { - List newInstructions = ListPool.Pool.Get(instructions); - - newInstructions.InsertRange(newInstructions.Count - 1, new CodeInstruction[] - { - // Pickup.Get(pickupBase).IsSpawned = true - new(OpCodes.Ldarg_0), - new(OpCodes.Call, Method(typeof(Pickup), nameof(Pickup.Get), new[] { typeof(ItemPickupBase) })), - new(OpCodes.Ldc_I4_1), - new(OpCodes.Callvirt, PropertySetter(typeof(Pickup), nameof(Pickup.IsSpawned))), }); for (int z = 0; z < newInstructions.Count; z++)