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