Exemple #1
0
 public override CodeExpression GCode_CodeDom_GetValue(LinkPinControl element, GenerateCodeContext_Method context, GenerateCodeContext_PreNode preNodeContext = null)
 {
     if (element == null || element == mCtrlTarget || element == mCtrlTargetOut)
     {
         return(mCtrlTarget.GetLinkedObject(0).GCode_CodeDom_GetValue(mCtrlTarget.GetLinkedPinControl(0), context, null));
     }
     else
     {
         throw new InvalidOperationException();
     }
 }
Exemple #2
0
        public override async System.Threading.Tasks.Task GCode_CodeDom_GenerateCode(CodeTypeDeclaration codeClass, CodeGenerateSystem.Base.LinkPinControl element, CodeGenerateSystem.Base.GenerateCodeContext_Class context)
        {
            if (!mCtrlValueInputHandle.HasLink)
            {
                return;
            }

            System.CodeDom.CodeMemberMethod initMethod = null;

            foreach (var member in codeClass.Members)
            {
                if (member.GetType() == typeof(CodeMemberMethod))
                {
                    var method = member as CodeMemberMethod;
                    if (method.Name == "Init")
                    {
                        initMethod = method;
                    }
                }
            }
            if (initMethod == null)
            {
                initMethod            = new CodeMemberMethod();
                initMethod.Name       = "Init";
                initMethod.Attributes = MemberAttributes.Override | MemberAttributes.Public;
                codeClass.Members.Add(initMethod);
            }

            var linkObj       = mCtrlValueInputHandle.GetLinkedObject(0, true);
            var linkElm       = mCtrlValueInputHandle.GetLinkedPinControl(0, true);
            var methodContext = new GenerateCodeContext_Method(context, initMethod);

            methodContext.InstanceAnimPoseReferenceExpression       = new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), "AnimationPoseProxy");
            methodContext.AnimAssetAnimPoseProxyReferenceExpression = methodContext.InstanceAnimPoseReferenceExpression;
            methodContext.AnimAssetTickHostReferenceExpression      = new CodeThisReferenceExpression();
            await linkObj.GCode_CodeDom_GenerateCode(codeClass, initMethod.Statements, linkElm, methodContext);

            var returnExpression = linkObj.GCode_CodeDom_GetSelfRefrence(mCtrlValueInputHandle, methodContext);


            CodeMethodInvokeExpression createCachedPose = new CodeMethodInvokeExpression(new CodeMethodReferenceExpression(new CodeThisReferenceExpression(), "GetCachedAnimPose"), new CodePrimitiveExpression("CachedPose_" + NodeName));
            //CodeVariableDeclarationStatement cachedPoseRef = new CodeVariableDeclarationStatement(new CodeTypeReference(typeof(EngineNS.Graphics.Mesh.Animation.CGfxAnimationPose)), NodeName);
            //CodeAssignStatement cachedPoseAssign = new CodeAssignStatement();
            //cachedPoseAssign.Left = cachedPoseRef;
            //cachedPoseAssign.Right = createCachedPose;
            //initMethod.Statements.Add(cachedPoseAssign);

            CodeFieldReferenceExpression animPoseField  = new CodeFieldReferenceExpression(new CodeFieldReferenceExpression(returnExpression, "AnimationPoseProxy"), "Pose");
            CodeAssignStatement          animPoseAssign = new CodeAssignStatement();

            animPoseAssign.Left  = animPoseField;
            animPoseAssign.Right = new CodeFieldReferenceExpression(createCachedPose, "CachedAnimationPose");
            initMethod.Statements.Add(animPoseAssign);
        }
Exemple #3
0
        public async Task GCode_CodeDom_GenerateCode_GenerateBlendTree(CodeTypeDeclaration codeClass, CodeStatementCollection codeStatementCollection, LinkPinControl element, GenerateCodeContext_Method context)
        {
            var linkObj = mCtrlValueInputHandle.GetLinkedObject(0, true);
            var linkElm = mCtrlValueInputHandle.GetLinkedPinControl(0, true);

            if (linkObj != null)
            {
                await linkObj.GCode_CodeDom_GenerateCode(codeClass, codeStatementCollection, linkElm, context);

                var blendTreeRootAssign = new CodeAssignStatement();
                blendTreeRootAssign.Left  = new CodeFieldReferenceExpression(new CodeVariableReferenceExpression("state"), "BlendTreeRoot");
                blendTreeRootAssign.Right = linkObj.GCode_CodeDom_GetSelfRefrence(null, null);
                codeStatementCollection.Add(blendTreeRootAssign);
            }
        }
Exemple #4
0
 public override async Task GCode_CodeDom_GenerateCode(CodeTypeDeclaration codeClass, CodeStatementCollection codeStatementCollection, LinkPinControl element, GenerateCodeContext_Method context)
 {
     if (mElemPin.HasLink)
     {
         var linkObj = mElemPin.GetLinkedObject(0);
         await linkObj.GCode_CodeDom_GenerateCode(codeClass, codeStatementCollection, mElemPin.GetLinkedPinControl(0), context);
     }
 }
        public bool IsUseLinkFromParamName()
        {
            if (!mCtrlValue_In.HasLink)
            {
                return(false);
            }
            if (mCtrlValue_In.LinkOpType == CodeGenerateSystem.Base.enLinkOpType.Start)
            {
                return(false);
            }
            var linkObj = mCtrlValue_In.GetLinkedObject(0);

            if (linkObj == null)
            {
                return(false);
            }
            return(linkObj.Pin_UseOrigionParamName(mCtrlValue_In.GetLinkedPinControl(0)));
        }
        public override async System.Threading.Tasks.Task GCode_CodeDom_GenerateCode(CodeTypeDeclaration codeClass, CodeGenerateSystem.Base.LinkPinControl element, CodeGenerateSystem.Base.GenerateCodeContext_Class context)
        {
            if (!mCtrlValueInputHandle.HasLink)
                return;
            System.CodeDom.CodeMemberMethod initMethod = null;

            foreach (var member in codeClass.Members)
            {
                if (member is CodeGenerateSystem.CodeDom.CodeMemberMethod)
                {
                    var method = member as CodeGenerateSystem.CodeDom.CodeMemberMethod;
                    if (method.Name == "Init")
                        initMethod = method;
                }
            }
            if (initMethod == null)
            {
                initMethod = new CodeGenerateSystem.CodeDom.CodeMemberMethod();
                initMethod.Name = "Init";
                initMethod.Attributes = MemberAttributes.Override | MemberAttributes.Public;
                codeClass.Members.Add(initMethod);
            }


            var linkObj = mCtrlValueInputHandle.GetLinkedObject(0, true);
            var linkElm = mCtrlValueInputHandle.GetLinkedPinControl(0, true);
            var methodContext = new GenerateCodeContext_Method(context, initMethod);

            await GenerateCachedPose(codeClass, initMethod.Statements, linkElm, methodContext);

            methodContext.InstanceAnimPoseReferenceExpression = new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), "AnimationPoseProxy");
            methodContext.AnimAssetAnimPoseProxyReferenceExpression = methodContext.InstanceAnimPoseReferenceExpression;
            methodContext.AnimAssetTickHostReferenceExpression = new CodeThisReferenceExpression();
            await linkObj.GCode_CodeDom_GenerateCode(codeClass, initMethod.Statements, linkElm, methodContext);
            var returnExp = linkObj.GCode_CodeDom_GetSelfRefrence(mCtrlValueInputHandle, methodContext);
            if (returnExp != null)
            {
                CodeFieldReferenceExpression animPoseField = new CodeFieldReferenceExpression(new CodeFieldReferenceExpression(returnExp, "AnimationPoseProxy"),"Pose");
                CodeAssignStatement animPoseAssign = new CodeAssignStatement();
                animPoseAssign.Left = animPoseField;
                animPoseAssign.Right = new CodeFieldReferenceExpression(new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), "AnimationPoseProxy"),"Pose");
                initMethod.Statements.Add(animPoseAssign);
            }
        }
