using System.Collections; using System.Collections.Generic; using UnityEngine; using XNode; //维修场景预制件管理器 用于规划维修步骤 管理维修步骤 public class RepairPrefabManager : MonoBehaviour { [Tooltip("步骤规划编辑器")] public NodeGraph Procress; [Tooltip("拆卸时终步骤节点")] public StepNode tearDownLastNode; [Tooltip("安装时终步骤节点")] public StepNode installLastNode; Dictionary> keyValues = new Dictionary>(); List stepRelations = new List(); // Start is called before the first frame update void Start() { for (int i = 0; i < Procress.nodes.Count; i++) { foreach (NodePort item in Procress.nodes[i].Outputs) { if (item.IsConnected) { string nodeName = (string)item.node.GetValue(null); if (keyValues.ContainsKey(nodeName)) { Debug.LogError($"存在重复的步骤名称{nodeName},跳过重复节点"); continue; } keyValues.Add(nodeName, new List()); List Connections = item.GetConnections();//获取当前节点 后续的所有节点 for (int j = 0; j < Connections.Count; j++) { string postpositionNodeName = (string)Connections[j].node.GetValue(null); keyValues[nodeName].Add(postpositionNodeName); stepRelations.Add(new StepRelation(nodeName, postpositionNodeName)); } } } }//梳理流程关系 ProcessManager.Instance.InitStepRelationDic(stepRelations, (string)tearDownLastNode.GetValue(null), (string)installLastNode.GetValue(null));//注入流程管理器 } }