Source file unity-csharp/arcade-classics/space-invaders/IHittable.cs from the GDnD code examples. Download raw file

// GDnD wiki example
// Demonstrates: a tiny interface so a projectile can damage anything hittable without knowing its type
// Related pages: [[overview-arcade-classics-as-learning-projects]], [[csharp-interfaces]]
 
// Implemented by the player ship and by invaders. The projectile calls Hit()
// on whatever it overlaps, so it never needs to know what it struck — this is the
// IDamageable pattern in miniature.
public interface IHittable
{
    void Hit();
}