Stupid circular dependency fixed.
This commit is contained in:
@@ -1,10 +1,8 @@
|
||||
#ifndef Component_h__
|
||||
#define Component_h__
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "Entity.h"
|
||||
#include "ComponentFactory.h"
|
||||
#include "Entity.h"
|
||||
|
||||
struct Component
|
||||
{
|
||||
|
||||
@@ -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()); });
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -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__
|
||||
|
||||
@@ -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__
|
||||
Reference in New Issue
Block a user