#ifndef GAME_OBJECT_H
#define GAME_OBJECT_H

#include "utils/rtti.h"
#include "utils/maths.h"
#include "utils/string.h"

#include "physics/physics_object.h"

class Model;

enum GameObjectComponents
{
	GAME_OBJECT_COMPONENTS_NONE,
	GAME_OBJECT_COMPONENTS_VISUAL,
	GAME_OBJECT_COMPONENTS_PHYSICS,
	GAME_OBJECT_COMPONENTS_COLLIDER,
	GAME_OBJECT_COMPONENTS_TRIGGER,
	GAME_OBJECT_COMPONENTS_GHOST,
	GAME_OBJECT_COMPONENTS_SOUND,
	GAME_OBJECT_COMPONENTS_PARTICLESYSTEM,

	GAME_OBJECT_COMPONENTS_MAX,
};

class GameObject
{
	DECLARE_RTTI_ROOT(GameObject);
public:
	GameObject();
	~GameObject();

	bool IsKindOf(const RuntimeClass* _typeInfo) const;

	template <typename T>
	bool IsKindOf();

	static GameObject* _Construct();

	virtual void LoadModel(const char* filename);

	glm::mat4 GetModelMatrix();

	void GetTransformedBBox( BoundingBox* boundinBox );

	inline PhysicsObject* CreatePhysicsObject()
	{
		PhysicsObject* pPhysicsObject = new PhysicsObject();
		m_pPhysicsObject = pPhysicsObject;
		return pPhysicsObject;
	}

public:
	String m_tag;
	String m_name;

	Vec3 m_position;
	Vec3 m_rotation;
	Vec3 m_scale;

	BoundingBox m_boundingBox;

	Model* m_model;

	PhysicsObject* m_pPhysicsObject;

};

template<typename T>
inline bool GameObject::IsKindOf()
{
	return IsKindOf( RUNTIME_CLASS(T) );
}

#endif // !GAME_OBJECT_H
