VersionFlow/Assets/VersionFlow/Editor/LoadingChainGraph/ChainNode.cs
2025-08-08 10:33:30 +08:00

44 lines
1.4 KiB
C#

using System.Collections.Generic;
using UnityEditor.Experimental.GraphView;
using UnityEngine.UIElements;
using VersionFlow.Runtime;
namespace VersionFlow.Editors
{
public class ChainNode : Node
{
private LoadingChain m_chain;
private Dictionary<ABEntity, ABEntityNode> m_existABNodes;
public Port linkAB { get; private set; }
public int EntityCount => m_chain != null ? m_chain.GetEntities().Count : 0;
internal ChainNode(LoadingChain chain, Dictionary<ABEntity, ABEntityNode> existAbNodes, LoadingChainGraphView graph)
{
m_chain = chain;
m_existABNodes = existAbNodes;
this.AddManipulator(new Dragger());
this.Q("collapse-button").RemoveFromHierarchy();
topContainer.Clear();
linkAB = Port.Create<Edge>(Orientation.Horizontal, Direction.Output, Port.Capacity.Multi, typeof(bool));
linkAB.portName = "Entities";
topContainer.Add(linkAB);
RefreshUI(graph);
}
private void RefreshUI(LoadingChainGraphView graph)
{
this.Q<Label>("title-label").text = EntityCount.ToString();
foreach (var entity in m_chain.GetEntities())
{
var abNode = graph.GetEntityNode(entity);
var edge = linkAB.ConnectTo(abNode.linkChain);
graph.AddElement(edge);
}
}
}
}