Exemple #1
0
        async Task GenerateLAPostProcess(CategoryItem item, IMacrossOperationContainer linkCtrl, CodeTypeDeclaration macrossClass, CodeGenerateSystem.Base.GenerateCodeContext_Class codeClassContext, LAStatesBridge lAStatesBridge)
        {
            var nodesContainer = await linkCtrl.GetNodesContainer(item, true);

            foreach (var ctrl in nodesContainer.NodesControl.CtrlNodeList)
            {
                ctrl.ReInitForGenericCode();
            }
            var constructLAGraphMethod = lAStatesBridge.ConstructLAGraphMethod;

            foreach (var ctrl in nodesContainer.NodesControl.CtrlNodeList)
            {
                if ((ctrl is CodeDomNode.Animation.LAFinalPoseControl))
                {
                    var laFinalPoseCtrl = ctrl as LAFinalPoseControl;
                    var initMethod      = new CodeMemberMethod();
                    initMethod.Name       = "InitPostProcess";
                    initMethod.Attributes = MemberAttributes.Public;
                    var param = new CodeParameterDeclarationExpression(new CodeTypeReference(typeof(EngineNS.Bricks.Animation.Pose.CGfxSkeletonPose)), "inPose");
                    initMethod.Parameters.Add(param);
                    macrossClass.Members.Add(initMethod);
                    var methodContext = new GenerateCodeContext_Method(codeClassContext, initMethod);
                    await laFinalPoseCtrl.GCode_CodeDom_GenerateCode_GeneratePostProcessBlendTree(macrossClass, initMethod.Statements, null, methodContext);

                    var initLambaAssign = new CodeAssignStatement();
                    initLambaAssign.Left  = new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), "InitializePostProcessFunc");
                    initLambaAssign.Right = new CodeVariableReferenceExpression(initMethod.Name);
                    constructLAGraphMethod.Statements.Add(initLambaAssign);
                }
            }
        }
        async Task GenerateLATransitions(CategoryItem item, IMacrossOperationContainer linkCtrl, CodeTypeDeclaration macrossClass, CodeGenerateSystem.Base.GenerateCodeContext_Class codeClassContext, LFSMStatesBridge lFSMStatesBridge)
        {
            var nodesContainer = await linkCtrl.GetNodesContainer(item, true);

            foreach (var ctrl in nodesContainer.NodesControl.CtrlNodeList)
            {
                ctrl.ReInitForGenericCode();
            }
            foreach (var ctrl in nodesContainer.NodesControl.CtrlNodeList)
            {
                if (ctrl is LogicFSMNodeControl)
                {
                    var laClipCtrl = ctrl as LogicFSMNodeControl;
                    await laClipCtrl.GCode_CodeDom_GenerateCode_GenerateLATransitions(macrossClass, null, codeClassContext, lFSMStatesBridge);
                }
            }
            for (int i = 0; i < item.Children.Count; ++i)
            {
                await GenerateLATransitions(item.Children[i], linkCtrl, macrossClass, codeClassContext, lFSMStatesBridge);
            }
        }
        async Task GenerateBehaviorTree(CategoryItem item, IMacrossOperationContainer linkCtrl, CodeTypeDeclaration macrossClass, CodeGenerateSystem.Base.GenerateCodeContext_Class codeClassContext, BehaviorTreeBridge behaviorTreeBridge)
        {
            var btLinkCtrl     = linkCtrl as McBTMacrossLinkControl;
            var nodesContainer = await linkCtrl.GetNodesContainer(item, true, true);

            foreach (var ctrl in nodesContainer.NodesControl.CtrlNodeList)
            {
                ctrl.ReInitForGenericCode();
                if (ctrl is BehaviorTree_BTCenterDataControl)
                {
                    var cc = ctrl as BehaviorTree_BTCenterDataControl;
                    cc.BTCenterDataWarpper.CenterDataName = btLinkCtrl.BTCenterDataWarpper.CenterDataName;
                }
            }
            var constructBTGraphMethod = behaviorTreeBridge.ConstructBTGraphMethod;

            foreach (var ctrl in nodesContainer.NodesControl.CtrlNodeList)
            {
                if ((ctrl is BehaviorTree_RootControl))
                {
                    var btRootCtrl = ctrl as BehaviorTree_RootControl;
                    var initMethod = new CodeMemberMethod();
                    initMethod.Name       = "InitBehaviorTree";
                    initMethod.Attributes = MemberAttributes.Public;
                    //var param = new CodeParameterDeclarationExpression(new CodeTypeReference(typeof(EngineNS.Bricks.Animation.Pose.CGfxSkeletonPose)), "inPose");
                    //initMethod.Parameters.Add(param);
                    macrossClass.Members.Add(initMethod);
                    var methodContext = new GenerateCodeContext_Method(codeClassContext, initMethod);
                    await btRootCtrl.GCode_CodeDom_GenerateCode_GenerateBehaviorTree(macrossClass, initMethod.Statements, null, methodContext);

                    var initLambaAssign = new CodeAssignStatement();
                    initLambaAssign.Left  = new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), "InitBehaviorTreeFunc");
                    initLambaAssign.Right = new CodeVariableReferenceExpression(initMethod.Name);
                    constructBTGraphMethod.Statements.Add(initLambaAssign);
                    break;
                }
            }
        }
        async Task GenerateLAStates(CategoryItem item, IMacrossOperationContainer linkCtrl, CodeTypeDeclaration macrossClass, CodeGenerateSystem.Base.GenerateCodeContext_Class codeClassContext, LFSMStatesBridge lFSMStatesBridge)
        {
            var nodesContainer = await linkCtrl.GetNodesContainer(item, true);

            lFSMStatesBridge.LFSMStateNodesContainerDic.Add(item.Name, nodesContainer.NodesControl);
            foreach (var ctrl in nodesContainer.NodesControl.CtrlNodeList)
            {
                ctrl.ReInitForGenericCode();
            }
            foreach (var ctrl in nodesContainer.NodesControl.CtrlNodeList)
            {
                if (ctrl is LogicFSMNodeControl)
                {
                    var laClipCtrl = ctrl as LogicFSMNodeControl;
                    await laClipCtrl.GCode_CodeDom_GenerateCode_GenerateLAStates(macrossClass, null, codeClassContext, lFSMStatesBridge);

                    //await laClipCtrl.GCode_CodeDom_GenerateCode_GenerateLogicGraphCustom(macrossClass, null, codeClassContext, lFSMStatesBridge);
                    await laClipCtrl.GCode_CodeDom_GenerateCode_GenerateLAClipStateEvent(macrossClass, null, codeClassContext, lFSMStatesBridge);

                    for (int i = 0; i < laClipCtrl.TransitionNodes.Count; ++i)
                    {
                        var laTranstionCtrl = laClipCtrl.TransitionNodes[i] as LFSMTransitionNodeControl;
                        var linkCtrls       = laClipCtrl.TransitionNodes[i].GetLinkPinInfos();
                        for (int j = 0; j < linkCtrls.Length; ++j)
                        {
                            for (int k = 0; k < linkCtrls[j].GetLinkInfosCount(); ++k)
                            {
                                var info       = linkCtrls[j].GetLinkInfo(k);
                                var title      = GetTransitionName(info);
                                var mcLinkCtrl = linkCtrl as McLogicFSMLinkControl;
                                var container  = await mcLinkCtrl.GetLATransitionGraph(info);

                                for (int m = 0; m < container.CtrlNodeList.Count; ++m)
                                {
                                    if (container.CtrlNodeList[m] is LFSMFinalTransitionResultControl)
                                    {
                                        lFSMStatesBridge.LFSMTransitionFinalResultNodesDic.Add(title, container.CtrlNodeList[m]);
                                    }
                                }
                                container = await mcLinkCtrl.GetTransitionExecuteGraph(info);

                                for (int m = 0; m < container.CtrlNodeList.Count; ++m)
                                {
                                    if (container.CtrlNodeList[m] is CodeDomNode.MethodCustom)
                                    {
                                        lFSMStatesBridge.LFSMTransitionExecuteNodesDic.Add(title, container.CtrlNodeList[m]);
                                    }
                                }
                            }
                        }
                    }
                }
                if (ctrl is LogicFSMGraphNodeControl)
                {
                    var laGraphCtrl = ctrl as LogicFSMGraphNodeControl;
                    if (laGraphCtrl.IsSelfGraphNode)
                    {
                        var laTranstionLinkCtrl = laGraphCtrl.CtrlValueLinkHandle as LFSMTransitionLinkControl;
                        for (int k = 0; k < laTranstionLinkCtrl.GetLinkInfosCount(); ++k)
                        {
                            var info       = laTranstionLinkCtrl.GetLinkInfo(k);
                            var title      = GetTransitionName(info);
                            var mcLinkCtrl = linkCtrl as McLogicFSMLinkControl;
                            var container  = await mcLinkCtrl.GetLATransitionGraph(info);

                            for (int m = 0; m < container.CtrlNodeList.Count; ++m)
                            {
                                if (container.CtrlNodeList[m] is LFSMFinalTransitionResultControl)
                                {
                                    lFSMStatesBridge.LFSMTransitionFinalResultNodesDic.Add(title, container.CtrlNodeList[m]);
                                }
                            }
                            container = await mcLinkCtrl.GetTransitionExecuteGraph(info);

                            for (int m = 0; m < container.CtrlNodeList.Count; ++m)
                            {
                                if (container.CtrlNodeList[m] is CodeDomNode.MethodCustom)
                                {
                                    lFSMStatesBridge.LFSMTransitionExecuteNodesDic.Add(title, container.CtrlNodeList[m]);
                                }
                            }
                        }
                    }
                }
            }
            for (int i = 0; i < item.Children.Count; ++i)
            {
                await GenerateLAStates(item.Children[i], linkCtrl, macrossClass, codeClassContext, lFSMStatesBridge);
            }
        }