void CreateSubContainerDefaultNodes() { var param = CSParam as BehaviorTree_CustomServiceControlConstructionParams; var miAssist = new CustomMethodInfo(); miAssist.MethodName = "CustomService_" + ValidName; miAssist.DisplayName = "CustomService_" + NodeName; var eTime = new CustomMethodInfo.FunctionParam(); eTime.ParamType = new VariableType(typeof(long), param.CSType); eTime.ParamName = "elapseTime"; miAssist.InParams.Add(eTime); var context = new CustomMethodInfo.FunctionParam(); context.ParamType = new VariableType(typeof(EngineNS.GamePlay.Actor.GCenterData), param.CSType); context.ParamName = "context"; context.Attributes.Add(new EngineNS.Editor.Editor_MacrossMethodParamTypeAttribute(BTCenterDataWarpper.CenterDataType)); miAssist.InParams.Add(context); var nodeType = typeof(CodeDomNode.MethodCustom); var csParam = new CodeDomNode.MethodCustom.MethodCustomConstructParam() { CSType = param.CSType, HostNodesContainer = mLinkedNodesContainer, ConstructParam = "", IsShowProperty = false, MethodInfo = miAssist, }; var node = mLinkedNodesContainer.AddOrigionNode(nodeType, csParam, 0, 100); node.IsDeleteable = false; node.NodeNameAddShowNodeName = false; mLinkedNodesContainer.HostNode = this; }
void InitDelegateMethodInfo() { var param = CSParam as MethodInvoke_DelegateControlConstructionParams; if (param.DelegateMethodInfo == null) { param.DelegateMethodInfo = new CodeDomNode.CustomMethodInfo() { MethodName = param.ParamInfo.ParamName, CSType = param.CSType, }; var method = param.ParamInfo.ParameterType.GetMethod("Invoke"); var methodParams = method.GetParameters(); foreach (var methodParam in methodParams) { var funcParam = new CustomMethodInfo.FunctionParam(); funcParam.HostMethodInfo = param.DelegateMethodInfo; funcParam.ParamName = methodParam.Name; if (methodParam.IsOut) { //var typefullname = methodParam.ParameterType.FullName.Substring(0, methodParam.ParameterType.FullName.Length - 1); //var type = methodParam.ParameterType.Assembly.GetType(typefullname); //funcParam.ParamType = new VariableType(type, param.CSType); funcParam.ParamType = new VariableType(methodParam.ParameterType, param.CSType); param.DelegateMethodInfo.OutParams.Add(funcParam); } else { funcParam.ParamType = new VariableType(methodParam.ParameterType, param.CSType); param.DelegateMethodInfo.InParams.Add(funcParam); } } param.CustomParamStartIndexInDelegateMethodInfo = param.DelegateMethodInfo.InParams.Count; if (method.ReturnType != typeof(void) && method.ReturnType != typeof(System.Threading.Tasks.Task)) { var funcParam = new CustomMethodInfo.FunctionParam(); funcParam.HostMethodInfo = param.DelegateMethodInfo; funcParam.ParamName = "Return"; if (method.ReturnType.BaseType == typeof(System.Threading.Tasks.Task)) { var genericType = method.ReturnType.GetGenericArguments()[0]; funcParam.ParamType = new VariableType(genericType, param.CSType); param.DelegateMethodInfo.IsAsync = true; } else { funcParam.ParamType = new VariableType(method.ReturnType, param.CSType); } param.DelegateMethodInfo.OutParams.Add(funcParam); } else if (method.ReturnType == typeof(System.Threading.Tasks.Task)) { param.DelegateMethodInfo.IsAsync = true; } } }
public async System.Threading.Tasks.Task AddGraphInParam(MethodInvokeParameterControl ctrl, CodeGenerateSystem.Base.LinkInfo info) { if (HostNodesContainer.IsLoading) { return; } if (mLinkedNodesContainer == null) { await InitializeLinkedNodesContainer(); } var param = CSParam as MethodInvoke_DelegateControlConstructionParams; var func = new CustomMethodInfo.FunctionParam(); func.HostMethodInfo = param.DelegateMethodInfo; func.ParamName = info.m_linkFromObjectInfo.HostNodeControl.GCode_GetValueName(info.m_linkFromObjectInfo, null); func.ParamType = new VariableType(info.m_linkFromObjectInfo.HostNodeControl.GCode_GetType(info.m_linkFromObjectInfo, null), param.CSType); int insertIndex = -1; for (int i = 0; i < mChildNodes.Count; i++) { if (mChildNodes[i] == ctrl) { insertIndex++; if (insertIndex >= param.InParamIndexes.Count) { insertIndex = -1; param.DelegateMethodInfo.InParams.Add(func); param.InParamIndexes.Add(ctrl.Id); param.DelegateMethodInfo._OnAddedInParam(func); } else { param.DelegateMethodInfo.InParams.Insert(insertIndex, func); param.InParamIndexes.Insert(insertIndex, ctrl.Id); param.DelegateMethodInfo._OnInsertInParam(insertIndex, func); } break; } else { insertIndex = param.InParamIndexes.IndexOf(mChildNodes[i].Id); } } //for(int i=0; i< mLinkedNodesContainer.CtrlNodeList.Count; i++) //{ // var node = mLinkedNodesContainer.CtrlNodeList[i]; // if(node is MethodCustom) // { // var methodNode = node as MethodCustom; // if(insertIndex < 0) // await methodNode.OnAddedInParam(func); // else // { // await methodNode.OnInsertInParam(insertIndex, func); // } // continue; // } // //else if(node is ReturnCustom) // //{ // // var retNode = node as ReturnCustom; // // retNode.ResetMethodInfo(param.DelegateMethodInfo); // //} //} }