Skip to content

Commit

Permalink
Moving Item.Get inside the eventargs instead of transpiller
Browse files Browse the repository at this point in the history
  • Loading branch information
louis1706 committed Aug 2, 2024
1 parent 62fd4d4 commit 7d62ef0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,13 @@ public class ChangingAttachmentsEventArgs : IPlayerEvent, IDeniableEvent, IFirea
/// <param name="isAllowed">
/// <inheritdoc cref="IsAllowed" />
/// </param>
public ChangingAttachmentsEventArgs(
Player player,
Firearm firearm,
uint code,
bool isAllowed = true)
public ChangingAttachmentsEventArgs(Player player, InventorySystem.Items.Firearms.Firearm firearm, uint code, bool isAllowed = true)
{
Player = player;
Firearm = firearm;
CurrentAttachmentIdentifiers = firearm.AttachmentIdentifiers;
NewAttachmentIdentifiers = firearm.FirearmType.GetAttachmentIdentifiers(code).ToList();
CurrentCode = firearm.Base.GetCurrentAttachmentsCode();
Firearm = Item.Get<Firearm>(firearm);
CurrentAttachmentIdentifiers = Firearm.AttachmentIdentifiers;
NewAttachmentIdentifiers = Firearm.FirearmType.GetAttachmentIdentifiers(code).ToList();
CurrentCode = firearm.GetCurrentAttachmentsCode();
NewCode = code;
IsAllowed = isAllowed;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,8 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi
new(OpCodes.Callvirt, PropertyGetter(typeof(NetworkIdentity), nameof(NetworkIdentity.netId))),
new(OpCodes.Call, Method(typeof(Player), nameof(Player.Get), new[] { typeof(uint) })),

// Item::Get(firearm)
// firearm
new(OpCodes.Ldloc_1),
new(OpCodes.Call, GetDeclaredMethods(typeof(Item)).First(x => !x.IsGenericMethod && x.Name is nameof(Item.Get) && x.GetParameters().Length is 1 && x.GetParameters()[0].ParameterType == typeof(InventorySystem.Items.ItemBase))),
new(OpCodes.Castclass, typeof(Firearm)),

// AttachmentsChangeRequest::AttachmentsCode
new(OpCodes.Ldarg_1),
Expand All @@ -80,7 +78,7 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi
// true
new(OpCodes.Ldc_I4_1),

// ChangingAttachmentsEventArgs ev = new ChangingAttachmentsEventArgs(__ARGS__)
// ChangingAttachmentsEventArgs ev = new ChangingAttachmentsEventArgs(Player, Firearm, uint, bool)
new(OpCodes.Newobj, GetDeclaredConstructors(typeof(ChangingAttachmentsEventArgs))[0]),
new(OpCodes.Dup),
new(OpCodes.Dup),
Expand Down

0 comments on commit 7d62ef0

Please sign in to comment.