ExtenderSlotComponent.h 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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 <Components/Slots/SlotComponent.h>
  10. #include <GraphCanvas/Components/Connections/ConnectionBus.h>
  11. #include <GraphCanvas/Components/Slots/Extender/ExtenderSlotBus.h>
  12. #include <GraphCanvas/Components/Nodes/NodeBus.h>
  13. namespace GraphCanvas
  14. {
  15. class ExtenderSlotComponent
  16. : public SlotComponent
  17. , public ExtenderSlotRequestBus::Handler
  18. , public ConnectionNotificationBus::Handler
  19. {
  20. private:
  21. enum SaveVersion
  22. {
  23. InitialVersion = 0,
  24. // Should always be last
  25. Current
  26. };
  27. public:
  28. AZ_COMPONENT(ExtenderSlotComponent, "{A86D8623-9D63-4D19-A4B3-344054FB8435}", SlotComponent);
  29. static void Reflect(AZ::ReflectContext* reflectContext);
  30. static AZ::Entity* CreateExtenderSlot(const AZ::EntityId& nodeId, const ExtenderSlotConfiguration& dataSlotConfiguration);
  31. ExtenderSlotComponent();
  32. ExtenderSlotComponent(const ExtenderSlotConfiguration& dataSlotConfiguration);
  33. ~ExtenderSlotComponent();
  34. // Component
  35. void Init() override;
  36. void Activate() override;
  37. void Deactivate() override;
  38. ////
  39. // SceneMemberNotifications
  40. void OnSceneMemberAboutToSerialize(GraphSerialization& sceneSerialization) override;
  41. ////
  42. // SlotRequestBus
  43. void AddConnectionId(const AZ::EntityId& connectionId, const Endpoint& endpoint) override;
  44. void RemoveConnectionId(const AZ::EntityId& connectionId, const Endpoint& endpoint) override;
  45. void SetNode(const AZ::EntityId& nodeId) override;
  46. SlotConfiguration* CloneSlotConfiguration() const override;
  47. int GetLayoutPriority() const override;
  48. void SetLayoutPriority(int priority) override;
  49. ////
  50. // ConnectionNotificationBus
  51. void OnMoveFinalized(bool isValidConnection) override;
  52. void OnSourceSlotIdChanged(const SlotId& oldSlotId, const SlotId& newSlotId) override;
  53. void OnTargetSlotIdChanged(const SlotId& oldSlotId, const SlotId& newSlotId) override;
  54. ////
  55. // ExtenderSlotComponent
  56. void TriggerExtension() override;
  57. Endpoint ExtendForConnectionProposal(const ConnectionId& connectionId, const Endpoint& endpoint) override;
  58. ////
  59. protected:
  60. // SlotComponent
  61. void OnFinalizeDisplay() override;
  62. ////
  63. private:
  64. ExtenderSlotComponent(const ExtenderSlotComponent&) = delete;
  65. ExtenderSlotComponent& operator=(const ExtenderSlotComponent&) = delete;
  66. void ConstructSlot(GraphModelRequests::ExtensionRequestReason reason);
  67. void EraseSlot();
  68. void CleanupProposedSlot();
  69. bool m_proposedSlot;
  70. AZ::Entity* ConstructConnectionEntity(const Endpoint& sourceEndpoint, const Endpoint& targetEndpoint, bool createModelConnection) override;
  71. AZ::EntityId m_trackedConnectionId;
  72. AZ::EntityId m_createdSlot;
  73. ExtenderId m_extenderId;
  74. };
  75. }