RustTip

OnItemRecycleAmount

OxideCarbonItem

Called when item recycle amount occurs.

object OnItemRecycleAmount(Item item, int int32, object this => l4)
Method changed — check — the game method differs from the one the hook is recorded for in Oxide. The hook is still called, but its place may have shifted — worth checking after an update.

Parameters

item
Item
int32
int
this => l4
object

Return value

objectThe returned value modifies the result, the game continues.

Example

object — you can affect the game: return a value to change or cancel the action.

private object OnItemRecycleAmount(Item item, int int32, object this => l4)
{
    Puts("OnItemRecycleAmount");

    // change nothing — the game continues as usual
    return null;

    // to affect the game:
    // return default(int); // your value instead of the game result
}

Works in both Oxide and Carbon: Carbon loads Oxide plugins as is.

Injection point

Rust.opj (Oxide)
void Recycler.RecycleThink()

Passes: Item item, int int32, object this => l4

Method changed — checkReturnBehavior: UseArgumentStringArgumentBehavior: UseArgumentString (l3, l4, this => l4)Assembly-CSharp.dll

Where it is called (this branch's game code)

// …
}
int num2 = 1;
if (slot.amount > 1)
{
	num2 = Mathf.CeilToInt(Mathf.Min(slot.amount, (float)slot.MaxStackable() * 0.1f));
}
if (slot.info.Blueprint.scrapFromRecycle > 0)
{
	Interface.CallHook("OnItemRecycleAmount", slot, num2, this => l4);
	float num3 = slot.info.Blueprint.scrapFromRecycle * num2;
	if (slot.MaxStackable() == 1 && slot.hasCondition)
	{
		num3 *= slot.conditionNormalized;
	}
	float num4 = num / 0.5f;
	num3 *= num4;
	int num5 = Mathf.FloorToInt(num3);
// …

Sources: Rust.opj from OxideMod/Oxide.Rust (MIT) and hook metadata of the Carbon documentation (MIT). Method code is decompiled from this branch's server.