#ifndef LEVEL_H
#define LEVEL_H

#include <vector>

class GameObject;

class Level
{
public:
	static bool IsLevelExist(const char* levelname);

public:
	Level();
	~Level();

	void Load(const char* levelname);
	void LoadText(const char* filename);

	GameObject* CreateEntity();
	GameObject* CreateEntityByRC(const RuntimeClass* _pRuntimeClass);
	GameObject* CreateEntityByClassName(const char* classname);
	void AddEntity(GameObject* entity);
	void DestroyEntity(GameObject* entity);

	void Update(float fDeltaTime);
	void Render();

	GameObject*					GetObjectByTag(const String& tag);

	std::vector<GameObject*>&	GetEntities() { return m_entities; }
	//PhysicsWorld*				GetPhysicsWorld();
	const char*					GetLevelName();

private:
	void						DestroyEntities();
	bool						FindEntityToDestroy(GameObject* O);

private:
	bool							m_busy;
	bool							m_needToDestroyEnt;
	std::vector<GameObject*>		m_entities;
	std::vector<GameObject*>		m_entitiesToDestroy;
	//PhysicsWorld*			m_physics_world;
	const char*						m_level_name;
};

extern Level* g_level;

#endif // !LEVEL_H