Exemple #7
0
 public override Type GCode_GetType(LinkPinControl element, CodeGenerateSystem.Base.GenerateCodeContext_Method context)
 {
     if (element == null || element == mCountOutPin)
     {
         return(typeof(Int32));
     }
     else if (element == mArrayInPin)
     {
         if (mArrayInPin.HasLink)
         {
             return(mArrayInPin.GetLinkedObject(0).GCode_GetType(mArrayInPin.GetLinkedPinControl(0), context));
         }
         return(typeof(object));
     }
     else
     {
         throw new InvalidOperationException();
     }
 }
Exemple #8
0
        public override async System.Threading.Tasks.Task GCode_CodeDom_GenerateCode(CodeTypeDeclaration codeClass, CodeStatementCollection codeStatementCollection, LinkPinControl element, GenerateCodeContext_Method context)
        {
            var basePoseLinkObj = mBasePoseLinkHandle.GetLinkedObject(0, true);
            var basePoseLinkElm = mBasePoseLinkHandle.GetLinkedPinControl(0, true);
            await basePoseLinkObj.GCode_CodeDom_GenerateCode(codeClass, codeStatementCollection, basePoseLinkElm, context);

            var maskPoseLinkObj = mMaskLinkHandle.GetLinkedObject(0, true);
            var maskPoseLinkElm = mMaskLinkHandle.GetLinkedPinControl(0, true);
            await maskPoseLinkObj.GCode_CodeDom_GenerateCode(codeClass, codeStatementCollection, maskPoseLinkElm, context);
        }
 public override void RefreshFromLink(CodeGenerateSystem.Base.LinkPinControl pin, int linkIndex)
 {
     if (ElementType == typeof(object))
     {
         if (pin == mArrayInPin)
         {
             var listType = pin.GetLinkedObject(0, true).GCode_GetType(pin.GetLinkedPinControl(0, true), null);
             ElementType = listType.GetGenericArguments()[0];
         }
         else if (pin == mValueInPin)
         {
             ElementType = pin.GetLinkedObject(0, true).GCode_GetType(pin.GetLinkedPinControl(0, true), null);
         }
         else
         {
             throw new InvalidOperationException();
         }
     }
 }
Exemple #10
0
        public override async System.Threading.Tasks.Task GCode_CodeDom_GenerateCode(CodeTypeDeclaration codeClass, CodeStatementCollection codeStatementCollection, LinkPinControl element, GenerateCodeContext_Method context)
        {
            var baseLinkObj = mBaseLinkHandle.GetLinkedObject(0, true);
            var baseLinkElm = mBaseLinkHandle.GetLinkedPinControl(0, true);

            if (baseLinkObj != null)
            {
                await baseLinkObj.GCode_CodeDom_GenerateCode(codeClass, codeStatementCollection, baseLinkElm, context);
            }
            var additiveLinkObj = mAdditiveLinkHandle.GetLinkedObject(0, true);
            var additiveLinkElm = mAdditiveLinkHandle.GetLinkedPinControl(0, true);

            if (additiveLinkObj != null)
            {
                await additiveLinkObj.GCode_CodeDom_GenerateCode(codeClass, codeStatementCollection, additiveLinkElm, context);
            }

            Type nodeType = typeof(EngineNS.Bricks.Animation.BlendTree.Node.BlendTree_AdditivePose);
            CodeVariableDeclarationStatement stateVarDeclaration = new CodeVariableDeclarationStatement(nodeType, ValidName, new CodeObjectCreateExpression(new CodeTypeReference(nodeType)));

            codeStatementCollection.Add(stateVarDeclaration);
            if (baseLinkObj != null)
            {
                var baseAssign = new CodeAssignStatement();
                baseAssign.Left  = new CodeFieldReferenceExpression(new CodeVariableReferenceExpression(ValidName), "BaseNode");
                baseAssign.Right = baseLinkObj.GCode_CodeDom_GetSelfRefrence(null, null);
                codeStatementCollection.Add(baseAssign);
            }
            if (additiveLinkObj != null)
            {
                var additiveAssign = new CodeAssignStatement();
                additiveAssign.Left  = new CodeFieldReferenceExpression(new CodeVariableReferenceExpression(ValidName), "AdditiveNode");
                additiveAssign.Right = additiveLinkObj.GCode_CodeDom_GetSelfRefrence(null, null);
                codeStatementCollection.Add(additiveAssign);
            }

            var valueEvaluateMethod = new CodeMemberMethod();

            valueEvaluateMethod.Name       = ValidName + "_AlphaEvaluate";
            valueEvaluateMethod.Attributes = MemberAttributes.Public | MemberAttributes.Final;
            valueEvaluateMethod.ReturnType = new CodeTypeReference(typeof(float));
            var            valueEvaluateMethodContex = new GenerateCodeContext_Method(context.ClassContext, valueEvaluateMethod);
            CodeExpression alphaValue = await Helper.GetEvaluateValueExpression(codeClass, valueEvaluateMethodContex, valueEvaluateMethod, mAlphaValueLinkHandle, Alpha);

            valueEvaluateMethod.Statements.Add(new CodeMethodReturnStatement(alphaValue));
            codeClass.Members.Add(valueEvaluateMethod);

            var alphaAssign = new CodeAssignStatement();

            alphaAssign.Left  = new CodeFieldReferenceExpression(new CodeVariableReferenceExpression(ValidName), "EvaluateAlpha");
            alphaAssign.Right = new CodeVariableReferenceExpression(valueEvaluateMethod.Name);
            codeStatementCollection.Add(alphaAssign);
            return;
        }
        public override async System.Threading.Tasks.Task GCode_CodeDom_GenerateCode(CodeTypeDeclaration codeClass, CodeGenerateSystem.Base.LinkPinControl element, CodeGenerateSystem.Base.GenerateCodeContext_Class context)
        {
            if (!mCtrlValueInputHandle.HasLink)
            {
                return;
            }

            var linkObj = mCtrlValueInputHandle.GetLinkedObject(0, true);
            var linkElm = mCtrlValueInputHandle.GetLinkedPinControl(0, true);

            System.CodeDom.CodeMemberMethod method = new CodeMemberMethod();
            method.Name       = "Init";
            method.Attributes = MemberAttributes.Public | MemberAttributes.Override;
            codeClass.Members.Add(method);
            var methodContext = new GenerateCodeContext_Method(context, method);

            methodContext.InstanceAnimPoseReferenceExpression       = new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), "AnimationPoseProxy");
            methodContext.AnimAssetAnimPoseProxyReferenceExpression = methodContext.InstanceAnimPoseReferenceExpression;
            methodContext.AnimAssetTickHostReferenceExpression      = new CodeThisReferenceExpression();
            await linkObj.GCode_CodeDom_GenerateCode(codeClass, method.Statements, linkElm, methodContext);
        }
        public override async System.Threading.Tasks.Task GCode_CodeDom_GenerateCode(CodeTypeDeclaration codeClass, CodeStatementCollection codeStatementCollection, LinkPinControl element, GenerateCodeContext_Method context)
        {
            var srcLinkObj = mSrcPoseLinkHandle.GetLinkedObject(0, true);
            var srcLinkElm = mSrcPoseLinkHandle.GetLinkedPinControl(0, true);
            await srcLinkObj.GCode_CodeDom_GenerateCode(codeClass, codeStatementCollection, srcLinkElm, context);

            var desLinkObj = mDescPoseLinkHandle.GetLinkedObject(0, true);
            var desLinkElm = mDescPoseLinkHandle.GetLinkedPinControl(0, true);
            await desLinkObj.GCode_CodeDom_GenerateCode(codeClass, codeStatementCollection, desLinkElm, context);

            return;
        }
