#ifndef ENEMY_HPP
#define ENEMY_HPP

#include "godot_cpp/classes/area3d.hpp"
#include "health.hpp"
#include <godot_cpp/classes/character_body3d.hpp>

namespace godot {
class CharacterActor;
class NavigationAgent3D;

class Enemy : public CharacterBody3D,
              public IHealthEntity {
    GDCLASS(Enemy, CharacterBody3D);
    static void _bind_methods();
public:
    virtual void _ready() override;
    virtual void _process(double delta_time) override;
    void process_navigation(double delta_time);

    void body_entered_vision_area(Node3D *body);

    void update_navigation_target();

    void on_damage(int delta, int health_left);
    void on_death(int damage);

    virtual Health *get_health() override;
    virtual Health const *get_health() const override;

private:
    float renav_time{0.f};

    CharacterActor *target_player{nullptr};
    Health *health{nullptr};
    NavigationAgent3D *nav_agent{nullptr};
    Area3D *vision_area{nullptr};

    static float const RENAV_INTERVAL;
};
}

#endif // !ENEMY_HPP
