EditorDetourNavigationComponent.cpp 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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 "EditorDetourNavigationComponent.h"
  9. #include <AzCore/Serialization/EditContext.h>
  10. #include <Components/DetourNavigationComponent.h>
  11. namespace RecastNavigation
  12. {
  13. void EditorDetourNavigationComponent::Reflect(AZ::ReflectContext* context)
  14. {
  15. if (auto serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
  16. {
  17. serializeContext->Class<EditorDetourNavigationComponent, AZ::Component>()
  18. ->Field("Navigation Mesh", &EditorDetourNavigationComponent::m_navQueryEntityId)
  19. ->Field("Nearest Distance", &EditorDetourNavigationComponent::m_nearestDistance)
  20. ->Version(1)
  21. ;
  22. if (AZ::EditContext* editContext = serializeContext->GetEditContext())
  23. {
  24. editContext->Class<EditorDetourNavigationComponent>("Detour Navigation Component",
  25. "[Calculates paths within an associated navigation mesh.]")
  26. ->ClassElement(AZ::Edit::ClassElements::EditorData, "")
  27. ->Attribute(AZ::Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC_CE("Game"))
  28. ->Attribute(AZ::Edit::Attributes::AutoExpand, true)
  29. ->DataElement(AZ::Edit::UIHandlers::Default, &EditorDetourNavigationComponent::m_navQueryEntityId,
  30. "Navigation Mesh", "Entity with Recast Navigation Mesh component")
  31. ->DataElement(AZ::Edit::UIHandlers::Default, &EditorDetourNavigationComponent::m_nearestDistance,
  32. "Nearest Distance", "If FindPath APIs are given points that are outside the navigation mesh, then "
  33. "look for the nearest point on the navigation mesh within this distance from the specified positions.")
  34. ;
  35. }
  36. }
  37. }
  38. void EditorDetourNavigationComponent::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
  39. {
  40. provided.push_back(AZ_CRC_CE("DetourNavigationComponent"));
  41. }
  42. void EditorDetourNavigationComponent::GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible)
  43. {
  44. incompatible.push_back(AZ_CRC_CE("DetourNavigationComponent"));
  45. }
  46. void EditorDetourNavigationComponent::Activate()
  47. {
  48. EditorComponentBase::Activate();
  49. }
  50. void EditorDetourNavigationComponent::Deactivate()
  51. {
  52. EditorComponentBase::Deactivate();
  53. }
  54. void EditorDetourNavigationComponent::BuildGameEntity(AZ::Entity* gameEntity)
  55. {
  56. gameEntity->CreateComponent<DetourNavigationComponent>(m_navQueryEntityId, m_nearestDistance);
  57. }
  58. } // namespace RecastNavigation