RustTip

OnWorldPrefabSpawned

OxideCarbonWorld

Called when a world prefab is spawned.

void OnWorldPrefabSpawned(GameObject local0, string category)
Works — the game method in this build is the one the hook was written for.

Parameters

local0
GameObject
category
string

Return value

voidThe return value is ignored — the hook only notifies.

Example

private void OnWorldPrefabSpawned(GameObject local0, string category)
{
    Puts("OnWorldPrefabSpawned");
}

Works in both Oxide and Carbon: Carbon loads Oxide plugins as is.

Injection point

Rust.opj (Oxide)
void World.SpawnPrefab(string, Prefab, Vector3, Quaternion, Vector3)

Passes: GameObject local0, string category

WorksReturnBehavior: ContinueArgumentBehavior: UseArgumentString (l0, a0)Assembly-CSharp.dll

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

// …
spawnTimer.Restart();
if (!Cached)
{
	prefab.ApplyTerrainPlacements(position, rotation, scale);
	prefab.ApplyTerrainModifiers(position, rotation, scale);
}
GameObject instance = prefab.Spawn(position, rotation, scale);
TrackSpawnedPrefab(category, instance);
Interface.CallHook("OnWorldPrefabSpawned", instance, category);
spawnTimer.Stop();
spawnTimings.Add(new SpawnTiming
{
	category = category,
	prefab = prefab,
	position = position,
	rotation = rotation,
	scale = scale,
// …

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.