7 #include <rtti/object.h>
8 #include <rtti/objectptr.h>
9 #include <utility/dllexport.h>
10 #include <nap/resource.h>
25 struct EntityCreationParameters;
27 template<
class TargetComponentType>
30 template<
class ComponentType>
56 mEntityInstance(&entity),
64 virtual void update(
double deltaTime) { }
81 T* getComponent()
const;
91 template<
typename TargetComponentType,
typename SourceComponentType>
94 template<
typename SourceComponentType>
99 friend class SceneInstantiation;
108 void addToComponentLinkMap(
Component* targetResource,
const std::string& instancePath,
ComponentInstance** targetInstancePtr);
117 void addToEntityLinkMap(
Entity* targetResource,
const std::string& instancePath,
EntityInstance** targetInstancePtr);
123 template<
class INSTANCETYPE>
124 struct TargetInstanceLink
126 INSTANCETYPE** mTargetPtr;
127 std::string mInstancePath;
130 using TargetComponentLink = TargetInstanceLink<ComponentInstance>;
131 using TargetEntityLink = TargetInstanceLink<EntityInstance>;
133 using ComponentLinkMap = std::unordered_map<Component*, std::vector<TargetComponentLink>>;
134 using EntityLinkMap = std::unordered_map<Entity*, std::vector<TargetEntityLink>>;
136 ComponentLinkMap mComponentLinkMap;
137 EntityLinkMap mEntityLinkMap;
178 const std::string& getOriginalID()
const;
182 friend class SceneInstantiation;
191 T* comp = rtti_cast<T>(mResource);
192 assert(comp !=
nullptr);
197 #define DECLARE_COMPONENT(ComponentType, ComponentInstanceType) \
199 using InstanceType = ComponentInstanceType; \
200 virtual const rtti::TypeInfo getInstanceType() const override \
202 return nap::rtti::TypeInfo::get<InstanceType>(); \