Exemple #13
0
        public override async Task GCode_CodeDom_GenerateCode(CodeTypeDeclaration codeClass, CodeStatementCollection codeStatementCollection, LinkPinControl element, GenerateCodeContext_Method context)
        {
            if (element == null || element == mCtrlMethodPin_Pre)
            {
                var tagLinkedObj = mCtrlTarget.GetLinkedObject(0);
                if (!tagLinkedObj.IsOnlyReturnValue)
                {
                    await tagLinkedObj.GCode_CodeDom_GenerateCode(codeClass, codeStatementCollection, mCtrlTarget.GetLinkedPinControl(0), context);
                }

                var tagExp = tagLinkedObj.GCode_CodeDom_GetValue(mCtrlTarget.GetLinkedPinControl(0), context);

                #region Debug
                // 设置之前的数据
                var debugPreCodes = CodeDomNode.BreakPoint.BeginMacrossDebugCodeStatments(codeStatementCollection);
                foreach (var paramNode in mChildNodes)
                {
                    var ctrl      = paramNode as ExpandNodeChild;
                    var ctrlParam = ctrl.CSParam as ExpandNodeChild.ExpandNodeChildConstructionParams;
                    CodeDomNode.BreakPoint.GetGatherDataValueCodeStatement(debugPreCodes, ctrl.CtrlValue_In.GetLinkPinKeyName(), ctrl.GCode_CodeDom_GetValue(null, null), ctrl.GCode_GetTypeString(null, null), context);
                }
                CodeDomNode.BreakPoint.BreakCodeStatement(codeClass, debugPreCodes, HostNodesContainer.GUID, Id);
                CodeDomNode.BreakPoint.EndMacrossDebugCodeStatements(codeStatementCollection, debugPreCodes);
                #endregion

                foreach (var paramNode in mChildNodes)
                {
                    var ctrl      = paramNode as ExpandNodeChild;
                    var ctrlParam = ctrl.CSParam as ExpandNodeChild.ExpandNodeChildConstructionParams;
                    await ctrl.GCode_CodeDom_GenerateCode(codeClass, codeStatementCollection, null, context);
                }

                #region Debug
                // 赋值之后再收集一次数据
                var debugCodesAfter = CodeDomNode.BreakPoint.BeginMacrossDebugCodeStatments(codeStatementCollection);
                foreach (var paramNode in mChildNodes)
                {
                    var ctrl      = paramNode as ExpandNodeChild;
                    var ctrlParam = ctrl.CSParam as ExpandNodeChild.ExpandNodeChildConstructionParams;
                    CodeDomNode.BreakPoint.GetGatherDataValueCodeStatement(debugCodesAfter, ctrl.CtrlValue_In.GetLinkPinKeyName(), ctrl.GCode_CodeDom_GetValue(null, null), ctrl.GCode_GetTypeString(null, null), context);
                }
                CodeDomNode.BreakPoint.EndMacrossDebugCodeStatements(codeStatementCollection, debugCodesAfter);
                #endregion
            }

            if (context.GenerateNext)
            {
                if (mCtrlMethodPin_Next.HasLink)
                {
                    await mCtrlMethodPin_Next.GetLinkedObject(0).GCode_CodeDom_GenerateCode(codeClass, codeStatementCollection, mCtrlMethodPin_Next.GetLinkedPinControl(0), context);
                }
            }
        }
Exemple #14
0
        public override async System.Threading.Tasks.Task GCode_CodeDom_GenerateCode(System.CodeDom.CodeTypeDeclaration codeClass, System.CodeDom.CodeStatementCollection codeStatementCollection, CodeGenerateSystem.Base.LinkPinControl element, CodeGenerateSystem.Base.GenerateCodeContext_Method context)
        {
            var codeSC = codeStatementCollection;

            foreach (ConditionControl cc in mChildNodes)
            {
                await cc.GCode_CodeDom_GenerateCode(codeClass, codeSC, null, context);

                codeSC = cc.ElseStatementCollection;
            }

            if (mCtrlMethodLink_False.HasLink)
            {
                await mCtrlMethodLink_False.GetLinkedObject(0, false).GCode_CodeDom_GenerateCode(codeClass, codeSC, mCtrlMethodLink_False.GetLinkedPinControl(0, false), context);
            }
        }
        public override async System.Threading.Tasks.Task GCode_CodeDom_GenerateCode(CodeTypeDeclaration codeClass, CodeStatementCollection codeStatementCollection, LinkPinControl element, GenerateCodeContext_Method context)
        {
            var stateMachineRef = context.AnimStateMachineReferenceExpression;

            var linkObj = mCtrlValueLinkHandle.GetLinkedObject(0);
            await linkObj.GCode_CodeDom_GenerateCode(codeClass, codeStatementCollection, element, context);

            var state = context.FirstStateReferenceExpression;
            CodeMethodReferenceExpression methodRef = new CodeMethodReferenceExpression(stateMachineRef, "SetCurrentState");
            var methodInvoke = new CodeGenerateSystem.CodeDom.CodeMethodInvokeExpression(methodRef, new CodeExpression[] { state });

            codeStatementCollection.Add(methodInvoke);

            var stateNode = linkObj as AnimStateControl;

            stateNode.ResetRecursionReachedFlag();
        }
