#ifndef _fencer_sprite_entity_h
#define _fencer_sprite_entity_h

#include "typeclass_helpers.h"
#include "sprite.h"

typedef struct {
    Sprite* (*const get_sprite)(void*);
} ISpriteEntity;

typedef struct {
    void* data;
    ISpriteEntity const* tc;
    ITransformable const* transformable;
} SpriteEntity;

extern void sprite_entity_draw(SpriteEntity self);

#define impl_SpriteEntity_for(T, get_sprite_f)\
static inline SpriteEntity T##_as_SpriteEntity(T* x) {\
    TC_FN_TYPECHECK(Sprite*, get_sprite_f, T*);\
    static ISpriteEntity const tc = {\
        .get_sprite = (Sprite*(*const)(void*)) get_sprite_f,\
    };\
    Transformable t = T##_as_Transformable(x);\
    return (SpriteEntity){.tc = &tc, .transformable = t.tc, .data = x};\
}

#endif // !_fencer_sprite_entity_h
