RustTip

OnExcavatorGather

OxideCarbonResource

Called when an excavator gathers.

object OnExcavatorGather(ExcavatorArm excavatorArm, Item local8)
Works — the game method in this build is the one the hook was written for.

Parameters

excavatorArm
ExcavatorArm
local8
Item

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 OnExcavatorGather(ExcavatorArm excavatorArm, Item local8)
{
    Puts("OnExcavatorGather");

    // 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

Rust.opj (Oxide)
void ExcavatorArm.ProduceResources()

Passes: ExcavatorArm excavatorArm, Item local8

WorksReturnBehavior: ExitWhenValidTypeArgumentBehavior: UseArgumentString (this, l8)Assembly-CSharp.dll

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

// …
{
	continue;
}
int num3 = Mathf.FloorToInt(itemAmount.amount / (float)outputPiles.Count);
itemAmount.amount -= num3 * 2;
foreach (ExcavatorOutputPile outputPile in outputPiles)
{
	Item item = ItemManager.Create(resourcesToMine[resourceMiningIndex].itemDef, num3, 0uL, isServerSide: true, 0uL);
	if (Interface.CallHook("OnExcavatorGather", this, item) != null)
	{
		return;
	}
	Analytics.Azure.OnExcavatorProduceItem(item, this);
	if (!item.MoveToContainer(outputPile.inventory))
	{
		item.Drop(outputPile.GetDropPosition(), outputPile.GetDropVelocity());
	}
// …

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.