${Name}SystemComponent.cpp 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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}