#ifndef FIGHT_ENEMY_H
#define FIGHT_ENEMY_H

#include "mirror.h"
#include "transform.h"
#include "state_machine.h"
#include "rigidbody.h"
#include "physics_entity.h"
#include "behaviour_entity.h"
#include "collider.h"
#include "sprite.h"
#include "animation_sprite.h"

#include "Damagable.h"
#include "EnemyStates.h"
#include "typeclass_helpers.h"

typedef struct Enemy {
    Transform transform;
    
    StateMachine* behaviour;
    
    RigidBody* rigidbody;
    Collider* collider;
    Collider* hitbox;

    Sprite* sprite;
    
    int facing;

    float stun_time;
    
    AnimationSprite* idleAnim;
    AnimationSprite* walkAnim;
    AnimationSprite* hurtAnim;
    
    AnimationSprite* currentAnimation;

    int health;
} Enemy;

extern Enemy* MakeEnemy();
extern Enemy* SpawnEnemy(Vector location, const State* entryState);

extern void EnemyStart(Enemy* self);
extern void EnemyUpdate(Enemy* self, float deltaTime);
extern void EnemyDestroy(Enemy* self);

extern void EnemyDraw(Enemy* self);

extern void EnemyOnCollision(Enemy* self, Collision collision);
extern void EnemyOnOverlap(Enemy* self, Collider* other);

extern Transform* EnemyGetTransform(Enemy* self);
extern RigidBody* EnemyGetRigidBody(Enemy* self);
static long EnemyGetDepth(Enemy* self) { return (long)(-self->transform.position.y * 1000); }

extern int EnemyDamage(Enemy* self, DamageEventData* data);

DECL_REFLECT(Enemy)

decl_typeclass_impl(Transformable, Enemy)
decl_typeclass_impl(Drop, Enemy)
decl_typeclass_impl(BehaviourEntity, Enemy)
decl_typeclass_impl(PhysicsEntity, Enemy)
decl_typeclass_impl(Damagable, Enemy)

#endif // !FIGHT_ENEMY_H
