OnItemRecycle
OxideCarbonItemCalled when an item recycles.
object OnItemRecycle(Item local3, Recycler recycler)
object OnItemRecycle(Recycler recycler, object arg1)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
- local3
- Item
- recycler
- Recycler
Return value
objectReturn non-null to cancel the game action.
Example
object — you can affect the game: return a value to change or cancel the action.
private object OnItemRecycle(Item local3, Recycler recycler)
{
Puts("OnItemRecycle");
// change nothing — the game continues as usual
return null;
// to affect the game:
// return false; // non-null cancels the game action
}Works in both Oxide and Carbon: Carbon loads Oxide plugins as is.
Injection point 1
Rust.opj (Oxide)
void Recycler.RecycleThink()
Passes: Item local3, Recycler recycler
Method changed — checkReturnBehavior: ExitWhenValidTypeArgumentBehavior: UseArgumentString (l3, this)Assembly-CSharp.dll
Where it is called (this branch's game code)
// …
float num = lastFetchedEfficiency;
for (int i = 0; i < 6; i++)
{
Item slot = inventory.GetSlot(i);
if (!CanBeRecycled(slot))
{
continue;
}
if (Interface.CallHook("OnItemRecycle", slot, this) != null)
{
return;
}
if (slot.hasCondition)
{
num = Mathf.Clamp01(num * Mathf.Clamp(slot.conditionNormalized * slot.maxConditionNormalized, 0.1f, 1f));
}
int num2 = 1;
// …Injection point 2
Rust.opj (Oxide)
void Recycler.RecycleThink()
Passes: Recycler recycler, object arg1
Method changed — checkReturnBehavior: ExitWhenNonNullAssembly-CSharp.dll
Where it is called (this branch's game code)
// …
{
Item slot = inventory.GetSlot(i);
if (!CanBeRecycled(slot))
{
continue;
}
if (slot.hasCondition)
{
if (Interface.CallHook("OnItemRecycle", this, Recycler.HasRecyclable()) == null)
{
return;
}
num = Mathf.Clamp01(num * Mathf.Clamp(slot.conditionNormalized * slot.maxConditionNormalized, 0.1f, 1f));
}
int num2 = 1;
if (slot.amount > 1)
{
// …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.