ROSConDemoSystemComponent.cpp 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. #include <AzCore/Serialization/SerializeContext.h>
  2. #include <AzCore/Serialization/EditContext.h>
  3. #include <AzCore/Serialization/EditContextConstants.inl>
  4. #include <Atom/RPI.Public/FeatureProcessorFactory.h>
  5. #include "ROSConDemoSystemComponent.h"
  6. #include "SunShaftsFeatureProcessor.h"
  7. namespace ROSConDemo
  8. {
  9. void ROSConDemoSystemComponent::Reflect(AZ::ReflectContext* context)
  10. {
  11. SunShaftsFeatureProcessor::Reflect(context);
  12. if (AZ::SerializeContext* serialize = azrtti_cast<AZ::SerializeContext*>(context))
  13. {
  14. serialize->Class<ROSConDemoSystemComponent, AZ::Component>()
  15. ->Version(0)
  16. ;
  17. if (AZ::EditContext* ec = serialize->GetEditContext())
  18. {
  19. ec->Class<ROSConDemoSystemComponent>("ROSConDemo", "[Description of functionality provided by this System Component]")
  20. ->ClassElement(AZ::Edit::ClassElements::EditorData, "")
  21. ->Attribute(AZ::Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC("System"))
  22. ->Attribute(AZ::Edit::Attributes::AutoExpand, true)
  23. ;
  24. }
  25. }
  26. }
  27. void ROSConDemoSystemComponent::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
  28. {
  29. provided.push_back(AZ_CRC("ROSConDemoService"));
  30. }
  31. void ROSConDemoSystemComponent::GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible)
  32. {
  33. incompatible.push_back(AZ_CRC("ROSConDemoService"));
  34. }
  35. void ROSConDemoSystemComponent::GetRequiredServices([[maybe_unused]] AZ::ComponentDescriptor::DependencyArrayType& required)
  36. {
  37. required.push_back(AZ_CRC("AtomBridgeService"));
  38. }
  39. void ROSConDemoSystemComponent::GetDependentServices([[maybe_unused]] AZ::ComponentDescriptor::DependencyArrayType& dependent)
  40. {
  41. }
  42. ROSConDemoSystemComponent::ROSConDemoSystemComponent()
  43. {
  44. if (ROSConDemoInterface::Get() == nullptr)
  45. {
  46. ROSConDemoInterface::Register(this);
  47. }
  48. }
  49. ROSConDemoSystemComponent::~ROSConDemoSystemComponent()
  50. {
  51. if (ROSConDemoInterface::Get() == this)
  52. {
  53. ROSConDemoInterface::Unregister(this);
  54. }
  55. }
  56. void ROSConDemoSystemComponent::Init()
  57. {
  58. }
  59. void ROSConDemoSystemComponent::Activate()
  60. {
  61. ROSConDemoRequestBus::Handler::BusConnect();
  62. AZ::RPI::FeatureProcessorFactory::Get()->RegisterFeatureProcessor<SunShaftsFeatureProcessor>();
  63. auto* passSystem = AZ::RPI::PassSystemInterface::Get();
  64. AZ_Assert(passSystem, "Cannot get the pass system.");
  65. // Setup handler for load pass templates mappings
  66. m_loadTemplatesHandler = AZ::RPI::PassSystemInterface::OnReadyLoadTemplatesEvent::Handler(
  67. [passSystem]()
  68. {
  69. const char* passTemplatesFile = "Passes/SunShaftsPassTemplates.azasset";
  70. passSystem->LoadPassTemplateMappings(passTemplatesFile);
  71. });
  72. //passSystem->AddPassCreator(AZ::Name("SunShaftsFullScreenPass"), &SunShaftsFullScreenPass::Create);
  73. passSystem->ConnectEvent(m_loadTemplatesHandler);
  74. }
  75. void ROSConDemoSystemComponent::Deactivate()
  76. {
  77. AZ::RPI::FeatureProcessorFactory::Get()->UnregisterFeatureProcessor<SunShaftsFeatureProcessor>();
  78. m_loadTemplatesHandler.Disconnect();
  79. ROSConDemoRequestBus::Handler::BusDisconnect();
  80. }
  81. }