#pragma once

#include <Critical.h>
#include <Either.h>
#include <Model3D.h>

#include "Area.h"
#include "EntityType.h"
#include "FactoryCraftModel.h"

class Block;

struct MovementFrame
{
    Framework::Vec3<float> position;
    float rotation;
    float duration;
};

class Entity : public FactoryCraftModel
{
private:
    int id;
    const EntityType* zType;
    bool playerControlled;
    Framework::ReadWriteLock framesLock;
    MovementFrame currentFrame;
    Framework::Array<MovementFrame> frames;
    double frameLength;

public:
    Entity(const EntityType* zType,
        Framework::Model3DData* model,
        Framework::Model3DTexture* texture,
        int id,
        Framework::Vec3<float> position,
        float size);
    ~Entity();

    void api(char* message);
    bool tick(double time) override;

    int getId() const;
    const EntityType* zEntityType() const;
    void setPlayerControlled();
};