OnWorldProjectileCreate
OxideCarbonWeaponCalled when a world projectile is created.
object OnWorldProjectileCreate(HitInfo info, Item local1)Works — the game method in this build is the one the hook was written for.
Parameters
- info
- HitInfo
- local1
- Item
Return value
objectReturn non-null to cancel the game action.
Example
object — you can affect the game: return a value to change or cancel the action.
private object OnWorldProjectileCreate(HitInfo info, Item local1)
{
Puts("OnWorldProjectileCreate");
// change nothing — the game continues as usual
return null;
// to affect the game:
// return false; // non-null cancels the game action
}Works in both Oxide and Carbon: Carbon loads Oxide plugins as is.
Injection point
Rust.opj (Oxide)
void BasePlayer.CreateWorldProjectile(HitInfo, ItemDefinition, ItemModProjectile, Projectile, Item)
Passes: HitInfo info, Item local1
WorksReturnBehavior: ExitWhenValidTypeArgumentBehavior: UseArgumentString (a0, l1)Assembly-CSharp.dll
Where it is called (this branch's game code)
protected virtual void CreateWorldProjectile(HitInfo info, ItemDefinition itemDef, ItemModProjectile itemMod, Projectile projectilePrefab, Item recycleItem)
{
Vector3 projectileVelocity = info.ProjectileVelocity;
Item item = ((recycleItem != null) ? recycleItem : ItemManager.Create(itemDef, 1, 0uL, isServerSide: true, 0uL));
BaseEntity baseEntity = null;
if (!info.DidHit)
{
if (Interface.CallHook("OnWorldProjectileCreate", info, item) != null)
{
return;
}
baseEntity = item.CreateWorldObject(info.HitPositionWorld, Quaternion.LookRotation(projectileVelocity.normalized));
baseEntity.Kill(DestroyMode.Gib);
return;
}
if (projectilePrefab.breakProbability > 0f && Random.value <= projectilePrefab.breakProbability)
// …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.