OnIngredientsCollect
OxideCarbonCraftingCalled when ingredients collect occurs.
object OnIngredientsCollect(ItemCrafter itemCrafter, ItemBlueprint bp, ItemCraftTask task, int amount, BasePlayer player, bool takeBroken)Works — the game method in this build is the one the hook was written for.
Parameters
- itemCrafter
- ItemCrafter
- bp
- ItemBlueprint
- task
- ItemCraftTask
- amount
- int
- player
- BasePlayer
- takeBroken
- bool
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 OnIngredientsCollect(ItemCrafter itemCrafter, ItemBlueprint bp, ItemCraftTask task, int amount, BasePlayer player, bool takeBroken)
{
Puts("OnIngredientsCollect");
// 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 ItemCrafter.CollectIngredients(ItemBlueprint, ItemCraftTask, int, BasePlayer, bool)
Passes: ItemCrafter itemCrafter, ItemBlueprint bp, ItemCraftTask task, int amount, BasePlayer player, bool takeBroken
WorksReturnBehavior: ExitWhenValidTypeArgumentBehavior: AllAssembly-CSharp.dll
Where it is called (this branch's game code)
private void CollectIngredients(ItemBlueprint bp, ItemCraftTask task, int amount = 1, BasePlayer player = null, bool takeBroken = true)
{
if (Interface.CallHook("OnIngredientsCollect", this, bp, task, amount, player, takeBroken) != null)
{
return;
}
List<Item> list = new List<Item>();
foreach (ItemAmount ingredient in bp.GetIngredients())
{
CollectIngredient(ingredient.itemid, (int)ingredient.amount * amount, list, takeBroken);
}
// …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.