${Name}SystemComponent.cpp 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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 "${Name}SystemComponent.h"
  9. #include <${Name}/${Name}TypeIds.h>
  10. #include <AzCore/Serialization/SerializeContext.h>
  11. #include <Atom/RPI.Public/FeatureProcessorFactory.h>
  12. #include <Render/${Name}FeatureProcessor.h>
  13. namespace ${Name}
  14. {
  15. AZ_COMPONENT_IMPL(${Name}SystemComponent, "${Name}SystemComponent",
  16. ${Name}SystemComponentTypeId);
  17. void ${Name}SystemComponent::Reflect(AZ::ReflectContext* context)
  18. {
  19. if (auto serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
  20. {
  21. serializeContext->Class<${Name}SystemComponent, AZ::Component>()
  22. ->Version(0)
  23. ;
  24. }
  25. ${Name}FeatureProcessor::Reflect(context);
  26. }
  27. void ${Name}SystemComponent::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
  28. {
  29. provided.push_back(AZ_CRC_CE("${Name}SystemService"));
  30. }
  31. void ${Name}SystemComponent::GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible)
  32. {
  33. incompatible.push_back(AZ_CRC_CE("${Name}SystemService"));
  34. }
  35. void ${Name}SystemComponent::GetRequiredServices([[maybe_unused]] AZ::ComponentDescriptor::DependencyArrayType& required)
  36. {
  37. required.push_back(AZ_CRC_CE("RPISystem"));
  38. }
  39. void ${Name}SystemComponent::GetDependentServices([[maybe_unused]] AZ::ComponentDescriptor::DependencyArrayType& dependent)
  40. {
  41. }
  42. ${Name}SystemComponent::${Name}SystemComponent()
  43. {
  44. if (${Name}Interface::Get() == nullptr)
  45. {
  46. ${Name}Interface::Register(this);
  47. }
  48. }
  49. ${Name}SystemComponent::~${Name}SystemComponent()
  50. {
  51. if (${Name}Interface::Get() == this)
  52. {
  53. ${Name}Interface::Unregister(this);
  54. }
  55. }
  56. void ${Name}SystemComponent::Init()
  57. {
  58. }
  59. void ${Name}SystemComponent::Activate()
  60. {
  61. ${Name}RequestBus::Handler::BusConnect();
  62. AZ::RPI::FeatureProcessorFactory::Get()->RegisterFeatureProcessor<${Name}FeatureProcessor>();
  63. }
  64. void ${Name}SystemComponent::Deactivate()
  65. {
  66. AZ::RPI::FeatureProcessorFactory::Get()->UnregisterFeatureProcessor<${Name}FeatureProcessor>();
  67. ${Name}RequestBus::Handler::BusDisconnect();
  68. }
  69. } // namespace ${Name}