OnCrateSpawned
OxideEntityvoid OnCrateSpawned(PatrolHelicopter patrolHelicopter, BaseEntity baseEntity)
void OnCrateSpawned(BradleyAPC bradleyAPC, BaseEntity baseEntity)Works — the game method in this build is the one the hook was written for.
Parameters
- patrolHelicopter
- PatrolHelicopter
- baseEntity
- BaseEntity
Return value
voidThe return value is ignored — the hook only notifies.
Example
private void OnCrateSpawned(PatrolHelicopter patrolHelicopter, BaseEntity baseEntity)
{
Puts("OnCrateSpawned");
}Works in both Oxide and Carbon: Carbon loads Oxide plugins as is.
Injection point 1
Rust.opj (Oxide)
void PatrolHelicopter.OnDied(HitInfo)
Passes: PatrolHelicopter patrolHelicopter, BaseEntity baseEntity
WorksReturnBehavior: ContinueArgumentBehavior: UseArgumentString (this, l14)Assembly-CSharp.dll
Where it is called (this branch's game code)
// …
baseEntity.Spawn();
baseEntity.SetVelocity(vector + onUnitSphere * Random.Range(minInclusive, maxInclusive));
foreach (ServerGib item in list)
{
Physics.IgnoreCollision(component, item.GetCollider(), ignore: true);
}
}
}
Interface.CallHook("OnCrateSpawned", this, baseEntity2);
for (int j = 0; j < maxCratesToSpawn; j++)
{
Vector3 onUnitSphere2 = Random.onUnitSphere;
Vector3 pos = transform.position + new Vector3(0f, 1.5f, 0f) + onUnitSphere2 * Random.Range(2f, 3f);
BaseEntity baseEntity2 = GameManager.server.CreateEntity(crateToDrop.resourcePath, pos, Quaternion.LookRotation(onUnitSphere2));
baseEntity2.enableSaving = true;
baseEntity2.Spawn();
Collider component2 = baseEntity2.GetComponent<Collider>();
// …Injection point 2
Rust.opj (Oxide)
void BradleyAPC.OnDied(HitInfo)
Passes: BradleyAPC bradleyAPC, BaseEntity baseEntity
WorksReturnBehavior: ContinueArgumentBehavior: UseArgumentString (this, l14)Assembly-CSharp.dll
Where it is called (this branch's game code)
// …
baseEntity.enableSaving = true;
baseEntity.Spawn();
baseEntity.SetVelocity(zero + onUnitSphere * Random.Range(minInclusive, maxInclusive));
foreach (ServerGib item in list)
{
Physics.IgnoreCollision(component, item.GetCollider(), ignore: true);
}
}
Interface.CallHook("OnCrateSpawned", this, baseEntity2);
for (int j = 0; j < maxCratesToSpawn; j++)
{
Vector3 onUnitSphere2 = Random.onUnitSphere;
onUnitSphere2.y = 0f;
onUnitSphere2.Normalize();
Vector3 pos = transform.position + new Vector3(0f, 1.5f, 0f) + onUnitSphere2 * Random.Range(2f, 3f);
BaseEntity baseEntity2 = GameManager.server.CreateEntity(crateToDrop.resourcePath, pos, Quaternion.LookRotation(onUnitSphere2));
baseEntity2.Spawn();
// …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.