#include <engine.h>
#include <data_struct/queue.h>

#define MAX_ENTITIES 4096

Entity	entities[MAX_ENTITIES] = {0};

//lock queue when used
queue_t			spawn_queue;
pthread_mutex_t	qmtx;

int	EntityUpdate(void) {
	
}

void EntityManager(void) {
	bool close_signal = false;
	while(!close_signal) {
		//update all entity data
		//spawn newentity from queue
		//advance timed entity tick
		//despawn dead or timed entity
	}
	return;
}

void	EntitySpawn(Entity entity) {
	while (pthread_mutex_trylock(&qmtx) != 0) {
		usleep(20);
	}
	queue_push(&spawn_queue, &entity);
	pthread_mutex_unlock(&qmtx);
}
