RustTip

OnTechTreeNodeUnlock

OxideCarbonTechTree

Called when a tech tree node is unlocked.

object OnTechTreeNodeUnlock(Workbench workbench, TechTreeData.NodeInstance local5, BasePlayer local0)
Works — the game method in this build is the one the hook was written for.

Parameters

workbench
Workbench
local5
TechTreeData.NodeInstance
local0
BasePlayer

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 OnTechTreeNodeUnlock(Workbench workbench, TechTreeData.NodeInstance local5, BasePlayer local0)
{
    Puts("OnTechTreeNodeUnlock");

    // 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 Workbench.RPC_TechTreeUnlock(BaseEntity.RPCMessage)

Passes: Workbench workbench, TechTreeData.NodeInstance local5, BasePlayer local0

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

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

// …
	return;
}
TechTreeData.NodeInstance byID = techTreeForLevel.GetByID(id);
if (byID == null)
{
	Debug.Log("Node for unlock not found :" + id);
	return;
}
if (Interface.CallHook("OnTechTreeNodeUnlock", this, byID, player) != null)
{
	return;
}
int itemid = ItemManager.FindItemDefinition("scrap").itemid;
int amount = player.inventory.GetAmount(itemid);
if (flag)
{
	if (byID.itemDef == null || player.blueprints.HasUnlocked(byID.itemDef))
// …

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.