3
0

DebugDrawTextComponent.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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/Script/ScriptTimePoint.h>
  11. #include <DebugDraw/DebugDrawBus.h>
  12. #include <AzFramework/Entity/EntityDebugDisplayBus.h>
  13. namespace DebugDraw
  14. {
  15. class DebugDrawTextElement
  16. {
  17. public:
  18. AZ_CLASS_ALLOCATOR(DebugDrawTextElement, AZ::SystemAllocator);
  19. AZ_TYPE_INFO(DebugDrawTextElement, "{A49413DB-0AFC-4D38-BD4B-EDC8FA83B640}");
  20. static void Reflect(AZ::ReflectContext* context);
  21. enum class DrawMode
  22. {
  23. OnScreen,
  24. InWorld,
  25. };
  26. DrawMode m_drawMode = DrawMode::OnScreen;
  27. float m_duration = 0.0f;
  28. AZStd::string m_text = "";
  29. AZ::ScriptTimePoint m_activateTime;
  30. AZ::Color m_color = AZ::Color(1.0f, 1.0f, 1.0f, 1.0f);
  31. AZ::EntityId m_targetEntityId;
  32. AZ::Vector3 m_worldLocation = AZ::Vector3::CreateZero();
  33. AZ::ComponentId m_owningEditorComponent = AZ::InvalidComponentId;
  34. };
  35. class DebugDrawTextComponent
  36. : public AZ::Component
  37. {
  38. friend class DebugDrawSystemComponent;
  39. public:
  40. AZ_COMPONENT(DebugDrawTextComponent, "{A705A8DF-31F1-49FF-8727-CC7783E09EF9}");
  41. static void Reflect(AZ::ReflectContext* context);
  42. static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided);
  43. static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible);
  44. static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required);
  45. static void GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent);
  46. DebugDrawTextComponent() = default;
  47. explicit DebugDrawTextComponent(const DebugDrawTextElement& textElement);
  48. ~DebugDrawTextComponent() override = default;
  49. // AZ::Component interface implementation
  50. void Init() override;
  51. void Activate() override;
  52. void Deactivate() override;
  53. protected:
  54. DebugDrawTextElement m_element;
  55. };
  56. }