Skip to content

Commit

Permalink
formatting stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
Banalny-Banan committed Nov 28, 2024
1 parent 6a9c9b6 commit 407ee99
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
8 changes: 2 additions & 6 deletions EXILED/Exiled.Events/EventArgs/Player/ShootingEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,13 @@
// </copyright>
// -----------------------------------------------------------------------

using InventorySystem.Items.Firearms.Modules.Misc;

namespace Exiled.Events.EventArgs.Player
{
using API.Features;

using Exiled.API.Features.Items;

using Interfaces;

using InventorySystem.Items.Firearms.Modules.Misc;

using BaseFirearm = InventorySystem.Items.Firearms.Firearm;

/// <summary>
Expand All @@ -36,7 +33,6 @@ public ShootingEventArgs(BaseFirearm firearm, ShotBacktrackData shotBacktrackDat
Firearm = (Firearm)Item.Get(firearm);
Player = Firearm.Owner;
ShotBacktrackData = shotBacktrackData;
// ShotMessage = msg;
}

/// <summary>
Expand Down
9 changes: 5 additions & 4 deletions EXILED/Exiled.Events/Patches/Events/Player/Shooting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace Exiled.Events.Patches.Events.Player
/// Adds the <see cref="Handlers.Player.Shooting" /> events.
/// </summary>
[EventPatch(typeof(Handlers.Player), nameof(Handlers.Player.Shooting))]

[HarmonyPatch(typeof(ShotBacktrackData), nameof(ShotBacktrackData.ProcessShot))]
internal static class Shooting
{
Expand Down Expand Up @@ -56,19 +56,20 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi
int noTargetIndex = newInstructions.FindIndex(hasTargetIndex, instruction => instruction.IsLdarg(2)) - 1;
List<Label> noTargetLabels = newInstructions[noTargetIndex].ExtractLabels();

CodeInstruction[] patchInstructions = {
CodeInstruction[] patchInstructions =
{
// ShootingEventArgs ev = new(firearm, this)
new(OpCodes.Ldarg_0),
new(OpCodes.Ldarg_1),
new(OpCodes.Newobj, GetDeclaredConstructors(typeof(ShootingEventArgs))[0]),

// Handlers.Player.OnShooting(ev)
new(OpCodes.Dup), // Dup to keep ev on the stack
new(OpCodes.Call, Method(typeof(Handlers.Player), nameof(Handlers.Player.OnShooting))),

// if (!ev.IsAllowed) return
new(OpCodes.Callvirt, PropertyGetter(typeof(ShootingEventArgs), nameof(ShootingEventArgs.IsAllowed))),
new(OpCodes.Brfalse_S, returnLabel),
new(OpCodes.Brfalse_S, returnLabel),
};

newInstructions.InsertRange( // noTargetIndex goes first because it's higher then hasTargetIndex so it won't mess it up
Expand Down

0 comments on commit 407ee99

Please sign in to comment.