IKillable - jimdroberts/FishMMO GitHub Wiki

Description

Interface for entities that can be killed by a character or other source. Implement this to allow objects to be killed and trigger death logic.


API Access

Methods

  • void Kill(ICharacter killer)

    Kills the entity, triggering death logic and effects. killer (ICharacter): The character responsible for the kill.


Basic Usage

Setup

  1. Implement IKillable on your entity or object class.
  2. Provide logic in the Kill method to handle death, cleanup, and effects.
  3. Use the interface to allow characters or other sources to kill the entity.

Example

// Example 1: Implementing IKillable
public class Enemy : MonoBehaviour, IKillable {
    public void Kill(ICharacter killer) {
        // Death logic here
    }
}

// Example 2: Killing an entity in gameplay
IKillable target = enemy.GetComponent<IKillable>();
target.Kill(player);

Best Practices

  • Always implement the Kill method to handle all relevant death logic for your entity.
  • Use IKillable for all objects that should be affected by lethal effects or attacks.
  • Trigger cleanup, animations, and effects in the Kill method as needed.
⚠️ **GitHub.com Fallback** ⚠️