Пример #1
0
 public override void RefreshFromLink(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();
         }
     }
 }
Пример #2
0
        public override async System.Threading.Tasks.Task GCode_CodeDom_GenerateCode(CodeTypeDeclaration codeClass, CodeStatementCollection codeStatementCollection, LinkPinControl element, GenerateCodeContext_Method context)
        {
            var trueLinkObj = mTrueLinkHandle.GetLinkedObject(0, true);
            var trueLinkElm = mTrueLinkHandle.GetLinkedPinControl(0, true);

            if (trueLinkObj != null)
            {
                await trueLinkObj.GCode_CodeDom_GenerateCode(codeClass, codeStatementCollection, trueLinkElm, context);
            }
            var falseLinkObj = mFalseLinkHandle.GetLinkedObject(0, true);
            var falseLinkElm = mFalseLinkHandle.GetLinkedPinControl(0, true);

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

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

            codeStatementCollection.Add(stateVarDeclaration);

            if (trueLinkObj != null)
            {
                var trueItem = await CreateBlendTree_PoseItemForBlend(codeClass, codeStatementCollection, mTrueLinkHandle, ValidName + "_TruePoseItem", mTrueBlendValueLinkHandle, TrueBlendValue, context);

                var addTrueInvoke = new CodeGenerateSystem.CodeDom.CodeMethodInvokeExpression(new CodeMethodReferenceExpression(new CodeVariableReferenceExpression(ValidName), "Add"), new CodeExpression[] { new CodePrimitiveExpression(1), trueItem });
                codeStatementCollection.Add(addTrueInvoke);
            }
            if (falseLinkObj != null)
            {
                var falseItme = await CreateBlendTree_PoseItemForBlend(codeClass, codeStatementCollection, mFalseLinkHandle, ValidName + "_FalsePoseItem", mFalseBlendValueLinkHandle, FalseBlendValue, context);

                var addFalseInvoke = new CodeGenerateSystem.CodeDom.CodeMethodInvokeExpression(new CodeMethodReferenceExpression(new CodeVariableReferenceExpression(ValidName), "Add"), new CodeExpression[] { new CodePrimitiveExpression(0), falseItme });
                codeStatementCollection.Add(addFalseInvoke);
            }
            var selectMethod = await CreateSelectedMethod(codeClass, ValidName + "_ActiveSelectValue", typeof(int), BoolValue, mActiveLinkHandle, context);

            var selectMethodAssign = new CodeAssignStatement();

            selectMethodAssign.Left  = new CodeFieldReferenceExpression(new CodeVariableReferenceExpression(ValidName), "EvaluateSelectedFunc");
            selectMethodAssign.Right = new CodeVariableReferenceExpression(selectMethod.Name);
            codeStatementCollection.Add(selectMethodAssign);
            return;
        }
Пример #3
0
        public override async Task GCode_CodeDom_GenerateCode(CodeTypeDeclaration codeClass, CodeStatementCollection codeStatementCollection, LinkPinControl element, GenerateCodeContext_Method context)
        {
            var param = CSParam as ExpandNodeChildConstructionParams;

            if (param.EnableSet)
            {
                var paramCodeName = GCode_CodeDom_GetValue(null, context);
                if (element == null)
                {
                    element = mCtrlValue_In;
                }
                if (element.HasLink)
                {
                    if (!element.GetLinkedObject(0).IsOnlyReturnValue)
                    {
                        await element.GetLinkedObject(0).GCode_CodeDom_GenerateCode(codeClass, codeStatementCollection, element.GetLinkedPinControl(0), context);
                    }

                    var codeExp = element.GetLinkedObject(0).GCode_CodeDom_GetValue(element.GetLinkedPinControl(0), context);
                    codeStatementCollection.Add(new CodeAssignStatement(paramCodeName, new CodeGenerateSystem.CodeDom.CodeCastExpression(param.ParamType, codeExp)));
                }
                else
                {
                    var node = ParentNode as CodeDomNode.ExpandNode;
                    if (node.TemplateClassInstance_Show != null)
                    {
                        var    proInfo = node.TemplateClassInstance_Show.GetType().GetProperty(param.ParamName);
                        object classValue;
                        if (proInfo == null)
                        {
                            classValue = CodeGenerateSystem.Program.GetDefaultValueFromType(param.ParamType);
                        }
                        else
                        {
                            classValue = proInfo.GetValue(node.TemplateClassInstance_Show);
                        }

                        Program.GenerateAssignCode(codeStatementCollection, paramCodeName, param.ParamType, classValue);
                    }
                }
            }
        }
Пример #4
0
        public static async System.Threading.Tasks.Task <CodeExpression> GetEvaluateValueExpression(CodeTypeDeclaration codeClass, GenerateCodeContext_Method valueEvaluateMethodContex, CodeMemberMethod valueEvaluateMethod, LinkPinControl linkHandle, object defaultValue)
        {
            CodeExpression valueExpression = null;
            var            valueLinkObj    = linkHandle.GetLinkedObject(0, true);

            if (valueLinkObj == null)
            {
                valueExpression = new CodePrimitiveExpression(defaultValue);
            }
            else
            {
                var valueLinkElm = linkHandle.GetLinkedPinControl(0, true);
                if (!valueLinkObj.IsOnlyReturnValue)
                {
                    await valueLinkObj.GCode_CodeDom_GenerateCode(codeClass, valueEvaluateMethod.Statements, valueLinkElm, valueEvaluateMethodContex);
                }
                valueExpression = valueLinkObj.GCode_CodeDom_GetValue(valueLinkElm, valueEvaluateMethodContex);
            }
            return(valueExpression);
        }