SequenceComponent.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. #pragma once
  9. #include <IMovieSystem.h>
  10. #include <AzCore/Component/Component.h>
  11. #include <Maestro/Bus/SequenceComponentBus.h>
  12. namespace Maestro
  13. {
  14. namespace AnimSerialize
  15. {
  16. //! Wrapper class for animation system data file. This allows us to use the old Cry
  17. //! serialize for the animation data
  18. class AnimationData
  19. {
  20. public:
  21. virtual ~AnimationData() { }
  22. AZ_CLASS_ALLOCATOR(AnimationData, AZ::SystemAllocator);
  23. AZ_RTTI(AnimationData, "{1CC687A8-9331-4314-A0F9-C75C50C10268}");
  24. AZStd::string m_serializedData;
  25. };
  26. }
  27. class SequenceComponent
  28. : public AZ::Component
  29. , public Maestro::SequenceComponentRequestBus::Handler
  30. {
  31. friend class EditorSequenceComponent;
  32. public:
  33. AZ_COMPONENT(SequenceComponent, "{027CE988-CF48-4589-A73A-73CD8D02F783}");
  34. SequenceComponent();
  35. //////////////////////////////////////////////////////////////////////////
  36. // AZ::Component interface implementation
  37. void Init() override;
  38. void Activate() override;
  39. void Deactivate() override;
  40. //////////////////////////////////////////////////////////////////////////
  41. //////////////////////////////////////////////////////////////////////////
  42. // SequenceComponentRequestBus::Handler Interface
  43. /**
  44. * Set a value for an animated property at the given address on the given entity.
  45. * @param animatedEntityId the entity Id of the entity containing the animatedAddress
  46. * @param animatedAddress identifies the component and property to be set
  47. * @param value the value to set - this must be instance of one of the concrete subclasses of AnimatedValue, corresponding to the type of the property referenced by the animatedAdresss
  48. * @return true if the value was changed.
  49. */
  50. bool SetAnimatedPropertyValue(const AZ::EntityId& animatedEntityId, const AnimatablePropertyAddress& animatableAddress, const AnimatedValue& value) override;
  51. /**
  52. * Get the current value for a property
  53. * @param returnValue holds the value to get - this must be instance of one of the concrete subclasses of AnimatedValue, corresponding to the type of the property referenced by the animatedAdresss
  54. * @param animatedEntityId the entity Id of the entity containing the animatedAddress
  55. * @param animatedAddress identifies the component and property to be set
  56. */
  57. void GetAnimatedPropertyValue(AnimatedValue& returnValue, const AZ::EntityId& animatedEntityId, const AnimatablePropertyAddress& animatableAddress) override;
  58. AZ::Uuid GetAnimatedAddressTypeId(const AZ::EntityId& animatedEntityId, const Maestro::SequenceComponentRequests::AnimatablePropertyAddress& animatableAddress) override;
  59. //! Track View will expect some components (those using AZ::Data::AssetBlends as a virtual property) to supply a GetAssetDuration event
  60. //! so Track View can query the duration of an asset (like a motion) without having any knowledge of that that asset is.
  61. void GetAssetDuration(AnimatedValue& returnValue, const AZ::EntityId& animatedEntityId, AZ::ComponentId componentId, const AZ::Data::AssetId& assetId) override;
  62. /////////////////////////////////////////
  63. // Behaviors
  64. void Play() override;
  65. void PlayBetweenTimes(float startTime, float endTime) override;
  66. void Stop() override;
  67. void Pause() override;
  68. void Resume() override;
  69. void SetPlaySpeed(float newSpeed) override;
  70. void JumpToTime(float newTime) override;
  71. void JumpToEnd() override;
  72. void JumpToBeginning() override;
  73. float GetCurrentPlayTime() override;
  74. float GetPlaySpeed() override;
  75. //////////////////////////////////////////////////////////////////////////
  76. protected:
  77. static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
  78. {
  79. provided.push_back(AZ_CRC("SequenceService", 0x7cbe5938));
  80. }
  81. static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible);
  82. // Required Reflect function.
  83. static void Reflect(AZ::ReflectContext* context);
  84. private:
  85. // pointer and id of the CryMovie anim sequence responsible for playback/recording
  86. AZStd::intrusive_ptr<IAnimSequence> m_sequence;
  87. // Reflects the entire CryMovie library
  88. static void ReflectCinematicsLib(AZ::ReflectContext* context);
  89. };
  90. } // namespace Maestro