OnLootSpawn
OxideResourceobject OnLootSpawn(LootContainer lootContainer)
object OnLootSpawn(LootFill lootFill)Works — the game method in this build is the one the hook was written for.
Parameters
- lootContainer
- LootContainer
Return value
objectReturn a value of the method's result type and the game returns it immediately; null continues as usual.
Example
object — you can affect the game: return a value to change or cancel the action.
private object OnLootSpawn(LootContainer lootContainer)
{
Puts("OnLootSpawn");
// change nothing — the game continues as usual
return null;
// to affect the game:
// return null; // null — the game continues as usual
}Works in both Oxide and Carbon: Carbon loads Oxide plugins as is.
Injection point 1
Rust.opj (Oxide)
void LootContainer.SpawnLoot()
Passes: LootContainer lootContainer
WorksReturnBehavior: ExitWhenValidTypeArgumentBehavior: JustThisAssembly-CSharp.dll
Where it is called (this branch's game code)
// …
}
if (inventory == null)
{
Debug.Log("CONTACT DEVELOPERS! LootContainer::PopulateLoot has null inventory!!!");
return;
}
inventory.Clear();
ItemManager.DoRemoves();
if (Interface.CallHook("OnLootSpawn", this) != null)
{
return;
}
PopulateLoot();
CancelLootRefreshCountdown();
if (shouldRefreshContents)
{
StartLootRefreshCountdown();
// …Injection point 2
Rust.opj (Oxide)
void LootFill.DelayFill()
Passes: LootFill lootFill
WorksReturnBehavior: ExitWhenValidTypeArgumentBehavior: JustThisAssembly-CSharp.dll
Where it is called (this branch's game code)
private void DelayFill()
{
if (!(StorageContainer == null))
{
if (Interface.CallHook("OnLootSpawn", this) != null)
{
return;
}
LootContainer.FillLoot(StorageContainer.inventory, LootDefinition, MaxDefinitionsToSpawn, LootSpawnSlots);
}
}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.