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); 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); } }
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); }
async Task GenerateLAStateMachine(IMacrossOperationContainer linkCtrl, CodeTypeDeclaration macrossClass, CodeGenerateSystem.Base.GenerateCodeContext_Class codeClassContext, LFSMStatesBridge lFSMStatesBridge) { var constructLAGraphMethod = lFSMStatesBridge.ConstructLFSMGraphMethod; await EngineNS.Thread.AsyncDummyClass.DummyFunc(); lFSMStatesBridge.LFSMStateMachineName = "LFSM_StateMachine"; var createStateMachineMethodInvoke = new CodeGenerateSystem.CodeDom.CodeMethodInvokeExpression(new CodeMethodReferenceExpression(new CodeThisReferenceExpression(), "CrteateStateMachine"), new CodeExpression[] { new CodePrimitiveExpression(lFSMStatesBridge.LFSMStateMachineName) }); CodeVariableDeclarationStatement stateVarDeclaration = new CodeVariableDeclarationStatement(typeof(EngineNS.Bricks.FSM.SFSM.StackBasedFiniteStateMachine), lFSMStatesBridge.LFSMStateMachineName, createStateMachineMethodInvoke); constructLAGraphMethod.Statements.Add(stateVarDeclaration); }
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); } }
public override async Task GenerateMethods(IMacrossOperationContainer linkCtrl, CodeTypeDeclaration macrossClass, CodeGenerateSystem.Base.GenerateCodeContext_Class codeClassContext) { await base.GenerateMethods(linkCtrl, macrossClass, codeClassContext); Category graphCategory; CodeMemberMethod constructGraphMethod = null; foreach (var member in macrossClass.Members) { if (member is CodeGenerateSystem.CodeDom.CodeMemberMethod) { var method = member as CodeGenerateSystem.CodeDom.CodeMemberMethod; if (method.Name == "ConstructLFSMGraph") { constructGraphMethod = method; } } } if (constructGraphMethod == null) { constructGraphMethod = new CodeGenerateSystem.CodeDom.CodeMemberMethod(); constructGraphMethod.Name = "ConstructLFSMGraph"; constructGraphMethod.Attributes = MemberAttributes.Override | MemberAttributes.Public; macrossClass.Members.Add(constructGraphMethod); } var statesBridge = new LFSMStatesBridge(); statesBridge.ConstructLFSMGraphMethod = constructGraphMethod; await GenerateLAStateMachine(linkCtrl, macrossClass, codeClassContext, statesBridge); if (linkCtrl.MacrossOpPanel.CategoryDic.TryGetValue(McLogicFSMMacrossPanel.LogicStateMachineCategoryName, out graphCategory)) { var linkNodes = graphCategory.Items; for (int i = 0; i < linkNodes.Count; i++) { var graph = linkNodes[i]; await GenerateLAStates(graph, linkCtrl, macrossClass, codeClassContext, statesBridge); } for (int i = 0; i < linkNodes.Count; i++) { var graph = linkNodes[i]; await GenerateLATransitions(graph, linkCtrl, macrossClass, codeClassContext, statesBridge); } } }
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); } }
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); 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); var createCachedPose = new CodeGenerateSystem.CodeDom.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); }
async System.Threading.Tasks.Task GenerateCode(CodeTypeDeclaration codeClass, CodeGenerateSystem.Base.GenerateCodeContext_Class classContext) { if (mLinkedNodesContainer == null) { await InitializeLinkedNodesContainer(); } var methodContext = new CodeGenerateSystem.Base.GenerateCodeContext_Method(classContext, null); methodContext.IsDelegateInvokeMethod = true; methodContext.DelegateMethodName = MethodName; var assist = this.HostNodesContainer.HostControl as Macross.NodesControlAssist; Macross.NodesControlAssist.ProcessData processData; if (assist.ProcessDataDic.TryGetValue(mLinkedNodesContainer.GUID, out processData)) { methodContext.MethodGenerateData = new CodeGenerateSystem.Base.MethodGenerateData(); foreach (var item in processData.FunctionVariableCategoryItems) { var pro = item.PropertyShowItem as Macross.VariableCategoryItemPropertys; if (pro == null) { continue; } var paramData = new CodeGenerateSystem.Base.MethodLocalParamData() { ParamType = pro.VariableType.GetActualType(), ParamName = pro.VariableName, }; methodContext.MethodGenerateData.LocalParams.Add(paramData); } } foreach (var ctrl in mLinkedNodesContainer.CtrlNodeList) { if (ctrl is CodeDomNode.MethodCustom) { await ctrl.GCode_CodeDom_GenerateCode(codeClass, null, null, methodContext); } } }
async Task GenerateLAStateMachine(CategoryItem item, IMacrossOperationContainer linkCtrl, CodeTypeDeclaration macrossClass, CodeGenerateSystem.Base.GenerateCodeContext_Class codeClassContext, LAStatesBridge lAStatesBridge) { var constructLAGraphMethod = lAStatesBridge.ConstructLAGraphMethod; await EngineNS.Thread.AsyncDummyClass.DummyFunc(); lAStatesBridge.LAStateMachineName = item.Name; var createLAStateMachineMethodInvoke = new CodeGenerateSystem.CodeDom.CodeMethodInvokeExpression(new CodeMethodReferenceExpression(new CodeThisReferenceExpression(), "CreateLAStateMachine"), new CodeExpression[] { new CodePrimitiveExpression(lAStatesBridge.LAStateMachineName) }); CodeVariableDeclarationStatement stateVarDeclaration = new CodeVariableDeclarationStatement(typeof(EngineNS.Bricks.Animation.AnimStateMachine.LogicAnimationStateMachine), lAStatesBridge.LAStateMachineName, createLAStateMachineMethodInvoke); var layerTypeAssign = new CodeAssignStatement(); layerTypeAssign.Left = new CodeFieldReferenceExpression(new CodeVariableReferenceExpression(item.Name), "LayerType"); var layerProp = item.PropertyShowItem as LAAnimLayerCategoryItemPropertys; layerTypeAssign.Right = new CodeFieldReferenceExpression(new CodeTypeReferenceExpression(typeof(EngineNS.Bricks.Animation.AnimStateMachine.AnimLayerType)), layerProp.LayerType.ToString()); lAStatesBridge.LAStateMachine = new CodeVariableReferenceExpression(item.Name); constructLAGraphMethod.Statements.Add(stateVarDeclaration); constructLAGraphMethod.Statements.Add(layerTypeAssign); }
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 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; } } }
public override async Task GenerateMethods(IMacrossOperationContainer linkCtrl, CodeTypeDeclaration macrossClass, CodeGenerateSystem.Base.GenerateCodeContext_Class codeClassContext) { await base.GenerateMethods(linkCtrl, macrossClass, codeClassContext); Category graphCategory; CodeGenerateSystem.CodeDom.CodeMemberMethod constructLAGraphMethod = null; foreach (var member in macrossClass.Members) { if (member is CodeGenerateSystem.CodeDom.CodeMemberMethod) { var method = member as CodeGenerateSystem.CodeDom.CodeMemberMethod; if (method.Name == "ConstructBTGraph") { constructLAGraphMethod = method; } } } if (constructLAGraphMethod == null) { constructLAGraphMethod = new CodeGenerateSystem.CodeDom.CodeMemberMethod(); constructLAGraphMethod.Name = "ConstructBTGraph"; constructLAGraphMethod.Attributes = MemberAttributes.Override | MemberAttributes.Public; macrossClass.Members.Add(constructLAGraphMethod); } if (linkCtrl.MacrossOpPanel.CategoryDic.TryGetValue(McBTMacrossPanel.BehaviorTreeCategoryName, out graphCategory)) { for (int k = 0; k < graphCategory.Items.Count; ++k) { var linkNodes = graphCategory.Items[k].Children; var btBridge = new BehaviorTreeBridge(); btBridge.ConstructBTGraphMethod = constructLAGraphMethod; await GenerateBehaviorTree(graphCategory.Items[k], linkCtrl, macrossClass, codeClassContext, btBridge); } } }
public GenerateCodeContext_Method(GenerateCodeContext_Class classContext, System.CodeDom.CodeMemberMethod method) { ClassContext = classContext; mMethod = method; }