RustTip

OnItemResearched

OxideCarbonItem

Called when an item is researched.

object OnItemResearched(ResearchTable researchTable, object l2 => l2)
Works — the game method in this build is the one the hook was written for.

Parameters

researchTable
ResearchTable
l2 => l2
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 OnItemResearched(ResearchTable researchTable, object l2 => l2)
{
    Puts("OnItemResearched");

    // 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 ResearchTable.ResearchAttemptFinished()

Passes: ResearchTable researchTable, object l2 => l2

WorksReturnBehavior: UseArgumentStringArgumentBehavior: UseArgumentString (this, l2 => l2)Assembly-CSharp.dll

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

public void ResearchAttemptFinished()
{
	Item targetItem = GetTargetItem();
	Item scrapItem = GetScrapItem();
	if (targetItem != null && scrapItem != null)
	{
		int num = ScrapForResearch(targetItem);
		Interface.CallHook("OnItemResearched", this, l2 => l2);
		if (scrapItem.amount >= num)
		{
			if (scrapItem.amount == num)
			{
				inventory.Remove(scrapItem);
				scrapItem.RemoveFromContainer();
				scrapItem.Remove();
			}
// …

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.