StartingPointCameraGem.cpp 3.5 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 "CameraTargetAcquirers/AcquireByEntityId.h"
  9. #include "CameraTargetAcquirers/AcquireByTag.h"
  10. #include "CameraTransformBehaviors/FollowTargetFromDistance.h"
  11. #include "CameraLookAtBehaviors/OffsetPosition.h"
  12. #include "CameraTransformBehaviors/FollowTargetFromAngle.h"
  13. #include "CameraTransformBehaviors/Rotate.h"
  14. #include "CameraTransformBehaviors/OffsetCameraPosition.h"
  15. #include "CameraLookAtBehaviors/SlideAlongAxisBasedOnAngle.h"
  16. #include "CameraLookAtBehaviors/RotateCameraLookAt.h"
  17. #include "CameraTransformBehaviors/FaceTarget.h"
  18. #include <AzCore/Serialization/SerializeContext.h>
  19. #include <AzCore/Module/Module.h>
  20. #include <AzFramework/Metrics/MetricsPlainTextNameRegistration.h>
  21. namespace StartingPointCamera
  22. {
  23. struct StartingPointCameraGemComponent
  24. : public AZ::Component
  25. {
  26. ~StartingPointCameraGemComponent() override = default;
  27. AZ_COMPONENT(StartingPointCameraGemComponent, "{728DF62E-6787-4A16-8F07-8A45BECADAD7}");
  28. static void Reflect(AZ::ReflectContext* reflection)
  29. {
  30. Camera::AcquireByEntityId::Reflect(reflection);
  31. Camera::AcquireByTag::Reflect(reflection);
  32. Camera::FollowTargetFromDistance::Reflect(reflection);
  33. Camera::OffsetPosition::Reflect(reflection);
  34. Camera::FollowTargetFromAngle::Reflect(reflection);
  35. Camera::Rotate::Reflect(reflection);
  36. Camera::OffsetCameraPosition::Reflect(reflection);
  37. Camera::SlideAlongAxisBasedOnAngle::Reflect(reflection);
  38. Camera::RotateCameraLookAt::Reflect(reflection);
  39. Camera::FaceTarget::Reflect(reflection);
  40. if (AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(reflection))
  41. {
  42. serializeContext->Class<StartingPointCameraGemComponent, AZ::Component>()
  43. ->Version(0)
  44. ;
  45. }
  46. }
  47. void Activate() override {}
  48. void Deactivate() override {}
  49. };
  50. class StartingPointCameraModule
  51. : public AZ::Module
  52. {
  53. public:
  54. AZ_RTTI(StartingPointCameraModule, "{87B6E891-9C64-4C5D-9FA1-4079BF6D902D}", AZ::Module);
  55. StartingPointCameraModule()
  56. : AZ::Module()
  57. {
  58. m_descriptors.insert(m_descriptors.end(), {
  59. StartingPointCameraGemComponent::CreateDescriptor(),
  60. });
  61. // This is an internal Amazon gem, so register it's components for metrics tracking, otherwise the name of the component won't get sent back.
  62. // IF YOU ARE A THIRDPARTY WRITING A GEM, DO NOT REGISTER YOUR COMPONENTS WITH EditorMetricsComponentRegistrationBus
  63. AZStd::vector<AZ::Uuid> typeIds;
  64. typeIds.reserve(m_descriptors.size());
  65. for (AZ::ComponentDescriptor* descriptor : m_descriptors)
  66. {
  67. typeIds.emplace_back(descriptor->GetUuid());
  68. }
  69. AzFramework::MetricsPlainTextNameRegistrationBus::Broadcast(
  70. &AzFramework::MetricsPlainTextNameRegistrationBus::Events::RegisterForNameSending, typeIds);
  71. }
  72. };
  73. }
  74. #if defined(O3DE_GEM_NAME)
  75. AZ_DECLARE_MODULE_CLASS(AZ_JOIN(Gem_, O3DE_GEM_NAME), StartingPointCamera::StartingPointCameraModule)
  76. #else
  77. AZ_DECLARE_MODULE_CLASS(Gem_StartingPointCamera, StartingPointCamera::StartingPointCameraModule)
  78. #endif