Exemple #16
0
        public override async Task GCode_CodeDom_GenerateCode(CodeTypeDeclaration codeClass, CodeStatementCollection codeStatementCollection, Base.LinkPinControl element, GenerateCodeContext_Method context)
        {
            return;

            if (!mCtrlValueOutputHandle.HasLink)
            {
                return;
            }

            var linkObj = mCtrlValueOutputHandle.GetLinkedObject(0, true);
            var linkElm = mCtrlValueOutputHandle.GetLinkedPinControl(0, true);

            var stateRef = context.AminStateReferenceExpression;

            System.CodeDom.CodeMemberMethod method = new CodeMemberMethod()
            {
                Name       = stateRef.VariableName + EngineNS.Editor.Assist.GetValuedGUIDString(this.Id) + "_Lambda",
                Parameters =
                {
                    new CodeParameterDeclarationExpression(new CodeTypeReference(typeof(EngineNS.Graphics.Mesh.Animation.CGfxAnimationPoseProxy)), "animPoseProxy")
                    ,                                                                                                                              new CodeParameterDeclarationExpression(new CodeTypeReference(typeof(EngineNS.GamePlay.StateMachine.AnimationState)), "state")
                },
                Attributes = MemberAttributes.Public | MemberAttributes.Final,
                ReturnType = new CodeTypeReference(typeof(bool)),
            };
            codeClass.Members.Add(method);

            context.AnimAssetAnimPoseProxyReferenceExpression = new CodeVariableReferenceExpression("animPoseProxy");
            context.AnimAssetTickHostReferenceExpression      = new CodeVariableReferenceExpression("state");
            await linkObj.GCode_CodeDom_GenerateCode(codeClass, method.Statements, linkElm, context);

            var codeReturn = new CodeMethodReturnStatement(new CodePrimitiveExpression(true));

            method.Statements.Add(codeReturn);
            CodeFieldReferenceExpression stateBeginFunctionField       = new CodeFieldReferenceExpression(stateRef, "AnimStateInitializeFunction");
            CodeAssignStatement          stateBeginFunctionFieldAssign = new CodeAssignStatement();

            stateBeginFunctionFieldAssign.Left  = stateBeginFunctionField;
            stateBeginFunctionFieldAssign.Right = new CodeMethodReferenceExpression(null, method.Name);
            codeStatementCollection.Add(stateBeginFunctionFieldAssign);
            return;
        }
        public override async System.Threading.Tasks.Task GCode_CodeDom_GenerateCode(CodeTypeDeclaration codeClass, CodeStatementCollection codeStatementCollection, LinkPinControl element, GenerateCodeContext_Method context)
        {
            var srcLinkObj = mSrcPoseLinkHandle.GetLinkedObject(0, true);
            var srcLinkElm = mSrcPoseLinkHandle.GetLinkedPinControl(0, true);

            if (srcLinkObj != null)
            {
                await srcLinkObj.GCode_CodeDom_GenerateCode(codeClass, codeStatementCollection, srcLinkElm, context);
            }
            var desLinkObj = mDescPoseLinkHandle.GetLinkedObject(0, true);
            var desLinkElm = mDescPoseLinkHandle.GetLinkedPinControl(0, true);

            if (desLinkObj != null)
            {
                await desLinkObj.GCode_CodeDom_GenerateCode(codeClass, codeStatementCollection, desLinkElm, context);
            }

            Type nodeType = typeof(EngineNS.Bricks.Animation.BlendTree.Node.BlendTree_BlendPose);
            CodeVariableDeclarationStatement stateVarDeclaration = new CodeVariableDeclarationStatement(nodeType, ValidName, new CodeObjectCreateExpression(new CodeTypeReference(nodeType)));

            codeStatementCollection.Add(stateVarDeclaration);
            if (srcLinkObj != null)
            {
                var srcAssign = new CodeAssignStatement();
                srcAssign.Left  = new CodeFieldReferenceExpression(new CodeVariableReferenceExpression(ValidName), "SourceNode");
                srcAssign.Right = srcLinkObj.GCode_CodeDom_GetSelfRefrence(null, null);
                codeStatementCollection.Add(srcAssign);
            }
            if (desLinkObj != null)
            {
                var desAssign = new CodeAssignStatement();
                desAssign.Left  = new CodeFieldReferenceExpression(new CodeVariableReferenceExpression(ValidName), "DestinationNode");
                desAssign.Right = desLinkObj.GCode_CodeDom_GetSelfRefrence(null, null);
                codeStatementCollection.Add(desAssign);
            }
            await GenerateValueEvaluateCode(codeClass, mWeightValueLinkHandle, ValidName + "_WeightEvaluate", "EvaluateWeight", codeStatementCollection, context);

            return;
        }
