${Name}EditorModule.cpp 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. // {BEGIN_LICENSE}
  2. /*
  3. * Copyright (c) Contributors to the Open 3D Engine Project.
  4. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  5. *
  6. * SPDX-License-Identifier: Apache-2.0 OR MIT
  7. *
  8. */
  9. // {END_LICENSE}
  10. #include <${Name}/${Name}TypeIds.h>
  11. #include <${Name}ModuleInterface.h>
  12. #include "${Name}EditorSystemComponent.h"
  13. #include <AzToolsFramework/API/PythonLoader.h>
  14. #include <QtGlobal>
  15. void Init${SanitizedCppName}Resources()
  16. {
  17. // We must register our Qt resources (.qrc file) since this is being loaded from a separate module (gem)
  18. Q_INIT_RESOURCE(${SanitizedCppName});
  19. }
  20. namespace ${SanitizedCppName}
  21. {
  22. class ${SanitizedCppName}EditorModule
  23. : public ${SanitizedCppName}ModuleInterface
  24. , public AzToolsFramework::EmbeddedPython::PythonLoader
  25. {
  26. public:
  27. AZ_RTTI(${SanitizedCppName}EditorModule, ${SanitizedCppName}EditorModuleTypeId, ${SanitizedCppName}ModuleInterface);
  28. AZ_CLASS_ALLOCATOR(${SanitizedCppName}EditorModule, AZ::SystemAllocator);
  29. ${SanitizedCppName}EditorModule()
  30. {
  31. Init${SanitizedCppName}Resources();
  32. // Push results of [MyComponent]::CreateDescriptor() into m_descriptors here.
  33. // Add ALL components descriptors associated with this gem to m_descriptors.
  34. // This will associate the AzTypeInfo information for the components with the the SerializeContext, BehaviorContext and EditContext.
  35. // This happens through the [MyComponent]::Reflect() function.
  36. m_descriptors.insert(m_descriptors.end(), {
  37. ${SanitizedCppName}EditorSystemComponent::CreateDescriptor(),
  38. });
  39. }
  40. /**
  41. * Add required SystemComponents to the SystemEntity.
  42. * Non-SystemComponents should not be added here
  43. */
  44. AZ::ComponentTypeList GetRequiredSystemComponents() const override
  45. {
  46. return AZ::ComponentTypeList {
  47. azrtti_typeid<${SanitizedCppName}EditorSystemComponent>(),
  48. };
  49. }
  50. };
  51. }// namespace ${SanitizedCppName}
  52. #if defined(O3DE_GEM_NAME)
  53. AZ_DECLARE_MODULE_CLASS(AZ_JOIN(Gem_, O3DE_GEM_NAME, _Editor), ${SanitizedCppName}::${SanitizedCppName}EditorModule)
  54. #else
  55. AZ_DECLARE_MODULE_CLASS(Gem_${SanitizedCppName}_Editor, ${SanitizedCppName}::${SanitizedCppName}EditorModule)
  56. #endif