EntityDebugDisplayComponent.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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 <AzCore/Component/TransformBus.h>
  11. #include <AzFramework/Entity/EntityDebugDisplayBus.h>
  12. namespace LmbrCentral
  13. {
  14. /**
  15. * Base type to be used to do custom component debug drawing.
  16. */
  17. class EntityDebugDisplayComponent
  18. : public AZ::Component
  19. , private AZ::TransformNotificationBus::Handler
  20. , private AzFramework::EntityDebugDisplayEventBus::Handler
  21. {
  22. public:
  23. AZ_CLASS_ALLOCATOR(EntityDebugDisplayComponent, AZ::SystemAllocator);
  24. AZ_RTTI(EntityDebugDisplayComponent, "{091EA609-13E9-4553-83BA-36878CBAB950}", AZ::Component);
  25. EntityDebugDisplayComponent() = default;
  26. // AZ::Component
  27. void Activate() override;
  28. void Deactivate() override;
  29. static void Reflect(AZ::ReflectContext* context);
  30. protected:
  31. static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required)
  32. {
  33. required.push_back(AZ_CRC_CE("TransformService"));
  34. }
  35. // AZ::TransformNotificationBus::Handler
  36. void OnTransformChanged(const AZ::Transform& local, const AZ::Transform& world) override;
  37. /**
  38. * Interface to draw using DebugDisplayRequests API.
  39. */
  40. virtual void Draw(AzFramework::DebugDisplayRequests& debugDisplay) = 0;
  41. const AZ::Transform& GetCurrentTransform() const { return m_currentEntityTransform; }
  42. private:
  43. AZ_DISABLE_COPY_MOVE(EntityDebugDisplayComponent)
  44. // AzFramework::EntityDebugDisplayEventBus
  45. void DisplayEntityViewport(
  46. const AzFramework::ViewportInfo& viewportInfo,
  47. AzFramework::DebugDisplayRequests& debugDisplay) override;
  48. AZ::Transform m_currentEntityTransform; ///< Stores the transform of the entity.
  49. };
  50. }