Exemple #18
0
        public override async System.Threading.Tasks.Task GCode_CodeDom_GenerateCode(CodeTypeDeclaration codeClass, CodeStatementCollection codeStatementCollection, LinkPinControl element, GenerateCodeContext_Method context)
        {
            var baseLinkObj = mRefLinkHandle.GetLinkedObject(0, true);
            var baseLinkElm = mRefLinkHandle.GetLinkedPinControl(0, true);

            if (baseLinkObj != null)
            {
                await baseLinkObj.GCode_CodeDom_GenerateCode(codeClass, codeStatementCollection, baseLinkElm, context);
            }
            var additiveLinkObj = mAdditiveLinkHandle.GetLinkedObject(0, true);
            var additiveLinkElm = mAdditiveLinkHandle.GetLinkedPinControl(0, true);

            if (additiveLinkObj != null)
            {
                await additiveLinkObj.GCode_CodeDom_GenerateCode(codeClass, codeStatementCollection, additiveLinkElm, context);
            }

            Type nodeType = typeof(EngineNS.Bricks.Animation.BlendTree.Node.BlendTree_MakeAdditivePose);
            CodeVariableDeclarationStatement stateVarDeclaration = new CodeVariableDeclarationStatement(nodeType, ValidName, new CodeObjectCreateExpression(new CodeTypeReference(nodeType)));

            codeStatementCollection.Add(stateVarDeclaration);
            if (baseLinkObj != null)
            {
                var baseAssign = new CodeAssignStatement();
                baseAssign.Left  = new CodeFieldReferenceExpression(new CodeVariableReferenceExpression(ValidName), "RefNode");
                baseAssign.Right = baseLinkObj.GCode_CodeDom_GetSelfRefrence(null, null);
                codeStatementCollection.Add(baseAssign);
            }
            if (additiveLinkObj != null)
            {
                var additiveAssign = new CodeAssignStatement();
                additiveAssign.Left  = new CodeFieldReferenceExpression(new CodeVariableReferenceExpression(ValidName), "AdditiveNode");
                additiveAssign.Right = additiveLinkObj.GCode_CodeDom_GetSelfRefrence(null, null);
                codeStatementCollection.Add(additiveAssign);
            }
            return;
        }
        public override async System.Threading.Tasks.Task GCode_CodeDom_GenerateCode(CodeTypeDeclaration codeClass, CodeStatementCollection codeStatementCollection, LinkPinControl element, GenerateCodeContext_Method context)
        {
            var inPoseLinkObj = mInPoseLinkHandle.GetLinkedObject(0, true);
            var inPoseLinkElm = mInPoseLinkHandle.GetLinkedPinControl(0, true);
            await inPoseLinkObj.GCode_CodeDom_GenerateCode(codeClass, codeStatementCollection, inPoseLinkElm, context);

            Type nodeType = typeof(EngineNS.Bricks.Animation.BlendTree.Node.BlendTree_CCDIK);
            CodeVariableDeclarationStatement stateVarDeclaration = new CodeVariableDeclarationStatement(nodeType, ValidName, new CodeObjectCreateExpression(new CodeTypeReference(nodeType)));

            codeStatementCollection.Add(stateVarDeclaration);
            if (inPoseLinkObj != null)
            {
                var srcAssign = new CodeAssignStatement();
                srcAssign.Left  = new CodeFieldReferenceExpression(new CodeVariableReferenceExpression(ValidName), "InPoseNode");
                srcAssign.Right = inPoseLinkObj.GCode_CodeDom_GetSelfRefrence(null, null);
                codeStatementCollection.Add(srcAssign);
            }
            var fieldAssign = new CodeAssignStatement();

            fieldAssign.Left  = new CodeFieldReferenceExpression(new CodeVariableReferenceExpression(ValidName), "Iteration");
            fieldAssign.Right = new CodePrimitiveExpression(Iteration);
            codeStatementCollection.Add(fieldAssign);
            fieldAssign       = new CodeAssignStatement();
            fieldAssign.Left  = new CodeFieldReferenceExpression(new CodeVariableReferenceExpression(ValidName), "LimitAngle");
            fieldAssign.Right = new CodePrimitiveExpression(LimitAngle);
            codeStatementCollection.Add(fieldAssign);
            fieldAssign       = new CodeAssignStatement();
            fieldAssign.Left  = new CodeFieldReferenceExpression(new CodeVariableReferenceExpression(ValidName), "EndEffecterBoneName");
            fieldAssign.Right = new CodePrimitiveExpression(EndEffecterBoneName);
            codeStatementCollection.Add(fieldAssign);
            fieldAssign       = new CodeAssignStatement();
            fieldAssign.Left  = new CodeFieldReferenceExpression(new CodeVariableReferenceExpression(ValidName), "RootBoneName");
            fieldAssign.Right = new CodePrimitiveExpression(RootBoneName);
            codeStatementCollection.Add(fieldAssign);
            fieldAssign       = new CodeAssignStatement();
            fieldAssign.Left  = new CodeFieldReferenceExpression(new CodeVariableReferenceExpression(ValidName), "TargetBoneName");
            fieldAssign.Right = new CodePrimitiveExpression(TargetBoneName);
            codeStatementCollection.Add(fieldAssign);

            var targetPositionEvaluateMethod = new CodeMemberMethod();

            targetPositionEvaluateMethod.Name       = ValidName + "_TargetPositionEvaluateMethod";
            targetPositionEvaluateMethod.Attributes = MemberAttributes.Public | MemberAttributes.Final;
            var            valueEvaluateMethodContex = new GenerateCodeContext_Method(context.ClassContext, targetPositionEvaluateMethod);
            CodeExpression valueExpression           = null;
            var            valueLinkObj = mActiveValueLinkHandle.GetLinkedObject(0, true);

            if (valueLinkObj == null)
            {
                valueExpression = new CodeObjectCreateExpression(new CodeTypeReference(typeof(EngineNS.Vector3)), new CodeExpression[] { new CodePrimitiveExpression(0), new CodePrimitiveExpression(0), new CodePrimitiveExpression(0) });
            }
            else
            {
                var valueLinkElm = mActiveValueLinkHandle.GetLinkedPinControl(0, true);
                if (!valueLinkObj.IsOnlyReturnValue)
                {
                    await valueLinkObj.GCode_CodeDom_GenerateCode(codeClass, targetPositionEvaluateMethod.Statements, valueLinkElm, valueEvaluateMethodContex);
                }
                valueExpression = valueLinkObj.GCode_CodeDom_GetValue(valueLinkElm, valueEvaluateMethodContex);
            }

            targetPositionEvaluateMethod.ReturnType = new CodeTypeReference(typeof(EngineNS.Vector3));
            targetPositionEvaluateMethod.Statements.Add(new CodeMethodReturnStatement(valueExpression));
            codeClass.Members.Add(targetPositionEvaluateMethod);

            var targetPositionAssign = new CodeAssignStatement();

            targetPositionAssign.Left  = new CodeFieldReferenceExpression(new CodeVariableReferenceExpression(ValidName), "EvaluateTargetPositionFunc");
            targetPositionAssign.Right = new CodeVariableReferenceExpression(targetPositionEvaluateMethod.Name);
            codeStatementCollection.Add(targetPositionAssign);

            var alphaEvaluateMethod = await Helper.CreateEvaluateMethod(codeClass, ValidName + "AlphaEvaluateMethod", typeof(float), Alpha, mAlphaValueLinkHandle, context);

            var alphaAssign = new CodeAssignStatement();

            alphaAssign.Left  = new CodeFieldReferenceExpression(new CodeVariableReferenceExpression(ValidName), "EvaluateAlphaFunc");
            alphaAssign.Right = new CodeVariableReferenceExpression(alphaEvaluateMethod.Name);
            codeStatementCollection.Add(alphaAssign);
        }
