MaestroSystemComponent.cpp 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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 <AzCore/Serialization/SerializeContext.h>
  9. #include <AzCore/Serialization/EditContext.h>
  10. #include <ISystem.h>
  11. #include "Cinematics/Movie.h"
  12. #include "MaestroSystemComponent.h"
  13. namespace Maestro
  14. {
  15. void MaestroAllocatorComponent::Activate()
  16. {
  17. }
  18. void MaestroAllocatorComponent::Deactivate()
  19. {
  20. }
  21. void MaestroAllocatorComponent::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
  22. {
  23. provided.push_back(AZ_CRC("MemoryAllocators", 0xd59acbcc));
  24. }
  25. void MaestroAllocatorComponent::Reflect(AZ::ReflectContext* context)
  26. {
  27. AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(context);
  28. if (serializeContext)
  29. {
  30. serializeContext->Class<MaestroAllocatorComponent, AZ::Component>()->Version(1)
  31. ->Attribute(AZ::Edit::Attributes::SystemComponentTags, AZStd::vector<AZ::Crc32>({ AZ_CRC("AssetBuilder", 0xc739c7d7) }));
  32. }
  33. }
  34. void MaestroSystemComponent::Reflect(AZ::ReflectContext* context)
  35. {
  36. if (AZ::SerializeContext* serialize = azrtti_cast<AZ::SerializeContext*>(context))
  37. {
  38. serialize->Class<MaestroSystemComponent, AZ::Component>()
  39. ->Version(0)
  40. ;
  41. if (AZ::EditContext* ec = serialize->GetEditContext())
  42. {
  43. ec->Class<MaestroSystemComponent>("Maestro", "Provides the Open 3D Engine Cinematics Service")
  44. ->ClassElement(AZ::Edit::ClassElements::EditorData, "")
  45. // ->Attribute(AZ::Edit::Attributes::Category, "") Set a category
  46. ->Attribute(AZ::Edit::Attributes::AutoExpand, true)
  47. ;
  48. }
  49. }
  50. }
  51. void MaestroSystemComponent::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
  52. {
  53. provided.push_back(AZ_CRC("MaestroService", 0xba05938e));
  54. }
  55. void MaestroSystemComponent::GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible)
  56. {
  57. incompatible.push_back(AZ_CRC("MaestroService", 0xba05938e));
  58. }
  59. void MaestroSystemComponent::GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required)
  60. {
  61. required.push_back(AZ_CRC("MemoryAllocators", 0xd59acbcc));
  62. }
  63. void MaestroSystemComponent::GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent)
  64. {
  65. (void)dependent;
  66. }
  67. void MaestroSystemComponent::Init()
  68. {
  69. }
  70. void MaestroSystemComponent::Activate()
  71. {
  72. MaestroRequestBus::Handler::BusConnect();
  73. CrySystemEventBus::Handler::BusConnect();
  74. }
  75. void MaestroSystemComponent::Deactivate()
  76. {
  77. MaestroRequestBus::Handler::BusDisconnect();
  78. CrySystemEventBus::Handler::BusDisconnect();
  79. }
  80. ///////////////////////////////////////////////////////////////////////////////////////////////
  81. void MaestroSystemComponent::OnCrySystemInitialized(ISystem& system, const SSystemInitParams& startupParams)
  82. {
  83. if (!startupParams.bSkipMovie)
  84. {
  85. // Create the movie System
  86. m_movieSystem.reset(new CMovieSystem(&system));
  87. gEnv->pMovieSystem = m_movieSystem.get();
  88. }
  89. }
  90. ///////////////////////////////////////////////////////////////////////////////////////////////
  91. void MaestroSystemComponent::OnCrySystemShutdown([[maybe_unused]] ISystem& system)
  92. {
  93. if (gEnv && gEnv->pMovieSystem)
  94. {
  95. gEnv->pMovieSystem = nullptr;
  96. // delete m_movieSystem
  97. m_movieSystem.reset();
  98. }
  99. }
  100. }