public BaseNodeProxy CreateProxy(BaseNode node) { if (node == null) { //组合节点必须有子节点 string msg = "BehaviorTreeManager.CreateProxy() \n Create nodeProxy failed,node is null."; LogError(msg); throw new Exception(msg); } //重置节点状态 if (node.Status != ENodeStatus.None) { node.Status = ENodeStatus.None; } IProxyManager proxyManager = null; for (int i = 0; i < m_ProxyManagers.Count; i++) { IProxyManager tempProxyManager = m_ProxyManagers[i]; ProxyData proxyData = tempProxyManager.GetProxyData(node.ClassType); if (proxyData != null) { proxyManager = tempProxyManager; break; } } if (proxyManager == null) { string msg = $"BehaviorTreeManager.CreateProxy() \n Create nodeProxy failed,proxyManager is null."; LogError(msg); throw new Exception(msg); } BaseNodeProxy nodeProxy = proxyManager.CreateProxy(); if (nodeProxy == null) { string msg = $"BehaviorTreeManager.CreateProxy() \n Create nodeProxy failed,ClassType:{node.ProxyData.ClassType}"; LogError(msg); throw new Exception(msg); } nodeProxy.BeginInit(); nodeProxy.SetNode(node); nodeProxy.SetData(node.NodeData); nodeProxy.SetContext(node.Context); nodeProxy.EndInit(); return(nodeProxy); }