Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ public DroppingScp330EventArgs(Player player, Scp330Bag scp330, CandyKindID cand
}

/// <summary>
/// Gets or sets a value representing the <see cref="API.Features.Items.Item" /> being picked up.
/// Gets a value representing the <see cref="API.Features.Items.Item" /> being picked up.
/// </summary>
public Scp330 Scp330 { get; set; } // Todo Remove set
public Scp330 Scp330 { get; }

/// <inheritdoc/>
public Item Item => Scp330;
Expand Down
18 changes: 12 additions & 6 deletions EXILED/Exiled.Events/Patches/Events/Scp330/DroppingCandy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,14 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi

// scp330Bag
new(OpCodes.Ldloc_1),

// Load candy bag array to get CandyKindID
new(OpCodes.Dup),
new(OpCodes.Ldfld, Field(typeof(Scp330Bag), nameof(Scp330Bag.Candies))),
new(OpCodes.Ldarg_1),

// Grab candy ID from network message, and pass it to event args.
// msg.CandyID
new(OpCodes.Ldarg_1),
new(OpCodes.Ldfld, Field(typeof(SelectScp330Message), nameof(SelectScp330Message.CandyID))),
new(OpCodes.Ldelem_U1),

// CandyKindID
new(OpCodes.Call, Method(typeof(DroppingCandy), nameof(DroppingCandy.GetCandyID))),

// DroppingScp330EventArgs ev = new(Player, Scp330Bag, CandyKindID)
new(OpCodes.Newobj, GetDeclaredConstructors(typeof(DroppingScp330EventArgs))[0]),
Expand Down Expand Up @@ -105,5 +104,12 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi

ListPool<CodeInstruction>.Pool.Return(newInstructions);
}

private static CandyKindID GetCandyID(Scp330Bag scp330Bag, int index)
{
if (index < 0 || index > scp330Bag.Candies.Count)
return CandyKindID.None;
return scp330Bag.Candies[index];
}
}
}