Stupid circular dependency fixed.

This commit is contained in:
2014-02-25 20:09:15 +01:00
parent 369ff782f1
commit 63337cf660
4 changed files with 17 additions and 8 deletions
+1 -3
View File
@@ -1,10 +1,8 @@
#ifndef Component_h__
#define Component_h__
#include <memory>
#include "Entity.h"
#include "ComponentFactory.h"
#include "Entity.h"
struct Component
{
+3 -2
View File
@@ -2,10 +2,11 @@
#define ComponentFactory_h__
#include <string>
#include <memory>
#include <functional>
#include <map>
#include "Component.h"
struct Component;
#define REGISTER_COMPONENT(NAME, TYPE) \
static ComponentRegistrar<TYPE> registrar(NAME);
@@ -16,7 +17,7 @@ class ComponentRegistrar
public:
ComponentRegistrar(std::string name)
{
ComponentFactory::Instance()->Register(name, [](void) -> std::shared_ptr<Component> { return new T() });
ComponentFactory::Instance()->Register(name, [](void) -> std::shared_ptr<Component> { return std::shared_ptr<Component>(new T()); });
}
};
+5 -1
View File
@@ -1,13 +1,17 @@
#ifndef Transform_h__
#define Transform_h__
#include "Component.h"
namespace Components
{
REGISTER_COMPONENT("Transform", Transform);
struct Transform : Component
{
float Position[3];
};
REGISTER_COMPONENT("Transform", Transform);
}
#endif // Transform_h__
+8 -2
View File
@@ -1,3 +1,6 @@
#ifndef World_h__
#define World_h__
#include <stack>
#include <unordered_map>
#include <vector>
@@ -5,7 +8,8 @@
#include "Entity.h"
#include "Component.h"
#include "Components/Transform.h"
#include "ComponentFactory.h"
//#include "Components/Transform.h"
class World
{
@@ -78,4 +82,6 @@ private:
{
m_RecycledEntityIDs.push(id);
}
};
};
#endif // World_h__