ExecutionSlotComponent.cpp 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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. #include <Components/Slots/Execution/ExecutionSlotComponent.h>
  9. #include <Components/Connections/ConnectionComponent.h>
  10. #include <Components/Slots/SlotConnectionFilterComponent.h>
  11. #include <Components/Slots/Execution/ExecutionSlotLayoutComponent.h>
  12. #include <Components/StylingComponent.h>
  13. #include <GraphCanvas/Components/Connections/ConnectionFilters/ConnectionFilters.h>
  14. namespace GraphCanvas
  15. {
  16. ///////////////////////////
  17. // ExecutionSlotComponent
  18. ///////////////////////////
  19. void ExecutionSlotComponent::Reflect(AZ::ReflectContext* reflectContext)
  20. {
  21. AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(reflectContext);
  22. if (serializeContext)
  23. {
  24. serializeContext->Class<ExecutionSlotComponent, SlotComponent>()
  25. ->Version(1)
  26. ;
  27. }
  28. }
  29. AZ::Entity* ExecutionSlotComponent::CreateExecutionSlot(const AZ::EntityId& nodeId, const SlotConfiguration& slotConfiguration)
  30. {
  31. AZ::Entity* entity = SlotComponent::CreateCoreSlotEntity();
  32. ExecutionSlotComponent* executionSlot = entity->CreateComponent<ExecutionSlotComponent>(slotConfiguration);
  33. entity->CreateComponent<ExecutionSlotLayoutComponent>();
  34. AZStd::string styleClass;
  35. StyledEntityRequestBus::EventResult(styleClass, nodeId, &StyledEntityRequests::GetClass);
  36. entity->CreateComponent<StylingComponent>(Styling::Elements::ExecutionSlot, nodeId, styleClass);
  37. SlotConnectionFilterComponent* connectionFilter = entity->CreateComponent<SlotConnectionFilterComponent>();
  38. SlotTypeFilter* slotTypeFilter = aznew SlotTypeFilter(ConnectionFilterType::Include);
  39. slotTypeFilter->AddSlotType(SlotTypes::ExecutionSlot);
  40. connectionFilter->AddFilter(slotTypeFilter);
  41. ConnectionTypeFilter* connectionTypeFilter = aznew ConnectionTypeFilter(ConnectionFilterType::Include);
  42. switch (executionSlot->GetConnectionType())
  43. {
  44. case ConnectionType::CT_Input:
  45. connectionTypeFilter->AddConnectionType(CT_Output);
  46. break;
  47. case ConnectionType::CT_Output:
  48. connectionTypeFilter->AddConnectionType(CT_Input);
  49. break;
  50. default:
  51. break;
  52. };
  53. connectionFilter->AddFilter(connectionTypeFilter);
  54. return entity;
  55. }
  56. ExecutionSlotComponent::ExecutionSlotComponent()
  57. : SlotComponent(SlotTypes::ExecutionSlot)
  58. {
  59. if (m_slotConfiguration.m_slotGroup == SlotGroups::Invalid)
  60. {
  61. m_slotConfiguration.m_slotGroup = SlotGroups::ExecutionGroup;
  62. }
  63. }
  64. ExecutionSlotComponent::ExecutionSlotComponent(const SlotConfiguration& slotConfiguration)
  65. : SlotComponent(SlotTypes::ExecutionSlot, slotConfiguration)
  66. {
  67. if (m_slotConfiguration.m_slotGroup == SlotGroups::Invalid)
  68. {
  69. m_slotConfiguration.m_slotGroup = SlotGroups::ExecutionGroup;
  70. }
  71. }
  72. ExecutionSlotComponent::~ExecutionSlotComponent()
  73. {
  74. }
  75. SlotConfiguration* ExecutionSlotComponent::CloneSlotConfiguration() const
  76. {
  77. ExecutionSlotConfiguration* executionConfiguration = aznew ExecutionSlotConfiguration();
  78. PopulateSlotConfiguration((*executionConfiguration));
  79. return executionConfiguration;
  80. }
  81. AZ::Entity* ExecutionSlotComponent::ConstructConnectionEntity(const Endpoint& sourceEndpoint, const Endpoint& targetEndpoint, bool createModelConnection)
  82. {
  83. const AZStd::string k_connectionSubStyle = ".logicFlow";
  84. return ConnectionComponent::CreateGeneralConnection(sourceEndpoint, targetEndpoint, createModelConnection, k_connectionSubStyle);
  85. }
  86. }