DynamicSlotComponent.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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/Component/Component.h>
  10. #include <GraphCanvas/Components/Slots/SlotBus.h>
  11. #include <GraphCanvas/Components/SceneBus.h>
  12. #include <ScriptCanvas/Core/Endpoint.h>
  13. #include <ScriptCanvas/Core/NodeBus.h>
  14. #include <ScriptCanvas/GraphCanvas/DynamicSlotBus.h>
  15. namespace ScriptCanvasEditor
  16. {
  17. class DynamicSlotComponent
  18. : public AZ::Component
  19. , public GraphCanvas::SceneMemberNotificationBus::Handler
  20. , public ScriptCanvas::NodeNotificationsBus::Handler
  21. , public DynamicSlotRequestBus::Handler
  22. {
  23. public:
  24. AZ_COMPONENT(DynamicSlotComponent, "{977152B6-1A7D-49A4-8E70-644AFAD1586A}");
  25. static void Reflect(AZ::ReflectContext* serializeContext);
  26. DynamicSlotComponent();
  27. DynamicSlotComponent(GraphCanvas::SlotGroup slotGroup);
  28. ~DynamicSlotComponent() override = default;
  29. // AZ::Component
  30. void Init() override;
  31. void Activate() override;
  32. void Deactivate() override;
  33. ////
  34. // GraphCanvas::SceneMemberNotificationBus
  35. void OnSceneSet(const AZ::EntityId& sceneId) override;
  36. ////
  37. // ScriptCanvas::EditorNodeNotificationBus
  38. void OnSlotAdded(const ScriptCanvas::SlotId& slotId) override;
  39. void OnSlotRemoved(const ScriptCanvas::SlotId& slotId) override;
  40. ////
  41. // DynamicSlotRequestBus
  42. void OnUserDataChanged() override;
  43. void StartQueueSlotUpdates() override;
  44. void StopQueueSlotUpdates() override;
  45. ////
  46. protected:
  47. virtual void ConfigureGraphCanvasSlot(const ScriptCanvas::Slot* slot, const GraphCanvas::SlotId& graphCanvasSlotId);
  48. const AZ::EntityId& GetScriptCanvasNodeId() const { return m_scriptCanvasNodeId; }
  49. private:
  50. void HandleSlotAdded(const ScriptCanvas::Endpoint& endpoint);
  51. GraphCanvas::SlotGroup m_slotGroup;
  52. AZ::EntityId m_scriptCanvasNodeId;
  53. bool m_queueUpdates;
  54. AZStd::unordered_set<ScriptCanvas::Endpoint> m_queuedEndpoints;
  55. };
  56. }