#ifndef FIGHT_DAMAGABLE_H
#define FIGHT_DAMAGABLE_H

#include "typeclass_helpers.h"

#include "vmath.h"

typedef struct DamageEventData {
    int damageAmount;
    int knockdown;
    float stun;
    float knockback;
    Vector origin;
} DamageEventData;

typedef struct {
    int (*const damage)(void*, DamageEventData*);
} IDamagable;

typedef struct {
    void* data;
    IDamagable const* tc;
} Damagable;

#define impl_Damagable_for(T, damage_f)\
Damagable T##_as_Damagable(T* x) {\
    TC_FN_TYPECHECK(int, damage_f, T*, DamageEventData*);\
    static const IDamagable tc = {\
        .damage = (int(*const)(void*, DamageEventData*)) damage_f,\
    };\
    return (Damagable){.data = x, .tc = &tc};\
}

#endif // !FIGHT_DAMAGABLE_H
