DebugDrawRayComponent.cpp 3.4 KB

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