MultiplayerSampleModule.cpp 3.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project. For complete copyright and license terms please see the LICENSE at the root of this distribution.
  3. *
  4. * SPDX-License-Identifier: Apache-2.0 OR MIT
  5. *
  6. */
  7. #include <AzCore/Memory/SystemAllocator.h>
  8. #include <AzCore/Module/Module.h>
  9. #include <Components/AttachPlayerWeaponComponent.h>
  10. #include <Components/ExampleFilteredEntityComponent.h>
  11. #include <Components/PerfTest/NetworkPrefabSpawnerComponent.h>
  12. #include <Components/UI/UiCoinCountComponent.h>
  13. #include <Components/UI/UiGameOverComponent.h>
  14. #include <Components/UI/UiPlayerArmorComponent.h>
  15. #include <Components/BackgroundMusicComponent.h>
  16. #include <Components/ScriptableDecalComponent.h>
  17. #include <Source/AutoGen/AutoComponentTypes.h>
  18. #include <MultiplayerSampleSystemComponent.h>
  19. #if AZ_TRAIT_CLIENT
  20. # include <Components/UI/HUDComponent.h>
  21. # include <Components/UI/UiMatchPlayerCoinCountsComponent.h>
  22. # include <Components/UI/UiRestBetweenRoundsComponent.h>
  23. # include <Components/UI/UiSettingsComponent.h>
  24. # include <Components/UI/UiStartMenuComponent.h>
  25. #include <UserSettings/MultiplayerSampleUserSettings.h>
  26. #endif
  27. namespace MultiplayerSample
  28. {
  29. class MultiplayerSampleModule
  30. : public AZ::Module
  31. {
  32. public:
  33. AZ_RTTI(MultiplayerSampleModule, "{9323FFB1-54AB-4665-889B-166CA2418C7C}", AZ::Module);
  34. AZ_CLASS_ALLOCATOR(MultiplayerSampleModule, AZ::SystemAllocator, 0);
  35. MultiplayerSampleModule()
  36. : AZ::Module()
  37. {
  38. // Push results of [MyComponent]::CreateDescriptor() into m_descriptors here.
  39. m_descriptors.insert(m_descriptors.end(), {
  40. MultiplayerSampleSystemComponent::CreateDescriptor(),
  41. AttachPlayerWeaponComponent::CreateDescriptor(),
  42. ExampleFilteredEntityComponent::CreateDescriptor(),
  43. NetworkPrefabSpawnerComponent::CreateDescriptor(),
  44. UiCoinCountComponent::CreateDescriptor(),
  45. BackgroundMusicComponent::CreateDescriptor(),
  46. ScriptableDecalComponent::CreateDescriptor(),
  47. #if AZ_TRAIT_CLIENT
  48. HUDComponent::CreateDescriptor(),
  49. UiGameOverComponent::CreateDescriptor(),
  50. UiPlayerArmorComponent::CreateDescriptor(),
  51. UiMatchPlayerCoinCountsComponent::CreateDescriptor(),
  52. UiRestBetweenRoundsComponent::CreateDescriptor(),
  53. UiSettingsComponent::CreateDescriptor(),
  54. UiStartMenuComponent::CreateDescriptor(),
  55. #endif
  56. });
  57. CreateComponentDescriptors(m_descriptors);
  58. }
  59. /**
  60. * Add required SystemComponents to the SystemEntity.
  61. */
  62. AZ::ComponentTypeList GetRequiredSystemComponents() const override
  63. {
  64. return AZ::ComponentTypeList{
  65. azrtti_typeid<MultiplayerSampleSystemComponent>(),
  66. };
  67. }
  68. #if AZ_TRAIT_CLIENT
  69. // This needs to be created as a part of the MultiplayerSampleModule, not during any sort of System Component activation.
  70. // It will affect registry keys that get read by System Components as a part of their activation and we can't guarantee
  71. // that those other core System Components will get started after our game-specific one.
  72. MultiplayerSampleUserSettings m_userSettings;
  73. #endif
  74. };
  75. }
  76. // DO NOT MODIFY THIS LINE UNLESS YOU RENAME THE GEM
  77. // The first parameter should be GemName_GemIdLower
  78. // The second should be the fully qualified name of the class above
  79. #if defined(AZ_MONOLITHIC_BUILD)
  80. AZ_DECLARE_MODULE_CLASS(Gem_MultiplayerSample_Client, MultiplayerSample::MultiplayerSampleModule);
  81. AZ_DECLARE_MODULE_CLASS(Gem_MultiplayerSample_Server, MultiplayerSample::MultiplayerSampleModule);
  82. #endif
  83. AZ_DECLARE_MODULE_CLASS(Gem_MultiplayerSample, MultiplayerSample::MultiplayerSampleModule)