229 : \
230 inline static struct ClassEntryEnd { \
231 ClassEntryEnd() { \
232 ::Elevate::ComponentRegistry::Register<ThisType>( \
233 generated_classEntry.ClassName, \
234 generated_classEntry.Category, \
235 generated_classEntry.Options \
236 ); \
237 ::Elevate::ComponentRegistry::PopClassStack(); \
239 size_t start = generated_classEntry.FieldStartIndex; \
240 for (size_t i = start; i < global.size(); ++i) { \
241 generated_classEntry.ClassFieldStack.push_back(global[i]); \
242 } \
243 if (start < global.size()) { \
244 global.erase(global.begin() + start, global.end()); \
245 } \
246 } \
247 } generated_classEntryEnd; \
248public: \
249 inline virtual std::string GetName() const override { return generated_classEntry.ClassName; } \
251 std::vector<Elevate::ComponentField> instanceFields; \
252 if (generated_classEntry.HasBaseClass) { \
253 auto parentFields = ParentFieldsHelper<ThisType>::Get(); \
255 const void* fieldPtr = reinterpret_cast<const char*>(this) + field.offset; \
257 field, fieldPtr \
258 )); \
259 } \
260 } \
262 const void* fieldPtr = reinterpret_cast<const char*>(this) + field.offset; \
264 } \
266 } \
267 virtual Component* Clone() override { \
268 ThisType* clone = new ThisType(); \
269 for (auto& field : ComponentRegistry::GetCustomComponentFields()[typeid(ThisType).name()]) { \
270 field.CopyValue(this, clone); \
271 } \
272 return clone; \
273 } \
274 virtual void CopyFrom(Component* other) override { \
275 if (auto o = dynamic_cast<ThisType*>(other)) { \
276 if (generated_classEntry.HasBaseClass) { \
277 auto parentFields = ParentFieldsHelper<ThisType>::Get(); \
279 field.CopyValue(o, this); \
280 } \
281 } \
283 field.CopyValue(o, this); \
284 } \
285 } \
286 else { \
287 EE_ERROR("Error: Tried setting a %s from a %s component in CopyFrom(Component*)", \
288 this->GetName(), other ? other->GetName() : "null"); \
289 } \
290 } \
292 auto& entries = ComponentRegistry::GetEntries(); \
293 auto it = entries.find(typeid(ThisType)); \
294 if (it != entries.end()) { \
295 return it->second.factory; \
296 } \
297 return nullptr; \
298 } \
300 auto& entries = ComponentRegistry::GetEntries(); \
301 auto it = entries.find(typeid(ThisType)); \
302 if (it != entries.end()) { \
303 return it->second.destructor; \
304 } \
305 return nullptr; \
306 } \
307 virtual const void* GetEditorIconHandle() const override { \
308 auto& entries = ComponentRegistry::GetEntries(); \
309 auto it = entries.find(typeid(ThisType)); \
310 if (it != entries.end()) { \
311 if(!it->second.editorIconPath.empty()) { \
312 return Texture::CreateFromFile(it->second.editorIconPath)->GetNativeHandle(); \
313 } \
314 } \
315 return nullptr; \
316 } \
317 virtual std::type_index GetTypeIndex() const override { return typeid(ThisType); }
std::function< Component *(std::weak_ptr< GameObject >)> GameObjectComponentFactory
std::function< void(std::weak_ptr< GameObject >)> GameObjectComponentDestructor