#include "play.h"

static void _play_entity_init(Play* self);

/* Initializes entities for the play state. */
static void
_play_entity_init(Play* self)
{
	self->player = ecs_entity_add(&self->state->game->ecs);
	self->elemental = ecs_entity_add(&self->state->game->ecs);
	self->spawner = ecs_entity_add(&self->state->game->ecs);
	self->cursor = ecs_entity_add(&self->state->game->ecs);
	self->goodieDisplay = ecs_entity_add(&self->state->game->ecs);
	self->timerDisplay = ecs_entity_add(&self->state->game->ecs);
	self->waveDisplay = ecs_entity_add(&self->state->game->ecs);
	self->waveTimerDisplay = ecs_entity_add(&self->state->game->ecs);
	self->heartDisplay = ecs_entity_add(&self->state->game->ecs);

	entity_spawner_init
	(
		&self->state->game->ecs, 
		self->spawner,
		self->player
	);

	entity_player_init
	(
		&self->state->game->ecs, 
		self->player, 
		(f32*)PLAY_PLAYER_POSITION,
		self->spawner
	);

	entity_cursor_init
	(
		&self->state->game->ecs,
		self->cursor
	);

	entity_goodie_display_init
	(
		&self->state->game->ecs,
		self->goodieDisplay,
		self->player
	);

	entity_heart_display_init
	(
		&self->state->game->ecs,
		self->heartDisplay,
		self->player
	);

	entity_timer_display_init
	(
		&self->state->game->ecs,
		self->timerDisplay
	);


	entity_wave_display_init
	(
		&self->state->game->ecs,
		self->waveDisplay,
		self->spawner
	);
	
	entity_combat_timer_display_init
	(
		&self->state->game->ecs,
		self->combatTimerDisplay,
		self->spawner
	);

	entity_wave_timer_display_init
	(
		&self->state->game->ecs,
		self->waveTimerDisplay,
		self->spawner
	);

	entity_elemental_init
	(
		&self->state->game->ecs, 
		self->elemental, 
		(f32*)PLAY_ELEMENTAL_POSITION,
		self->spawner,
		self->player
	);
}

/* Initializes play state. */
void
play_init(Play* self, State* state)
{
	memset(self, '\0', sizeof(Play));

	self->state = state;
	
	_play_entity_init(self);
}
