#pragma once

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

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

typedef struct ComponentPhysics
{
	ECSComponent component;
	f32 friction;
	f32 velocityMax;
	vec2 size;
	vec3 velocity;
	vec3 position;
	f32 angle;
	Vector collisions;
	bool isSolid;
} ComponentPhysics;

void component_physics_init
(
	ComponentPhysics* self, 
	vec2 size,
	vec3 position,
	f32 velocityMax,
	f32 friction,
	bool isSolid
);

void component_physics_rectangle_get(ComponentPhysics* self, Rectangle* rectangle);
void component_physics_add(ComponentPhysics* self, ECS* ecs);
void component_physics_delete(ComponentPhysics* self, ECS* ecs);
void component_physics_tick(ComponentPhysics* self, ECS* ecs);

static const ECSComponentInfo COMPONENT_PHYSICS_INFO = 
{
	.system = 
	{
		.functions = 
		{ 
			(ECSFunction)component_physics_add,
			(ECSFunction)component_physics_delete, 
			(ECSFunction)component_physics_tick,
			NULL
		}
	},
	.type = ECS_COMPONENT_PHYSICS,
	.size = sizeof(ComponentPhysics)
};


