3
0

${Name}ComponentController.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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/Asset/AssetCommon.h>
  10. #include <AzCore/Component/Component.h>
  11. #include <AzCore/Component/TransformBus.h>
  12. #include <${Name}/${Name}FeatureProcessorInterface.h>
  13. namespace ${Name}
  14. {
  15. class ${Name}ComponentConfig final
  16. : public AZ::ComponentConfig
  17. {
  18. public:
  19. AZ_RTTI(${Name}ComponentConfig, "{${Random_Uuid}}", ComponentConfig);
  20. AZ_CLASS_ALLOCATOR(${Name}ComponentConfig, AZ::SystemAllocator);
  21. static void Reflect(AZ::ReflectContext* context);
  22. ${Name}ComponentConfig() = default;
  23. AZ::u64 m_entityId{ AZ::EntityId::InvalidEntityId };
  24. };
  25. class ${Name}ComponentController final
  26. : public AZ::Data::AssetBus::MultiHandler
  27. , private AZ::TransformNotificationBus::Handler
  28. {
  29. public:
  30. friend class Editor${Name}Component;
  31. AZ_RTTI(${Name}ComponentController, "{${Random_Uuid}}");
  32. AZ_CLASS_ALLOCATOR(${Name}ComponentController, AZ::SystemAllocator);
  33. static void Reflect(AZ::ReflectContext* context);
  34. static void GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent);
  35. static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided);
  36. static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible);
  37. static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required);
  38. ${Name}ComponentController() = default;
  39. ${Name}ComponentController(const ${Name}ComponentConfig& config);
  40. void Activate(AZ::EntityId entityId);
  41. void Deactivate();
  42. void SetConfiguration(const ${Name}ComponentConfig& config);
  43. const ${Name}ComponentConfig& GetConfiguration() const;
  44. private:
  45. AZ_DISABLE_COPY(${Name}ComponentController);
  46. // TransformNotificationBus overrides
  47. void OnTransformChanged(const AZ::Transform& local, const AZ::Transform& world) override;
  48. // handle for this probe in the feature processor
  49. ${Name}Handle m_handle;
  50. ${Name}FeatureProcessorInterface* m_featureProcessor = nullptr;
  51. AZ::TransformInterface* m_transformInterface = nullptr;
  52. AZ::EntityId m_entityId;
  53. ${Name}ComponentConfig m_configuration;
  54. };
  55. }