#pragma once

#include "../../GAME_COMMON.h"
#include "../../render/texture_quad.h"
#include "../ecs_entity.h"

#include "../../../engine/rectangle.h"

#define COMPONENT_SPRITE_COLOR (f32*)COLOR_OPAQUE

static const vec2 COMPONENT_SPRITE_SCALE = {1.0f, 1.0f};
static const vec3 COMPONENT_SPRITE_ROTATION_AXIS = {0.0f, 0.0f, 1.0f};

typedef struct ComponentSprite
{
	ECSComponent component;
	vec3 position;
	vec4 color;
	vec2 scale;
	vec3 offset;
	Atlas atlas;
	vec2 size;
	f32 rotation;
} ComponentSprite;

void component_sprite_rectangle_get(ComponentSprite* self, Rectangle* rectangle);

void component_sprite_atlas_init
(
	ComponentSprite* self, 
	Texture texture, 
	ivec2 frameSize,
	ivec2 atlasSize,
	vec2 size, 
	vec3 position
);

void
component_sprite_init
(
	ComponentSprite* self, 
	Texture texture, 
	vec2 size, 
	vec3 position
);

void component_sprite_size_get(ComponentSprite* self, vec2 size);
void component_sprite_add(ComponentSprite* self, ECS* ecs);
void component_sprite_draw(ComponentSprite* self, ECS* ecs);

static const ECSComponentInfo COMPONENT_SPRITE_INFO = 
{
	.system = 
	{
		.functions = 
		{ 
			(ECSFunction)component_sprite_add, 
			NULL, 
			NULL,
			(ECSFunction)component_sprite_draw
		}
	},
	.type = ECS_COMPONENT_SPRITE,
	.size = sizeof(ComponentSprite)
};


