AckermannModelComponent.cpp 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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 "AckermannModelComponent.h"
  9. #include <AzCore/Serialization/EditContext.h>
  10. #include <AzCore/Serialization/EditContextConstants.inl>
  11. #include <AzCore/Serialization/SerializeContext.h>
  12. namespace ROS2::VehicleDynamics
  13. {
  14. void AckermannVehicleModelComponent::Reflect(AZ::ReflectContext* context)
  15. {
  16. AckermannDriveModel::Reflect(context);
  17. if (AZ::SerializeContext* serialize = azrtti_cast<AZ::SerializeContext*>(context))
  18. {
  19. serialize->Class<AckermannVehicleModelComponent, VehicleModelComponent>()->Version(3)->Field(
  20. "DriveModel", &AckermannVehicleModelComponent::m_driveModel);
  21. if (AZ::EditContext* ec = serialize->GetEditContext())
  22. {
  23. ec->Class<AckermannVehicleModelComponent>("Ackermann Vehicle Model", "Ackermann vehicle model component")
  24. ->ClassElement(AZ::Edit::ClassElements::EditorData, "")
  25. ->Attribute(AZ::Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC_CE("Game"))
  26. ->Attribute(AZ::Edit::Attributes::Category, "ROS2")
  27. ->DataElement(
  28. AZ::Edit::UIHandlers::Default,
  29. &AckermannVehicleModelComponent::m_driveModel,
  30. "Drive model",
  31. "Settings of the selected drive model");
  32. }
  33. }
  34. }
  35. void AckermannVehicleModelComponent::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
  36. {
  37. provided.push_back(AZ_CRC_CE("AckermannModelService"));
  38. }
  39. void AckermannVehicleModelComponent::GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible)
  40. {
  41. incompatible.push_back(AZ_CRC_CE("AckermannModelService"));
  42. }
  43. VehicleDynamics::DriveModel* AckermannVehicleModelComponent::GetDriveModel()
  44. {
  45. return &m_driveModel;
  46. };
  47. void AckermannVehicleModelComponent::Activate()
  48. {
  49. VehicleModelComponent::Activate();
  50. m_driveModel.Activate(m_vehicleConfiguration);
  51. }
  52. } // namespace ROS2::VehicleDynamics