3
0

EditorSequenceAgentComponent.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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 <AzToolsFramework/ToolsComponents/EditorComponentBase.h>
  10. #include <Maestro/Bus/EditorSequenceAgentComponentBus.h>
  11. #include "SequenceAgent.h"
  12. namespace AzToolsFramework
  13. {
  14. namespace Components
  15. {
  16. class TransformComponent;
  17. }
  18. }
  19. namespace Maestro
  20. {
  21. class EditorSequenceAgentComponent
  22. : public AzToolsFramework::Components::EditorComponentBase
  23. , public EditorSequenceAgentComponentRequestBus::MultiHandler
  24. , public SequenceAgentComponentRequestBus::MultiHandler
  25. , public SequenceAgent
  26. , public EditorSequenceAgentComponentNotificationBus::MultiHandler
  27. {
  28. public:
  29. AZ_EDITOR_COMPONENT(EditorSequenceAgentComponent, "{D90A3A45-CA0C-4ED7-920A-41D50557D67B}");
  30. //////////////////////////////////////////////////////////////////////////
  31. // AZ::Component interface implementation
  32. void Activate() override;
  33. void Deactivate() override;
  34. //////////////////////////////////////////////////////////////////////////
  35. //////////////////////////////////////////////////////////////////////////
  36. // EditorSequenceAgentComponentRequestBus::Handler Interface
  37. void GetAllAnimatableProperties(IAnimNode::AnimParamInfos& properties, AZ::ComponentId componentId) override;
  38. void GetAnimatableComponents(AZStd::vector<AZ::ComponentId>& animatableComponentIds) override;
  39. //~EditorSequenceAgentComponentRequestBus::Handler Interface //////////////////
  40. //////////////////////////////////////////////////////////////////////////
  41. // SequenceAgentComponentRequestBus::Handler Interface
  42. void ConnectSequence(const AZ::EntityId& sequenceEntityId) override;
  43. void DisconnectSequence() override;
  44. AZ::Uuid GetAnimatedAddressTypeId(const AnimatablePropertyAddress& animatableAddress) override;
  45. void GetAnimatedPropertyValue(AnimatedValue& returnValue, const AnimatablePropertyAddress& animatableAddress) override;
  46. bool SetAnimatedPropertyValue(const AnimatablePropertyAddress& animatableAddress, const AnimatedValue& value) override;
  47. void GetAssetDuration(AnimatedValue& returnValue, AZ::ComponentId componentId, const AZ::Data::AssetId& assetId) override;
  48. //~SequenceAgentComponentRequestBus::Handler Interface //////////////////
  49. protected:
  50. // Required Reflect function.
  51. static void Reflect(AZ::ReflectContext* context);
  52. // Optional functions for defining provided and dependent services.
  53. static void GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent)
  54. {
  55. dependent.push_back(AZ_CRC("TransformService", 0x8ee22c50));
  56. }
  57. // Override from SequenceAgent
  58. AZ::TypeId GetComponentTypeUuid(const AZ::Component& component) const override;
  59. // Get all of the components available on the current entity.
  60. void GetEntityComponents(AZ::Entity::ComponentArrayType& entityComponents) const override;
  61. ////////////////////////////////////////////////////////////////////////
  62. void BuildGameEntity(AZ::Entity* gameEntity) override;
  63. ////////////////////////////////////////////////////////////////////////
  64. private:
  65. // connect and disconnect to all SequenceComponents registered with us
  66. void ConnectAllSequences();
  67. void DisconnectAllSequences();
  68. // set of ids of all unique Entities with SequenceComponent instances connected to this Agent
  69. AZStd::unordered_set<AZ::EntityId> m_sequenceEntityIds;
  70. };
  71. } // namespace Maestro