3
0

SequenceAgentComponent.h 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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 <AzCore/RTTI/BehaviorContext.h>
  10. #include <AzCore/Component/Component.h>
  11. #include <Maestro/Bus/SequenceAgentComponentBus.h>
  12. #include "SequenceAgent.h"
  13. namespace AzFramework
  14. {
  15. class TransformComponent;
  16. }
  17. namespace Maestro
  18. {
  19. class SequenceAgentComponent
  20. : public AZ::Component
  21. , public SequenceAgentComponentRequestBus::MultiHandler
  22. , public SequenceAgent
  23. {
  24. public:
  25. friend class EditorSequenceAgentComponent;
  26. AZ_COMPONENT(SequenceAgentComponent, "{67DC06D3-1F16-4FAB-B3F8-D8C0A3AF4F61}");
  27. //////////////////////////////////////////////////////////////////////////
  28. // AZ::Component interface implementation
  29. void Init() override;
  30. void Activate() override;
  31. void Deactivate() override;
  32. //////////////////////////////////////////////////////////////////////////
  33. //////////////////////////////////////////////////////////////////////////
  34. // SequenceAgentComponentRequestBus::Handler Interface
  35. void GetAnimatedPropertyValue(AnimatedValue& returnValue, const Maestro::SequenceComponentRequests::AnimatablePropertyAddress& animatableAddress) override;
  36. bool SetAnimatedPropertyValue(const Maestro::SequenceComponentRequests::AnimatablePropertyAddress& animatableAddress, const AnimatedValue& value) override;
  37. AZ::Uuid GetAnimatedAddressTypeId(const AnimatablePropertyAddress& animatableAddress) override;
  38. void GetAssetDuration(AnimatedValue& returnValue, AZ::ComponentId componentId, const AZ::Data::AssetId& assetId) override;
  39. void ConnectSequence(const AZ::EntityId& sequenceEntityId) override;
  40. void DisconnectSequence() override;
  41. //~SequenceAgentComponentRequestBus::Handler Interface
  42. //////////////////////////////////////////////////////////////////////////
  43. protected:
  44. // Required Reflect function.
  45. static void Reflect(AZ::ReflectContext* context);
  46. static void GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent)
  47. {
  48. dependent.push_back(AZ_CRC("TransformService", 0x8ee22c50));
  49. }
  50. // Override from SequenceAgent
  51. AZ::TypeId GetComponentTypeUuid(const AZ::Component& component) const override
  52. {
  53. return component.RTTI_GetType();
  54. }
  55. // Get all of the components available on the current entity.
  56. void GetEntityComponents(AZ::Entity::ComponentArrayType& entityComponents) const override;
  57. private:
  58. // connect and disconnect to all SequenceComponents registered with us
  59. void ConnectAllSequences();
  60. void DisconnectAllSequences();
  61. // set of ids of all unique Entities with SequenceComponent instances connected to this Agent
  62. AZStd::unordered_set<AZ::EntityId> m_sequenceEntityIds;
  63. };
  64. } // namespace Maestro