DebugDrawLineComponent.cpp 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. #include <AzCore/Serialization/SerializeContext.h>
  9. #include <AzCore/Serialization/EditContext.h>
  10. #include "DebugDrawLineComponent.h"
  11. namespace DebugDraw
  12. {
  13. void DebugDrawLineElement::Reflect(AZ::ReflectContext* context)
  14. {
  15. AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(context);
  16. if (serializeContext)
  17. {
  18. serializeContext->Class<DebugDrawLineElement>()
  19. ->Version(0)
  20. ->Field("StartEntityId", &DebugDrawLineElement::m_startEntityId)
  21. ->Field("EndEntityId", &DebugDrawLineElement::m_endEntityId)
  22. ->Field("StartWorldLocation", &DebugDrawLineElement::m_startWorldLocation)
  23. ->Field("EndWorldLocation", &DebugDrawLineElement::m_endWorldLocation)
  24. ->Field("Color", &DebugDrawLineElement::m_color)
  25. ;
  26. AZ::EditContext* editContext = serializeContext->GetEditContext();
  27. if (editContext)
  28. {
  29. editContext->Class<DebugDrawLineElement>("DebugDraw Line element settings", "Settings for DebugDraw line element.")
  30. ->ClassElement(AZ::Edit::ClassElements::EditorData, "")
  31. ->Attribute(AZ::Edit::Attributes::Category, "Debugging")
  32. ->DataElement(0, &DebugDrawLineElement::m_endEntityId, "End Entity", "Which entity the line is drawn to (starts on this entity).")
  33. ->DataElement(0, &DebugDrawLineElement::m_color, "Color", "Display color for the line.")
  34. ;
  35. }
  36. }
  37. }
  38. void DebugDrawLineComponent::Reflect(AZ::ReflectContext* context)
  39. {
  40. DebugDrawLineElement::Reflect(context);
  41. if (AZ::SerializeContext* serialize = azrtti_cast<AZ::SerializeContext*>(context))
  42. {
  43. serialize->Class<DebugDrawLineComponent, AZ::Component>()
  44. ->Version(0)
  45. ->Field("Element", &DebugDrawLineComponent::m_element)
  46. ;
  47. }
  48. }
  49. DebugDrawLineComponent::DebugDrawLineComponent(const DebugDrawLineElement& element)
  50. : m_element(element)
  51. {
  52. m_element.m_owningEditorComponent = AZ::InvalidComponentId;
  53. }
  54. void DebugDrawLineComponent::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
  55. {
  56. provided.push_back(AZ_CRC_CE("DebugDrawLineService"));
  57. }
  58. void DebugDrawLineComponent::GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible)
  59. {
  60. (void)incompatible;
  61. }
  62. void DebugDrawLineComponent::GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required)
  63. {
  64. (void)required;
  65. }
  66. void DebugDrawLineComponent::GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent)
  67. {
  68. (void)dependent;
  69. }
  70. void DebugDrawLineComponent::Init()
  71. {
  72. }
  73. void DebugDrawLineComponent::Activate()
  74. {
  75. DebugDrawInternalRequestBus::Broadcast(&DebugDrawInternalRequestBus::Events::RegisterDebugDrawComponent, this);
  76. }
  77. void DebugDrawLineComponent::Deactivate()
  78. {
  79. DebugDrawInternalRequestBus::Broadcast(&DebugDrawInternalRequestBus::Events::UnregisterDebugDrawComponent, this);
  80. }
  81. } // namespace DebugDraw