#pragma once

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

#include "../../input/input.h"
#include "component_sprite.h"
#include "component_physics.h"

#include "../entity/play/entity_shadow.h"

#define COMPONENT_GAME_OBJECT_DEPTH_MAX 0.9f
#define COMPONENT_GAME_OBJECT_DEPTH_MIN 0.1f
#define COMPONENT_GAME_OBJECT_GRAVITY -1.0f
#define COMPONENT_GAME_OBJECT_BOUNCE_FRICTION 0.8f
#define COMPONENT_GAME_OBJECT_HEIGHT_MAX 2500.0f
#define COMPONENT_GAME_OBJECT_SHADOW_Z_OFFSET 0.01f

typedef struct ComponentGameObject
{
	ECSComponent component;
	u32 shadowID;
	f32 height;
	f32 heightVelocity;
	f32 gravity;
	bool isAffectedByGravity;
	bool isAirborne;
	bool isBounce;
} ComponentGameObject;

void
component_game_object_init
(
	ComponentGameObject* self,
	ECS* ecs,
	Texture texture,
	vec2 size,
	vec2 physicsSize,
	vec3 position,
	f32 friction,
	f32 velocityMax,
	bool isBounce,
	bool isAffectedByGravity,
	bool isSolid
);

void
component_game_object_atlas_init
(
	ComponentGameObject* self,
	ECS* ecs,
	Texture texture,
	ivec2 frameSize,
	ivec2 atlasSize,
	vec2 size,
	vec2 physicsSize,
	vec3 position,
	f32 friction,
	f32 velocityMax,
	bool isBounce,
	bool isAffectedByGravity,
	bool isSolid
);

void component_game_object_add(ComponentGameObject* self, ECS* ecs);
void component_game_object_delete(ComponentGameObject* self, ECS* ecs);
void component_game_object_tick(ComponentGameObject* self, ECS* ecs);


static const ECSComponentInfo COMPONENT_GAME_OBJECT_INFO = 
{
	.system = 
	{
		.functions = 
		{ 
			(ECSFunction)component_game_object_add,
			(ECSFunction)component_game_object_delete,
			(ECSFunction)component_game_object_tick, 
			NULL
		}
	},
	.type = ECS_COMPONENT_GAME_OBJECT,
	.size = sizeof(ComponentGameObject)
};


