RustTip

OnTerrainCreate

OxideCarbonWorld

Called when a terrAIn is created.

void OnTerrainCreate(TerrainGenerator terrainGenerator)
Works — the game method in this build is the one the hook was written for.

Parameters

terrainGenerator
TerrainGenerator

Return value

voidThe return value is ignored — the hook only notifies.

Example

private void OnTerrainCreate(TerrainGenerator terrainGenerator)
{
    Puts("OnTerrainCreate");
}

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

Injection point

Rust.opj (Oxide)
void TerrainGenerator.CreateTerrain(int, int)

Passes: TerrainGenerator terrainGenerator

WorksReturnBehavior: ContinueArgumentBehavior: JustThisAssembly-CSharp.dll

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

public GameObject CreateTerrain(int heightmapResolution, int alphamapResolution)
{
	Interface.CallHook("OnTerrainCreate", this);
	TerrainData terrainData = new TerrainData();
	terrainData.baseMapResolution = GetBaseMapRes();
	terrainData.heightmapResolution = heightmapResolution;
	terrainData.alphamapResolution = alphamapResolution;
	terrainData.size = new Vector3(World.Size, 1000f, World.Size);
	Terrain terrain = null;
	GeometryClipmapTerrain geometryClipmapTerrain = null;
	terrain = Terrain.CreateTerrainGameObject(terrainData).GetComponent<Terrain>();
// …

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.