#include "../utils.h"
#include "../factory_objects.h"
#include "../resources.h"
#include "../level.h"

typedef struct actor_back_s
{
    object_t *self_object;
    vector_t  position;
    int       width;
    int       height;
} actor_back_t;

static void _Actor_Back_GetInfo(actor_back_t *actor, object_info_t *info)
{
    if (actor == NULL)
        return;

    if (info == NULL)
        return;

    info->box_rect          = Utils_GetRect(0, 0, actor->width, actor->height);
    info->collision_rect    = Utils_GetRect(0, 0, actor->width, actor->height);
    info->collision_cell_ul = Utils_GetPoint(0, 0);
    info->collision_cell_br = Utils_GetPoint(0, 0);
    info->position          = actor->position;
}

static void _Actor_Back_Draw(SDL_Renderer *renderer, actor_back_t *actor)
{
    if (actor == NULL)
        return;

    Level_DrawBack(renderer);
}

static void _Actor_Back_Free(actor_back_t *actor)
{
    if (actor == NULL)
        return;

    free(actor);

    actor = NULL;
}

void Actor_Back_Create(object_t *object, int width, int height)
{
    if (object != NULL)
    {
        actor_back_t *actor = (actor_back_t*)malloc(sizeof(actor_back_t));

        actor->self_object = object;

        FactoryObjects_SetActor(object, (void*)actor, AT_BACK, OLAY_BACK);

        FactoryObjects_SetFunc(object, _Actor_Back_GetInfo, OFUNC_GETINFO);
        FactoryObjects_SetFunc(object, _Actor_Back_Draw,    OFUNC_DRAW);
        FactoryObjects_SetFunc(object, _Actor_Back_Free,    OFUNC_FREE);

        actor->position = Utils_GetVector(0, 0);
        actor->width  = width;
        actor->height = height;
    }
}
