Skip to content

Commit

Permalink
Revert "ThrowingRequest (#1759)"
Browse files Browse the repository at this point in the history
This reverts commit 386e511.
  • Loading branch information
joker-119 committed May 10, 2023
1 parent c806799 commit 1544575
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
14 changes: 10 additions & 4 deletions Exiled.Events/EventArgs/Player/ThrowingRequestEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,31 @@

namespace Exiled.Events.EventArgs.Player
{
using System;

using Exiled.API.Enums;
using Exiled.API.Features;
using Exiled.API.Features.Items;
using Exiled.Events.EventArgs.Interfaces;

using InventorySystem.Items.ThrowableProjectiles;

/// <summary>
/// Contains all information before receving a throwing request.
/// </summary>
public class ThrowingRequestEventArgs : IPlayerEvent
public class ThrowingRequestEventArgs : IPlayerEvent, IDeniableEvent
{
/// <summary>
/// Initializes a new instance of the <see cref="ThrowingRequestEventArgs"/> class.
/// </summary>
/// <param name="player"><inheritdoc cref="Player"/></param>
/// <param name="item"><inheritdoc cref="Throwable"/></param>
/// <param name="request"><inheritdoc cref="RequestType"/></param>
public ThrowingRequestEventArgs(Player player, ThrowableItem item, ThrowableNetworkHandler.RequestType request)
/// <param name="isAllowed"><inheritdoc cref="IsAllowed"/></param>
public ThrowingRequestEventArgs(Player player, ThrowableItem item, ThrowableNetworkHandler.RequestType request, bool isAllowed = true)
{
Player = player;
Throwable = (Throwable)Item.Get(item);
RequestType = (ThrowRequest)request;
IsAllowed = isAllowed;
}

/// <summary>
Expand All @@ -47,5 +48,10 @@ public ThrowingRequestEventArgs(Player player, ThrowableItem item, ThrowableNetw
/// Gets or sets the type of throw being requested.
/// </summary>
public ThrowRequest RequestType { get; set; }

/// <summary>
/// Gets or sets a value indicating whether or not the grenade can be thrown.
/// </summary>
public bool IsAllowed { get; set; } = true;
}
}
7 changes: 6 additions & 1 deletion Exiled.Events/Patches/Events/Player/ThrowingRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,16 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi
// ThrowingRequestEventArgs ev = new(Player.Get(referenceHub), ThrowableItem,Networkconnection.Request, true);
new(OpCodes.Newobj, GetDeclaredConstructors(typeof(ThrowingRequestEventArgs))[0]),
new(OpCodes.Dup),
new(OpCodes.Dup),
new(OpCodes.Stloc_S, ev.LocalIndex),

// Handlers.Player.OnThrowingRequest(ev);
new(OpCodes.Call, Method(typeof(Handlers.Player), nameof(Handlers.Player.OnThrowingRequest))),

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

// Networkconnection.Serial
new(OpCodes.Ldarg_1),
new(OpCodes.Ldfld, Field(typeof(ThrowableNetworkHandler.ThrowableItemRequestMessage), nameof(ThrowableNetworkHandler.ThrowableItemRequestMessage.Serial))),
Expand Down Expand Up @@ -98,4 +103,4 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi
ListPool<CodeInstruction>.Pool.Return(newInstructions);
}
}
}
}

0 comments on commit 1544575

Please sign in to comment.