RustTip

OnEntityDeath

OxideEntity
void OnEntityDeath(ResourceEntity resourceEntity, HitInfo info)
void OnEntityDeath(BaseCombatEntity baseCombatEntity, HitInfo info)
Works — the game method in this build is the one the hook was written for.

Parameters

resourceEntity
ResourceEntity
info
HitInfo

Return value

voidThe return value is ignored — the hook only notifies.

Example

private void OnEntityDeath(ResourceEntity resourceEntity, HitInfo info)
{
    Puts("OnEntityDeath");
}

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

Injection point 1

Rust.opj (Oxide)
void ResourceEntity.OnDied(HitInfo)

Passes: ResourceEntity resourceEntity, HitInfo info

WorksReturnBehavior: ContinueArgumentBehavior: AllAssembly-CSharp.dll

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

public virtual void OnDied(HitInfo info)
{
	isKilled = true;
	Interface.CallHook("OnEntityDeath", this, info);
	Kill();
}

Injection point 2

Rust.opj (Oxide)
void BaseCombatEntity.Die(HitInfo)

Passes: BaseCombatEntity baseCombatEntity, HitInfo info

WorksReturnBehavior: ContinueArgumentBehavior: AllAssembly-CSharp.dll

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

// …
{
	if (IsDead())
	{
		return;
	}
	LogEntry(RustLog.EntryType.Combat, 2, "died");
	health = 0f;
	lifestate = LifeState.Dead;
	Interface.CallHook("OnEntityDeath", this, info);
	if (info != null && info.InitiatorPlayer != null && !info.InitiatorPlayer.IsNpc && info.InitiatorPlayer != this)
	{
		BaseMission.MissionEventPayload payload = new BaseMission.MissionEventPayload
		{
			NetworkIdentifier = info.InitiatorPlayer.net.ID,
			UintIdentifier = prefabID,
			IntIdentifier = 1,
			WorldPosition = transform.position
// …

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.