SkidSteeringModelComponent.cpp 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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 "SkidSteeringModelComponent.h"
  9. #include <AzCore/Serialization/EditContext.h>
  10. #include <AzCore/Serialization/EditContextConstants.inl>
  11. #include <AzCore/Serialization/SerializeContext.h>
  12. namespace ROS2Controllers::VehicleDynamics
  13. {
  14. void SkidSteeringModelComponent::Reflect(AZ::ReflectContext* context)
  15. {
  16. SkidSteeringDriveModel::Reflect(context);
  17. if (AZ::SerializeContext* serialize = azrtti_cast<AZ::SerializeContext*>(context))
  18. {
  19. serialize->Class<SkidSteeringModelComponent, VehicleModelComponent>()->Version(3)->Field(
  20. "DriveModel", &SkidSteeringModelComponent::m_driveModel);
  21. if (AZ::EditContext* ec = serialize->GetEditContext())
  22. {
  23. ec->Class<SkidSteeringModelComponent>("Skid Steering Vehicle Model", "Skid steering 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. ->Attribute(AZ::Edit::Attributes::Icon, "Editor/Icons/Components/SkidSteeringVehicleModel.svg")
  28. ->Attribute(AZ::Edit::Attributes::ViewportIcon, "Editor/Icons/Components/Viewport/SkidSteeringVehicleModel.svg")
  29. ->DataElement(
  30. AZ::Edit::UIHandlers::Default,
  31. &SkidSteeringModelComponent::m_driveModel,
  32. "Drive model",
  33. "Settings of the selected drive model");
  34. }
  35. }
  36. }
  37. SkidSteeringModelComponent::SkidSteeringModelComponent(
  38. const VehicleConfiguration& vehicleConfiguration, const SkidSteeringDriveModel& driveModel)
  39. : m_driveModel(driveModel)
  40. {
  41. m_vehicleConfiguration = vehicleConfiguration;
  42. }
  43. void SkidSteeringModelComponent::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
  44. {
  45. provided.push_back(AZ_CRC_CE("SkidSteeringModelService"));
  46. }
  47. void SkidSteeringModelComponent::GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible)
  48. {
  49. incompatible.push_back(AZ_CRC_CE("SkidSteeringModelService"));
  50. }
  51. VehicleDynamics::DriveModel* SkidSteeringModelComponent::GetDriveModel()
  52. {
  53. return &m_driveModel;
  54. };
  55. void SkidSteeringModelComponent::Activate()
  56. {
  57. VehicleModelComponent::Activate();
  58. m_driveModel.Activate(m_vehicleConfiguration);
  59. }
  60. } // namespace ROS2Controllers::VehicleDynamics