Exemple #20
0
        public override async System.Threading.Tasks.Task GCode_CodeDom_GenerateCode(CodeTypeDeclaration codeClass, CodeStatementCollection codeStatementCollection, CodeGenerateSystem.Base.LinkPinControl element, CodeGenerateSystem.Base.GenerateCodeContext_Method context)
        {
            if (element == mCtrlArrayElement || element == mCtrlArrayIndex || element == mCtrlDicKey || element == mCtrlDicValue)
            {
                return;
            }

            var param = CSParam as ForeachNodeConstructionParams;

            if (mCtrlArrayIn.HasLink)
            {
                var valuedGUID = EngineNS.Editor.Assist.GetValuedGUIDString(this.Id);
                var array      = "param_" + valuedGUID;
                var current    = "current_" + valuedGUID;

                if (!mCtrlArrayIn.GetLinkedObject(0, true).IsOnlyReturnValue)
                {
                    await mCtrlArrayIn.GetLinkedObject(0, true).GCode_CodeDom_GenerateCode(codeClass, codeStatementCollection, mCtrlArrayIn.GetLinkedPinControl(0, true), context);
                }
                var arrayExpression = mCtrlArrayIn.GetLinkedObject(0, true).GCode_CodeDom_GetValue(mCtrlArrayIn.GetLinkedPinControl(0, true), context);

                codeStatementCollection.Add(new CodeVariableDeclarationStatement("var", array, arrayExpression));

                // 调试的代码
                var debugCodes = CodeDomNode.BreakPoint.BeginMacrossDebugCodeStatments(codeStatementCollection);
                CodeDomNode.BreakPoint.BreakCodeStatement(codeClass, debugCodes, HostNodesContainer.GUID, Id);
                CodeDomNode.BreakPoint.EndMacrossDebugCodeStatements(codeStatementCollection, debugCodes);

                var idxStr = $"index_{valuedGUID}";

                string value = "";
                switch (param.LoopValueType)
                {
                case ForeachNodeConstructionParams.enLoopValueType.Dictionary:
                    value  = "        foreach (var " + current + " in " + array + ")\r\n";
                    value += "        {";
                    codeStatementCollection.Add(new CodeSnippetStatement(value));
                    break;

                case ForeachNodeConstructionParams.enLoopValueType.IntPtr:
                {
                    var countStr = $"count_{ valuedGUID}";
                    if (mCountDeclaration == null || !codeStatementCollection.Contains(mCountDeclaration))
                    {
                        var countType = typeof(Int32);
                        if (mCtrlArrayCount.HasLink)
                        {
                            mCountDeclaration = new CodeVariableDeclarationStatement(countType, countStr);
                            mCountDeclaration.InitExpression = new CodeGenerateSystem.CodeDom.CodeCastExpression(countType, mCtrlArrayCount.GetLinkedObject(0, true).GCode_CodeDom_GetValue(mCtrlArrayCount.GetLinkedPinControl(0, true), context));
                            codeStatementCollection.Add(mCountDeclaration);
                        }
                        else
                        {
                            mCountDeclaration = new CodeVariableDeclarationStatement(countType, countStr);
                            mCountDeclaration.InitExpression = new CodeGenerateSystem.CodeDom.CodeCastExpression(countType, new CodePrimitiveExpression(CountDefaultValue));
                            codeStatementCollection.Add(mCountDeclaration);
                        }
                    }

                    value  = $"        for (int {idxStr} = 0; {idxStr} < {countStr}; {idxStr}++)";
                    value += "        {";
                    codeStatementCollection.Add(new CodeSnippetStatement(value));
                    codeStatementCollection.Add(new CodeVariableDeclarationStatement(ElementType, current, new CodeVariableReferenceExpression($"{array}[{idxStr}]")));
                }
                break;

                case ForeachNodeConstructionParams.enLoopValueType.Array:
                    value  = $"        for (int {idxStr} = 0; {idxStr} < {array}.Length; {idxStr}++)";
                    value += "        {";
                    codeStatementCollection.Add(new CodeSnippetStatement(value));
                    codeStatementCollection.Add(new CodeVariableDeclarationStatement(ElementType, current, new CodeVariableReferenceExpression($"{array}[{idxStr}]")));
                    break;

                case ForeachNodeConstructionParams.enLoopValueType.List:
                    value  = $"        for (int {idxStr} = 0; {idxStr} < {array}.Count; {idxStr}++)";
                    value += "        {";
                    codeStatementCollection.Add(new CodeSnippetStatement(value));
                    codeStatementCollection.Add(new CodeVariableDeclarationStatement(ElementType, current, new CodeVariableReferenceExpression($"{array}[{idxStr}]")));
                    break;
                }


                if (mCtrlMethodLink_LoopBody.HasLink)
                {
                    //if (!mCtrlMethodLink_LoopBody.GetLinkedObject(0, false).IsOnlyReturnValue)
                    await mCtrlMethodLink_LoopBody.GetLinkedObject(0, false).GCode_CodeDom_GenerateCode(codeClass, codeStatementCollection, mCtrlMethodLink_LoopBody.GetLinkedPinControl(0, false), context);
                }

                codeStatementCollection.Add(new CodeSnippetStatement("        }"));

                if (context.GenerateNext)
                {
                    if (mCtrlMethodLink_Completed.HasLink)
                    {
                        //if (!mCtrlMethodLink_Completed.GetLinkedObject(0, false).IsOnlyReturnValue)
                        await mCtrlMethodLink_Completed.GetLinkedObject(0, false).GCode_CodeDom_GenerateCode(codeClass, codeStatementCollection, mCtrlMethodLink_Completed.GetLinkedPinControl(0, false), context);
                    }
                }
            }
        }
