OnLootSpawn
OxideResourceobject OnLootSpawn(LootContainer lootContainer)
object OnLootSpawn(LootFill lootFill)Method changed — check — the game method differs from the one the hook is recorded for in Oxide. The hook is still called, but its place may have shifted — worth checking after an update.
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
Method changed — checkReturnBehavior: 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;
}
int num = ((!scaleLootWithGatherRate) ? 1 : BaseGameMode.ScaleGatherAmount(1));
for (int i = 0; i < num; i++)
{
PopulateLoot();
}
// …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.