52 static void entityFactorySet(std::shared_ptr<fsCEntityFactory> pEntityFactory);
64 template <
typename TComponent>
68 template <
typename TComponent>
74 template <
typename TInterface>
77 template <
typename TLamda>
79 template <
typename TLamda>
84 template <
typename TInterface>
86 template <
typename TInterface>
89 const std::vector<const std::type_info*>& pPossibleComponentTypes);
92 template <
typename TInterface>
116 void componentUpdateMethodExecute(
void (
fsIComponent::*pMethod)());
118 void deferredComponentsAdd();
119 void deferredComponentsRemove();
121 void componentUnregisterAndDestroy(
const fsCUniqueId& pTypeId);
123 void childEntitiesWithComponentsOfTypeGetDo(std::vector<fsCEntity*>& pVectorToFill,
124 const std::vector<const std::type_info*>& pPossibleComponentTypes);
125 void childEntitiesTaggedWithGetDo(std::vector<fsStr> pTags, std::vector<fsCEntity*>& pEnts);
127 std::map<fsU32, fsIComponent*> mComponentsMap;
128 std::vector<fsIComponent*> mComponentsVector;
130 std::vector<std::pair<fsIComponent*, fsU32>> mComponentsToAdd;
131 std::vector<fsCUniqueId> mComponentsToDestroy;
133 fsBool mInComponentUpdate;
135 static std::shared_ptr<fsCEntityFactory> mEntityFactory;
136 static std::shared_ptr<fsCComponentFactory> mComponentFactory;
140template <
typename TInterface>
143 for (
auto iter = mComponentsMap.begin(); iter != mComponentsMap.end(); ++iter)
145 if (
auto* result =
dynamic_cast<TInterface*
>(iter->second))
151 for (
auto iter = mComponentsToAdd.begin(); iter != mComponentsToAdd.end(); ++iter)
153 if (
auto* result =
dynamic_cast<TInterface*
>(iter->first))
161template <
typename TInterface>
164 std::vector<TInterface*> comps;
165 for (
auto iter = mComponentsMap.begin(); iter != mComponentsMap.end(); ++iter)
167 if (
auto* result =
dynamic_cast<TInterface*
>(iter->second))
169 comps.push_back(result);
173 for (
auto compIt = mComponentsToAdd.begin(); compIt != mComponentsToAdd.end(); ++compIt)
175 if (
auto* result =
dynamic_cast<TInterface*
>(compIt->first))
177 comps.push_back(result);
184template <
typename TInterface>
187 std::vector<fsCEntity*> ents;
193 auto ret = childEnt->childEntitiesWithComponentsOfFamilyType<TInterface>();
194 ents.insert(ents.end(), ret.begin(), ret.end());
198 for (
auto iter = mComponentsMap.begin(); iter != mComponentsMap.end(); ++iter)
200 if (
dynamic_cast<TInterface*
>(iter->second))
202 ents.push_back(
this);
208template <
typename TComponent>
211 return dynamic_cast<TComponent* const
>(
componentGet(TComponent::mTypeId));
214template <
typename TComponent>
217 return dynamic_cast<TComponent* const
>(
componentAdd(TComponent::mTypeId));
220template <
typename TInterface>
227 if (
auto matchEnt = childEnt->firstChildEntityWithComponentsOfFamilyType<TInterface>())
234 for (
auto component : mComponentsMap)
236 if (
dynamic_cast<TInterface*
>(component.second))
244template <
typename TLamda>
250 if (fsCEntity* const ent = dynamic_cast<fsCEntity*>(node))
252 ent->forAllChildren(pLamda);
258template <
typename TLamda>
Definition fsCComponentFactory.h:26
Definition fsCEntityFactory.h:25
void initialiseFromVariableTableDo(const fsCVariableTable &pVars) override
Definition fsCEntity.cpp:135
static void componentFactorySet(std::shared_ptr< fsCComponentFactory > pComponentFactory)
Definition fsCEntity.cpp:49
void resetDo() override
Definition fsCEntity.cpp:194
void forAllChildren(TLamda &&pLamda)
Definition fsCEntity.h:245
TComponent * componentAdd()
Definition fsCEntity.h:215
friend class gfCTestLoadGuis
Definition fsCEntity.h:41
void renderDo() override
Definition fsCEntity.cpp:184
fsCEntity * firstChildEntityWithComponentsOfFamilyType()
Definition fsCEntity.h:221
fsISpriteComponent * spriteComponentAdd()
Definition fsCEntity.cpp:98
void listenersRegister()
Definition fsCEntity.cpp:19
fsITextSpriteComponent * textComponentGet() const
Definition fsCEntity.cpp:93
static void entityFactorySet(std::shared_ptr< fsCEntityFactory > pEntityFactory)
Definition fsCEntity.cpp:59
fsITextSpriteComponent * textComponentAdd()
Definition fsCEntity.cpp:88
fsCEntity * childFind(const fsStr &pName, fsBool pCaseless=false)
Definition fsCEntity.cpp:199
void listenersDeRegister()
Definition fsCEntity.cpp:31
fsCEntityFactory * entityFactoryGet()
Definition fsCEntity.cpp:64
void forMyChildren(TLamda &&pLamda)
Definition fsCEntity.h:259
std::vector< fsCEntity * > childEntitiesWithComponentsOfTypeGet(const std::vector< const std::type_info * > &pPossibleComponentTypes)
Definition fsCEntity.cpp:302
void postLoad() override
Definition fsCEntity.cpp:129
fsCEntity * grandparentGet() const
Definition fsCEntity.cpp:14
fsBool tagExists(fsStr const &pTag) const
Definition fsCEntity.cpp:79
TInterface * firstComponentOfFamilyType() const
Definition fsCEntity.h:141
fsISpriteComponent * spriteComponentGet() const
Definition fsCEntity.cpp:103
fsCComponentFactory * componentFactoryGet()
Definition fsCEntity.cpp:54
TComponent * componentGet() const
Definition fsCEntity.h:209
void initDo() override
Definition fsCEntity.cpp:108
friend class fsCEntityFactory
Definition fsCEntity.h:40
fsCEntity(const fsStr &pName)
Definition fsCEntity.cpp:335
std::vector< fsCEntity * > childEntitiesWithComponentsOfFamilyType()
Definition fsCEntity.h:185
void postLinkDo() override
Definition fsCEntity.cpp:43
void tagAdd(fsStr const &pTag)
Definition fsCEntity.cpp:69
std::vector< fsCEntity * > childEntitiesTaggedWithGet(std::vector< fsStr > pTags)
Definition fsCEntity.cpp:275
void deserialiseDo() override
Definition fsCEntity.cpp:122
std::vector< TInterface * > componentsOfFamilyTypeGet() const
Definition fsCEntity.h:162
void componentDestroy(const fsCUniqueId &pTypeId)
Definition fsCEntity.cpp:257
void updateDo(fsS32 pDeltaMs) override
Definition fsCEntity.cpp:163
virtual ~fsCEntity()
Definition fsCEntity.cpp:342
void updatedMatrixProcess() override
Definition fsCEntity.cpp:189
void serialiseDo() override
Definition fsCEntity.cpp:115
friend class fsIGuiComponent
Definition fsCEntity.h:42
Definition fsCTaggableComponent.h:19
Definition fsCUniqueId.h:21
Definition fsCVariableTable.h:27
Definition fsIComponent.h:26
fsINode(const fsStr &pName)
Definition fsINode.cpp:657
friend class fsCEntity
Definition fsINode.h:31
std::vector< fsINode * > mChildren
Definition fsINode.h:117
Definition fsIRenderableComponent.h:21
Definition fsISpriteComponent.h:23
Definition fsITextSpriteComponent.h:22
bool fsBool
Definition fsBaseTypes.h:26
int fsS32
Definition fsBaseTypes.h:20