Exemple #21
0
        //System.CodeDom.CodeVariableDeclarationStatement mVecVariableDeclaration = new System.CodeDom.CodeVariableDeclarationStatement();
        public override async System.Threading.Tasks.Task GCode_CodeDom_GenerateCode(CodeTypeDeclaration codeClass, CodeStatementCollection codeStatementCollection, CodeGenerateSystem.Base.LinkPinControl element, CodeGenerateSystem.Base.GenerateCodeContext_Method context)
        {
            var strValueName = GCode_GetValueName(null, context);

            if (!context.Method.Statements.Contains(mVarDec))
            {
                mVarDec = new CodeAssignStatement(new CodeSnippetExpression(mValueType.FullName + " " + strValueName), CodeGenerateSystem.Program.GetDefaultValueExpressionFromType(mValueType));//, paramCodeName, CodeGenerateSystem.Program.GetDefaultValueExpressionFromType(ParamType));
                context.Method.Statements.Insert(0, mVarDec);
            }
            if (mCtrlvalue_VectorIn.HasLink)
            {
                if (!mCtrlvalue_VectorIn.GetLinkedObject(0, true).IsOnlyReturnValue)
                {
                    await mCtrlvalue_VectorIn.GetLinkedObject(0, true).GCode_CodeDom_GenerateCode(codeClass, codeStatementCollection, mCtrlvalue_VectorIn.GetLinkedPinControl(0, true), context);
                }


                if (!codeStatementCollection.Contains(mAssignCode))
                {
                    mAssignCode = new CodeAssignStatement(new System.CodeDom.CodeVariableReferenceExpression(strValueName), mCtrlvalue_VectorIn.GetLinkedObject(0, true).GCode_CodeDom_GetValue(mCtrlvalue_VectorIn.GetLinkedPinControl(0, true), context));
                    codeStatementCollection.Add(mAssignCode);
                }
            }
            else
            {
                if (!codeStatementCollection.Contains(mAssignCode))
                {
                    mAssignCode      = new CodeAssignStatement();
                    mAssignCode.Left = new System.CodeDom.CodeVariableReferenceExpression(strValueName);
                    var paramExp = new System.CodeDom.CodeExpression[mLinkInDic.Count];
                    var param    = CSParam as AixConstructionParams;
                    if (param != null)
                    {
                        for (int i = 0; i < mLinkInDic.Count; i++)
                        {
                            paramExp[i] = new System.CodeDom.CodePrimitiveExpression(param.Value[i]);
                        }
                    }
                    mAssignCode.Right = new CodeObjectCreateExpression(mValueType, paramExp);
                    codeStatementCollection.Add(mAssignCode);
                }
            }

            foreach (var data in mLinkInDic)
            {
                var linkOI = data.Element;
                if (linkOI.HasLink)
                {
                    if (!linkOI.GetLinkedObject(0, true).IsOnlyReturnValue)
                    {
                        await linkOI.GetLinkedObject(0, true).GCode_CodeDom_GenerateCode(codeClass, codeStatementCollection, linkOI.GetLinkedPinControl(0, true), context);
                    }

                    var fieldRef = new System.CodeDom.CodeFieldReferenceExpression();
                    fieldRef.TargetObject = new CodeVariableReferenceExpression(strValueName);
                    fieldRef.FieldName    = data.KeyName;
                    var statValAss = new System.CodeDom.CodeAssignStatement();
                    statValAss.Left  = fieldRef;
                    statValAss.Right = new CodeGenerateSystem.CodeDom.CodeCastExpression(typeof(float), linkOI.GetLinkedObject(0, true).GCode_CodeDom_GetValue(linkOI.GetLinkedPinControl(0, true), context));
                    codeStatementCollection.Add(statValAss);
                }
            }
        }
        public async System.Threading.Tasks.Task GCode_CodeDom_GenerateMethodCode(CodeTypeDeclaration codeClass, LinkPinControl element, GenerateCodeContext_Class context, MethodGenerateData data)
        {
            var csParam = CSParam as MethodOverrideConstructParam;

            Type[] paramTypes = new Type[csParam.MethodInfo.Params.Count];
            for (int i = 0; i < paramTypes.Length; i++)
            {
                switch (csParam.MethodInfo.Params[i].FieldDirection)
                {
                case FieldDirection.In:
                    if (csParam.MethodInfo.Params[i].IsParamsArray)
                    {
                        throw new InvalidOperationException("未实现");
                    }
                    else
                    {
                        paramTypes[i] = csParam.MethodInfo.Params[i].ParameterType;
                    }
                    break;

                case FieldDirection.Out:
                case FieldDirection.Ref:
                    if (csParam.MethodInfo.Params[i].IsParamsArray)
                    {
                        throw new InvalidOperationException("未实现");
                    }
                    else
                    {
                        paramTypes[i] = csParam.MethodInfo.Params[i].ParameterType.MakeByRefType();
                    }
                    break;
                }
            }
            EngineNS.Editor.MacrossMemberAttribute.enMacrossType macrossType = EngineNS.Editor.MacrossMemberAttribute.enMacrossType.Overrideable;
            if (csParam.MethodInfo.IsFromMacross)
            {
                macrossType |= EngineNS.Editor.MacrossMemberAttribute.enMacrossType.Callable;
            }
            else
            {
                var methodInfo = csParam.MethodInfo.ParentClassType.GetMethod(csParam.MethodInfo.MethodName, System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static, null, paramTypes, null);
                var atts       = methodInfo.GetCustomAttributes(typeof(EngineNS.Editor.MacrossMemberAttribute), false);
                if (atts.Length > 0)
                {
                    var macrossMemberAtt = atts[0] as EngineNS.Editor.MacrossMemberAttribute;
                    macrossType = macrossMemberAtt.MacrossType;
                }
            }

            if (element == null || element == mCtrlMethodPin_Next)
            {
                var methodCode = new CodeGenerateSystem.CodeDom.CodeMemberMethod();
                methodCode.Attributes = MemberAttributes.Override;
                //if (mMethodInfo != null)
                //{
                if (csParam.MethodInfo.IsFamily)
                {
                    methodCode.Attributes |= MemberAttributes.Family;
                }
                if (csParam.MethodInfo.IsFamilyAndAssembly)
                {
                    methodCode.Attributes |= MemberAttributes.FamilyAndAssembly;
                }
                if (csParam.MethodInfo.IsFamilyOrAssembly)
                {
                    methodCode.Attributes |= MemberAttributes.FamilyOrAssembly;
                }
                if (csParam.MethodInfo.IsPublic)
                {
                    methodCode.Attributes |= MemberAttributes.Public;
                }
                //}
                //else
                //    methodCode.Attributes |= MemberAttributes.Public;
                methodCode.Name = NodeName;

                var mcType = EngineNS.Editor.MacrossMemberAttribute.enMacrossType.Unknow;
                if (csParam.MethodInfo.MC_Callable)
                {
                    mcType = mcType | EngineNS.Editor.MacrossMemberAttribute.enMacrossType.Callable;
                }
                if (csParam.MethodInfo.MC_Overrideable)
                {
                    mcType = mcType | EngineNS.Editor.MacrossMemberAttribute.enMacrossType.Overrideable;
                }
                if (mcType != EngineNS.Editor.MacrossMemberAttribute.enMacrossType.Unknow)
                {
                    methodCode.CustomAttributes.Add(new CodeAttributeDeclaration(new CodeTypeReference(typeof(EngineNS.Editor.MacrossMemberAttribute)), new CodeAttributeArgument(new CodePrimitiveExpression(mcType))));
                }

                if (data != null)
                {
                    foreach (var localParam in data.LocalParams)
                    {
                        var defVal  = CodeGenerateSystem.Program.GetDefaultValueFromType(localParam.ParamType);
                        var initExp = Program.GetValueCode(methodCode.Statements, localParam.ParamType, defVal);
                        methodCode.Statements.Add(new CodeVariableDeclarationStatement(localParam.ParamType, localParam.ParamName, initExp));
                    }
                }

                string paramPreStr = "temp___";
                //bool needUnsafeFlag = false;
                string catchParamName = "(";
                foreach (var paramNode in mChildNodes)
                {
                    var paramExp = new System.CodeDom.CodeParameterDeclarationExpression();
                    if (paramNode is MethodInvokeParameterControl)
                    {
                        var pm      = paramNode as MethodInvokeParameterControl;
                        var pmParam = pm.CSParam as MethodInvokeParameterControl.MethodInvokeParameterConstructionParams;
                        paramExp.Direction = pm.ParamFlag;
                        if (pmParam.ParamInfo.ParameterDisplayType != null)
                        {
                            paramExp.Name = paramPreStr + pmParam.ParamInfo.ParamName;
                            paramExp.Type = new CodeTypeReference(pmParam.ParamInfo.ParameterType);
                        }
                        else
                        {
                            paramExp.Name = pmParam.ParamInfo.ParamName;
                            paramExp.Type = new System.CodeDom.CodeTypeReference(pm.ParamType);
                        }

                        //if (pm.ParamType.IsPointer)
                        //    needUnsafeFlag = true;
                    }
                    else if (paramNode is ParamParameterControl)
                    {
                        var pm = paramNode as ParamParameterControl;
                        paramExp.Name = pm.ParamName;
                        paramExp.Type = new System.CodeDom.CodeTypeReference(pm.ParamType);

                        //if (pm.ParamType.IsPointer)
                        //    needUnsafeFlag = true;
                    }
                    else if (paramNode is MethodInvoke_DelegateControl)
                    {
                        var pm = paramNode as MethodInvoke_DelegateControl;
                        paramExp.Name = pm.ParamName;
                        paramExp.Type = new System.CodeDom.CodeTypeReference(pm.ParamType);
                    }

                    methodCode.Parameters.Add(paramExp);
                    catchParamName += paramExp.Type + " " + paramExp.Name + ",";
                }
                // 所有函数全部unsafe
                //if (needUnsafeFlag)
                {
                    //var typeName = MethodReturnType.FullName;
                    methodCode.ReturnType = new CodeTypeReference(MethodReturnType);
                    if (MethodReturnType == typeof(System.Threading.Tasks.Task) || MethodReturnType.BaseType == typeof(System.Threading.Tasks.Task))
                    {
                        methodCode.IsAsync = true;
                    }
                    else
                    {
                        if (EngineNS.Editor.MacrossMemberAttribute.HasType(macrossType, EngineNS.Editor.MacrossMemberAttribute.enMacrossType.Unsafe))
                        {
                            methodCode.IsUnsafe = true;
                        }
                    }
                }
                //else
                //    methodCode.ReturnType = new CodeTypeReference(MethodReturnType);

                catchParamName  = catchParamName.TrimEnd(',');
                catchParamName += ")";

                var tryCatchExp = new System.CodeDom.CodeTryCatchFinallyStatement();
                tryCatchExp.TryStatements.Add(new CodeGenerateSystem.CodeDom.CodeMethodInvokeExpression(new CodeVariableReferenceExpression(context.ScopFieldName), "Begin", new CodeExpression[0]));
                var exName = "ex_" + EngineNS.Editor.Assist.GetValuedGUIDString(Id);
                var cah    = new System.CodeDom.CodeCatchClause(exName);
                cah.Statements.Add(new System.CodeDom.CodeExpressionStatement(
                                       new CodeGenerateSystem.CodeDom.CodeMethodInvokeExpression(
                                           new System.CodeDom.CodeSnippetExpression("EngineNS.Profiler.Log"), "WriteException",
                                           new System.CodeDom.CodeVariableReferenceExpression(exName),
                                           new CodePrimitiveExpression("Macross异常"))));
                tryCatchExp.CatchClauses.Add(cah);
                tryCatchExp.FinallyStatements.Add(new CodeGenerateSystem.CodeDom.CodeMethodInvokeExpression(new CodeVariableReferenceExpression(context.ScopFieldName), "End", new CodeExpression[0]));

                string paramComment = "";
                // 设置out参数默认值
                foreach (var param in csParam.MethodInfo.Params)
                {
                    if (param.ParameterDisplayType != null)
                    {
                        if (param.FieldDirection == FieldDirection.Out)
                        {
                            methodCode.Statements.Add(new CodeAssignStatement(new CodeVariableReferenceExpression(paramPreStr + param.ParamName),
                                                                              new CodePrimitiveExpression(CodeGenerateSystem.Program.GetDefaultValueFromType(param.ParameterType))));
                        }
                        methodCode.Statements.Add(new CodeVariableDeclarationStatement(param.ParameterDisplayType, param.ParamName, new CodeGenerateSystem.CodeDom.CodeCastExpression(param.ParameterDisplayType, new CodeVariableReferenceExpression(paramPreStr + param.ParamName))));
                    }
                    else
                    {
                        if (param.FieldDirection == FieldDirection.Out)
                        {
                            methodCode.Statements.Add(new CodeAssignStatement(new CodeVariableReferenceExpression(param.ParamName),
                                                                              new CodePrimitiveExpression(CodeGenerateSystem.Program.GetDefaultValueFromType(param.ParameterType))));
                        }
                    }

                    paramComment += param.FieldDirection + "," + param.ParameterType.FullName + "|";
                }
                paramComment = paramComment.TrimEnd('|');

                methodCode.Statements.Add(tryCatchExp);
                foreach (var param in csParam.MethodInfo.Params)
                {
                    // ref或out,需要将displayType造成的临时变量再赋给原函数参数
                    if ((param.FieldDirection == FieldDirection.Out || param.FieldDirection == FieldDirection.Ref) && param.ParameterDisplayType != null)
                    {
                        methodCode.Statements.Add(new CodeAssignStatement(new CodeVariableReferenceExpression(paramPreStr + param.ParamName), new CodeGenerateSystem.CodeDom.CodeCastExpression(param.ParameterType, new CodeVariableReferenceExpression(param.ParamName))));
                    }
                }

                if (csParam.MethodInfo.ReturnType != typeof(void) && csParam.MethodInfo.ReturnType != typeof(System.Threading.Tasks.Task))
                {
                    var retVal = CodeGenerateSystem.Program.GetDefaultValueFromType(csParam.MethodInfo.ReturnType);
                    methodCode.Statements.Add(new CodeMethodReturnStatement(new CodePrimitiveExpression(retVal)));
                }


                if (csParam.MethodInfo.IsFromMacross)
                {
                    codeClass.Members.Add(new CodeSnippetTypeMember($"// OverrideStart {csParam.MethodInfo.FuncId.ToString()} {NodeName} {paramComment}"));
                    codeClass.Members.Add(new CodeSnippetTypeMember("#pragma warning disable 1998"));
                    codeClass.Members.Add(methodCode);
                    codeClass.Members.Add(new CodeSnippetTypeMember("#pragma warning restore 1998"));
                    codeClass.Members.Add(new CodeSnippetTypeMember($"// OverrideEnd {csParam.MethodInfo.FuncId.ToString()} {NodeName}"));
                }
                else
                {
                    codeClass.Members.Add(new CodeSnippetTypeMember($"// OverrideStart {NodeName} {paramComment}"));
                    codeClass.Members.Add(new CodeSnippetTypeMember("#pragma warning disable 1998"));
                    codeClass.Members.Add(methodCode);
                    codeClass.Members.Add(new CodeSnippetTypeMember("#pragma warning restore 1998"));
                    codeClass.Members.Add(new CodeSnippetTypeMember($"// OverrideEnd {NodeName}"));
                }

                var methodContext = new CodeGenerateSystem.Base.GenerateCodeContext_Method(context, methodCode);
                // 收集用于调试的数据的代码
                var debugCodes = CodeDomNode.BreakPoint.BeginMacrossDebugCodeStatments(tryCatchExp.TryStatements);
                foreach (var paramNode in mChildNodes)
                {
                    if (paramNode is MethodInvokeParameterControl)
                    {
                        var paramCtrl = paramNode as MethodInvokeParameterControl;
                        CodeDomNode.BreakPoint.GetGatherDataValueCodeStatement(debugCodes, paramCtrl.ParamPin.GetLinkPinKeyName(), paramCtrl.GCode_CodeDom_GetValue(paramCtrl.ParamPin, methodContext), paramCtrl.GCode_GetTypeString(paramCtrl.ParamPin, methodContext), methodContext);
                    }
                    else if (paramNode is ParamParameterControl)
                    {
                        throw new InvalidOperationException();
                    }
                }
                // 断点
                var breakCondStatement = CodeDomNode.BreakPoint.BreakCodeStatement(codeClass, debugCodes, HostNodesContainer.GUID, Id);
                // 设置数据
                foreach (var paramNode in mChildNodes)
                {
                    if (paramNode is MethodInvokeParameterControl)
                    {
                        var paramCtrl = paramNode as MethodInvokeParameterControl;
                        CodeDomNode.BreakPoint.GetSetDataValueCodeStatement(breakCondStatement.TrueStatements, paramCtrl.ParamPin.GetLinkPinKeyName(), paramCtrl.GCode_CodeDom_GetValue(paramCtrl.ParamPin, methodContext), paramCtrl.GCode_GetType(paramCtrl.ParamPin, methodContext));
                    }
                    else if (paramNode is ParamParameterControl)
                    {
                        throw new InvalidOperationException();
                    }
                }
                CodeDomNode.BreakPoint.EndMacrossDebugCodeStatements(tryCatchExp.TryStatements, debugCodes);

                if (mCtrlMethodPin_Next.HasLink)
                {
                    methodContext.ReturnValueType = MethodReturnType;
                    await mCtrlMethodPin_Next.GetLinkedObject(0, false).GCode_CodeDom_GenerateCode(codeClass, tryCatchExp.TryStatements, mCtrlMethodPin_Next.GetLinkedPinControl(0, false), methodContext);
                }
            }
        }