SimulationFeaturesAggregator.cpp 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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 "SimulationFeaturesAggregator.h"
  9. #include <AzCore/Component/ComponentApplicationBus.h>
  10. #include <AzCore/Serialization/SerializeContext.h>
  11. #include <AzFramework/Physics/PhysicsSystem.h>
  12. #include <SimulationInterfaces/SimulationInterfacesTypeIds.h>
  13. namespace SimulationInterfaces
  14. {
  15. AZ_COMPONENT_IMPL(SimulationFeaturesAggregator, "SimulationFeaturesAggregator", SimulationFeaturesAggregatorTypeId);
  16. void SimulationFeaturesAggregator::Reflect(AZ::ReflectContext* context)
  17. {
  18. if (auto serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
  19. {
  20. serializeContext->Class<SimulationFeaturesAggregator, AZ::Component>()->Version(0);
  21. }
  22. }
  23. void SimulationFeaturesAggregator::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
  24. {
  25. provided.push_back(AZ_CRC_CE("SimulationFeaturesAggregator"));
  26. }
  27. void SimulationFeaturesAggregator::GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible)
  28. {
  29. incompatible.push_back(AZ_CRC_CE("SimulationFeaturesAggregator"));
  30. }
  31. void SimulationFeaturesAggregator::GetRequiredServices([[maybe_unused]] AZ::ComponentDescriptor::DependencyArrayType& required)
  32. {
  33. }
  34. void SimulationFeaturesAggregator::GetDependentServices([[maybe_unused]] AZ::ComponentDescriptor::DependencyArrayType& dependent)
  35. {
  36. }
  37. SimulationFeaturesAggregator::SimulationFeaturesAggregator()
  38. {
  39. if (SimulationFeaturesAggregatorRequestBusInterface::Get() == nullptr)
  40. {
  41. SimulationFeaturesAggregatorRequestBusInterface::Register(this);
  42. }
  43. }
  44. SimulationFeaturesAggregator::~SimulationFeaturesAggregator()
  45. {
  46. if (SimulationFeaturesAggregatorRequestBusInterface::Get() == this)
  47. {
  48. SimulationFeaturesAggregatorRequestBusInterface::Unregister(this);
  49. }
  50. }
  51. void SimulationFeaturesAggregator::Init()
  52. {
  53. }
  54. void SimulationFeaturesAggregator::Activate()
  55. {
  56. SimulationFeaturesAggregatorRequestBus::Handler::BusConnect();
  57. }
  58. void SimulationFeaturesAggregator::Deactivate()
  59. {
  60. SimulationFeaturesAggregatorRequestBus::Handler::BusDisconnect();
  61. }
  62. void SimulationFeaturesAggregator::AddSimulationFeatures(const AZStd::unordered_set<SimulationFeatureType>& features)
  63. {
  64. m_registeredFeatures.insert(features.begin(), features.end());
  65. }
  66. AZStd::unordered_set<SimulationFeatureType> SimulationFeaturesAggregator::GetSimulationFeatures()
  67. {
  68. return m_registeredFeatures;
  69. }
  70. bool SimulationFeaturesAggregator::HasFeature(SimulationFeatureType feature)
  71. {
  72. return m_registeredFeatures.contains(feature);
  73. }
  74. } // namespace SimulationInterfaces