LevelSettingsComponent.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #pragma once
  9. #include <AzCore/Component/Component.h>
  10. #include <AreaSystemComponent.h>
  11. #include <InstanceSystemComponent.h>
  12. #include <Vegetation/Ebuses/LevelSettingsRequestBus.h>
  13. namespace LmbrCentral
  14. {
  15. template<typename, typename>
  16. class EditorWrappedComponentBase;
  17. }
  18. namespace Vegetation
  19. {
  20. /*
  21. * The settings for the area and instance managers
  22. */
  23. class LevelSettingsConfig
  24. : public AZ::ComponentConfig
  25. {
  26. public:
  27. AZ_CLASS_ALLOCATOR(LevelSettingsConfig, AZ::SystemAllocator);
  28. AZ_RTTI(LevelSettingsConfig, "{794F7DE4-188C-4031-8B00-C2BA0C351A1E}", AZ::ComponentConfig);
  29. static void Reflect(AZ::ReflectContext* context);
  30. AreaSystemConfig m_areaSystemConfig;
  31. InstanceSystemConfig m_instanceSystemConfig;
  32. };
  33. inline constexpr AZ::TypeId LevelSettingsComponentTypeId{ "{FDF8520C-933F-4ED5-9B3A-4ABC9B62496C}" };
  34. /*
  35. * Sends out updates for the settings for the area and instance managers
  36. */
  37. class LevelSettingsComponent
  38. : public AZ::Component
  39. , private LevelSettingsRequestBus::Handler
  40. {
  41. public:
  42. template<typename, typename> friend class LmbrCentral::EditorWrappedComponentBase;
  43. AZ_COMPONENT(LevelSettingsComponent, LevelSettingsComponentTypeId);
  44. static void Reflect(AZ::ReflectContext* context);
  45. static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& services);
  46. static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& services);
  47. LevelSettingsComponent(const LevelSettingsConfig& configuration);
  48. LevelSettingsComponent() = default;
  49. ~LevelSettingsComponent() override;
  50. //////////////////////////////////////////////////////////////////////////
  51. // AZ::Component interface implementation
  52. void Init() override;
  53. void Activate() override;
  54. void Deactivate() override;
  55. bool ReadInConfig(const AZ::ComponentConfig* baseConfig) override;
  56. bool WriteOutConfig(AZ::ComponentConfig* outBaseConfig) const override;
  57. protected:
  58. void UpdateSystemConfig();
  59. LevelSettingsConfig m_configuration;
  60. AreaSystemConfig m_previousAreaSystemConfig;
  61. InstanceSystemConfig m_previousInstanceSystemConfig;
  62. bool m_componentActivated = false;
  63. //////////////////////////////////////////////////////////////////////////
  64. // LevelSettingsRequestBus
  65. AreaSystemConfig* GetAreaSystemConfig() override;
  66. InstanceSystemConfig* GetInstanceSystemConfig() override;
  67. bool m_active = false;
  68. };
  69. } // namespace Vegetation