static bool Prefix(LiveMixin __instance, ref bool __result) { if ((Object)__instance.gameObject.GetComponent <Player>() == (Object)null) { // Not the player taking damage, execute the function normally return(true); } // Check if OHKO flag is active if (OneHitKnockout.active) { // Reuse the kill logic from the LiveMixin, to ensure that cutscenes are handled properly. __result = true; if (!__instance.IsCinematicActive()) { __instance.Kill(); } else { __instance.cinematicModeActive = true; __instance.SyncUpdatingState(); } return(false); } return(true); }
static void KillFish(LiveMixin liveMixin) { //ErrorMessage.AddDebug("Kill " + liveMixin.gameObject.name); //Main.Log("Kill " + liveMixin.gameObject.name); liveMixin.health = 0f; liveMixin.tempDamage = 0f; liveMixin.SyncUpdatingState(); if (liveMixin.deathClip) { Utils.PlayEnvSound(liveMixin.deathClip, liveMixin.transform.position, 25f); } //if (this.deathEffect != null) // Utils.InstantiateWrap(this.deathEffect, this.transform.position, Quaternion.identity); if (liveMixin.passDamageDataOnDeath) { liveMixin.gameObject.BroadcastMessage("OnKill", DamageType.Normal, SendMessageOptions.DontRequireReceiver); } else if (liveMixin.broadcastKillOnDeath) { liveMixin.gameObject.BroadcastMessage("OnKill", SendMessageOptions.DontRequireReceiver); } CreatureDeath creatureDeath = liveMixin.GetComponent <CreatureDeath>(); Eatable eatable = liveMixin.GetComponent <Eatable>(); eatable.SetDecomposes(true); Rigidbody rb = liveMixin.GetComponent <Rigidbody>(); if (rb) { rb.isKinematic = false; rb.constraints = RigidbodyConstraints.None; WorldForces worldForces = liveMixin.GetComponent <WorldForces>(); if (worldForces) { worldForces.handleDrag = false; } rb.drag = Mathf.Max(rb.drag, 1f); rb.angularDrag = Mathf.Max(rb.angularDrag, 1f); } liveMixin.gameObject.EnsureComponent <EcoTarget>().SetTargetType(EcoTargetType.DeadMeat); if (creatureDeath) { if (creatureDeath.respawn && !creatureDeath.respawnOnlyIfKilledByCreature) { creatureDeath.SpawnRespawner(); } if (creatureDeath.removeCorpseAfterSeconds >= 0.0) { creatureDeath.Invoke("RemoveCorpse", creatureDeath.removeCorpseAfterSeconds); } creatureDeath.SyncFixedUpdatingState(); } }
static void KillFish(LiveMixin liveMixin) { //AddDebug("KillFish " + liveMixin.gameObject.name); //Main.Log("Kill " + liveMixin.gameObject.name); liveMixin.health = 0f; liveMixin.tempDamage = 0f; liveMixin.SyncUpdatingState(); //if (liveMixin.deathClip) // liveMixin.deathClip.Play(); //if (liveMixin.deathSound) // Utils.PlayFMODAsset(liveMixin.deathSound, liveMixin.transform); //if (liveMixin.passDamageDataOnDeath) // liveMixin.gameObject.BroadcastMessage("OnKill", DamageType.Normal, SendMessageOptions.DontRequireReceiver); //else if (liveMixin.broadcastKillOnDeath) // liveMixin.gameObject.BroadcastMessage("OnKill", SendMessageOptions.DontRequireReceiver); //if (liveMixin.sendKillOnDeath) //{ // if (liveMixin.passDamageDataOnDeath) // liveMixin.gameObject.SendMessage("OnKill", DamageType.Normal, SendMessageOptions.DontRequireReceiver); // else // liveMixin.gameObject.SendMessage("OnKill", SendMessageOptions.DontRequireReceiver); //} AquariumFish af = liveMixin.GetComponent <AquariumFish>(); if (af) { UnityEngine.Object.Destroy(af); } Locomotion locomotion = liveMixin.GetComponent <Locomotion>(); locomotion.enabled = false; CreatureDeath creatureDeath = liveMixin.GetComponent <CreatureDeath>(); Eatable eatable = liveMixin.GetComponent <Eatable>(); eatable.SetDecomposes(true); Rigidbody rb = liveMixin.GetComponent <Rigidbody>(); if (rb) { rb.isKinematic = false; rb.constraints = RigidbodyConstraints.None; WorldForces worldForces = liveMixin.GetComponent <WorldForces>(); if (worldForces) { worldForces.handleDrag = false; } rb.drag = Mathf.Max(rb.drag, 1f); rb.angularDrag = Mathf.Max(rb.angularDrag, 1f); } liveMixin.gameObject.EnsureComponent <EcoTarget>().SetTargetType(EcoTargetType.DeadMeat); if (creatureDeath) { if (creatureDeath.respawn && !creatureDeath.respawnOnlyIfKilledByCreature) { creatureDeath.SpawnRespawner(); } if (creatureDeath.removeCorpseAfterSeconds >= 0.0) { creatureDeath.Invoke("RemoveCorpse", creatureDeath.removeCorpseAfterSeconds); } creatureDeath.SyncFixedUpdatingState(); } Pickupable pickupable = liveMixin.GetComponent <Pickupable>(); ItemsContainer container = pickupable.inventoryItem.container as ItemsContainer; if (container != null) { // fix offset decay bar container.RemoveItem(pickupable, true); container.AddItem(pickupable); } }