protected override EBTStatus update(Agent pAgent, EBTStatus childStatus) { Debug.Check(childStatus == EBTStatus.BT_RUNNING); EBTStatus result = EBTStatus.BT_SUCCESS; Debug.Check(this.GetNode() is Compute); Compute pComputeNode = (Compute)(this.GetNode()); #if !BEHAVIAC_RELEASE // debug code only if (pComputeNode.m_operator == EOperatorType.E_DIV) { object v = pComputeNode.m_opr2.GetValueObject(pAgent); float f = Convert.ToSingle(v); if (Math.Abs(f) < 0.00001f) { Debug.LogError(string.Format("Compute {0}: right is 0", this.m_id)); } double d = Convert.ToDouble(v); if (Math.Abs(d) < 0.00001) { Debug.LogError(string.Format("Compute {0}: right is 0", this.m_id)); } int n = Convert.ToInt32(v); if (n == 0) { Debug.LogError(string.Format("Compute {0} has right is 0", this.m_id)); } } #endif if (pComputeNode.m_opl != null) { pComputeNode.m_opl.Compute(pAgent, pComputeNode.m_opr1, pComputeNode.m_opr2, pComputeNode.m_operator); } else { result = pComputeNode.update_impl(pAgent, childStatus); } return(result); }
protected override EBTStatus update(Agent pAgent, EBTStatus childStatus) { Debug.Check(childStatus == EBTStatus.BT_RUNNING); EBTStatus result = EBTStatus.BT_SUCCESS; Debug.Check(this.GetNode() is Compute); Compute pComputeNode = (Compute)(this.GetNode()); bool bValid = Compute.EvaluteCompute(pAgent, pComputeNode.m_opl, pComputeNode.m_opr1, pComputeNode.m_opr1_m, pComputeNode.m_operator, pComputeNode.m_opr2, pComputeNode.m_opr2_m); if (!bValid) { result = pComputeNode.update_impl(pAgent, childStatus); } return(result); }
protected override EBTStatus update(Agent pAgent, EBTStatus childStatus) { Debug.Check(childStatus == EBTStatus.BT_RUNNING); EBTStatus result = EBTStatus.BT_SUCCESS; Debug.Check(this.GetNode() is Compute); Compute pComputeNode = (Compute)(this.GetNode()); if (pComputeNode.m_opl != null) { pComputeNode.m_opl.Compute(pAgent, pComputeNode.m_opr1, pComputeNode.m_opr2, pComputeNode.m_operator); } else { result = pComputeNode.update_impl(pAgent, childStatus); } return(result); }
protected override EBTStatus update(Agent pAgent, EBTStatus childStatus) { EBTStatus result = EBTStatus.BT_SUCCESS; Debug.Check(this.GetNode() is Compute); Compute pComputeNode = (Compute)(this.GetNode()); bool bValid = false; object value1 = null; if (pComputeNode.m_opl != null) { if (pComputeNode.m_opr1_m != null) { bValid = true; ParentType pt = pComputeNode.m_opr1_m.GetParentType(); Agent pParent = pAgent; if (pt == ParentType.PT_INSTANCE) { pParent = Agent.GetInstance(pComputeNode.m_opr1_m.GetInstanceNameString(), pParent.GetContextId()); Debug.Check(pParent != null || Utils.IsStaticClass(pComputeNode.m_opr1_m.GetInstanceNameString())); } value1 = pComputeNode.m_opr1_m.run(pParent, pAgent); } else if (pComputeNode.m_opr1 != null) { bValid = true; Agent pParentL = pAgent; Agent pParentR = pAgent; { ParentType pt = pComputeNode.m_opl.GetParentType(); if (pt == ParentType.PT_INSTANCE) { pParentL = Agent.GetInstance(pComputeNode.m_opl.GetInstanceNameString(), pParentL.GetContextId()); Debug.Check(pParentL != null || Utils.IsStaticClass(pComputeNode.m_opl.GetInstanceNameString())); } } { ParentType pt = pComputeNode.m_opr1.GetParentType(); if (pt == ParentType.PT_INSTANCE) { pParentR = Agent.GetInstance(pComputeNode.m_opr1.GetInstanceNameString(), pParentR.GetContextId()); //it is a const if (pParentR == null) { pParentR = pParentL; } } } pComputeNode.m_opl.SetFrom(pParentR, pComputeNode.m_opr1, pParentL); value1 = pComputeNode.m_opl.GetValue(pParentL); } if (pComputeNode.m_opr2_m != null) { bValid = true; ParentType pt = pComputeNode.m_opr2_m.GetParentType(); Agent pParent = pAgent; if (pt == ParentType.PT_INSTANCE) { pParent = Agent.GetInstance(pComputeNode.m_opr2_m.GetInstanceNameString(), pParent.GetContextId()); Debug.Check(pParent != null || Utils.IsStaticClass(pComputeNode.m_opr2_m.GetInstanceNameString())); } object value2 = pComputeNode.m_opr2_m.run(pParent, pAgent); ParentType pt_opl = pComputeNode.m_opl.GetParentType(); Agent pParentOpl = pAgent; if (pt_opl == ParentType.PT_INSTANCE) { pParentOpl = Agent.GetInstance(pComputeNode.m_opl.GetInstanceNameString(), pParentOpl.GetContextId()); Debug.Check(pParentOpl != null || Utils.IsStaticClass(pComputeNode.m_opl.GetInstanceNameString())); } object returnValue = Details.ComputeValue(value1, value2, pComputeNode.m_operator); pComputeNode.m_opl.SetValue(pParentOpl, returnValue); } else if (pComputeNode.m_opr2 != null) { bValid = true; Agent pParentL = pAgent; Agent pParentR = pAgent; { ParentType pt = pComputeNode.m_opl.GetParentType(); if (pt == ParentType.PT_INSTANCE) { pParentL = Agent.GetInstance(pComputeNode.m_opl.GetInstanceNameString(), pParentL.GetContextId()); Debug.Check(pParentL != null || Utils.IsStaticClass(pComputeNode.m_opl.GetInstanceNameString())); } } { ParentType pt = pComputeNode.m_opr2.GetParentType(); if (pt == ParentType.PT_INSTANCE) { pParentR = Agent.GetInstance(pComputeNode.m_opr2.GetInstanceNameString(), pParentR.GetContextId()); //it is a const if (pParentR == null) { pParentR = pParentL; } } } object value2 = pComputeNode.m_opr2.GetValue(pParentR); object returnValue = Details.ComputeValue(value1, value2, pComputeNode.m_operator); pComputeNode.m_opl.SetValue(pParentL, returnValue); } } if (!bValid) { result = pComputeNode.update_impl(pAgent, childStatus); } return(result); }
protected override EBTStatus update(Agent pAgent, EBTStatus childStatus) { EBTStatus status = EBTStatus.BT_SUCCESS; Compute node = (Compute)base.GetNode(); bool flag = false; object obj2 = null; if (node.m_opl != null) { if (node.m_opr1_m != null) { flag = true; ParentType parentType = node.m_opr1_m.GetParentType(); Agent parent = pAgent; if (parentType == ParentType.PT_INSTANCE) { parent = Agent.GetInstance(node.m_opr1_m.GetInstanceNameString(), parent.GetContextId()); } obj2 = node.m_opr1_m.run(parent, pAgent); } else if (node.m_opr1 != null) { flag = true; Agent pAgentTo = pAgent; Agent pAgentFrom = pAgent; if (node.m_opl.GetParentType() == ParentType.PT_INSTANCE) { pAgentTo = Agent.GetInstance(node.m_opl.GetInstanceNameString(), pAgentTo.GetContextId()); } if (node.m_opr1.GetParentType() == ParentType.PT_INSTANCE) { pAgentFrom = Agent.GetInstance(node.m_opr1.GetInstanceNameString(), pAgentFrom.GetContextId()); if (pAgentFrom == null) { pAgentFrom = pAgentTo; } } node.m_opl.SetFrom(pAgentFrom, node.m_opr1, pAgentTo); obj2 = node.m_opl.GetValue(pAgentTo); } if (node.m_opr2_m != null) { flag = true; ParentType type4 = node.m_opr2_m.GetParentType(); Agent instance = pAgent; if (type4 == ParentType.PT_INSTANCE) { instance = Agent.GetInstance(node.m_opr2_m.GetInstanceNameString(), instance.GetContextId()); } object obj3 = node.m_opr2_m.run(instance, pAgent); ParentType type5 = node.m_opl.GetParentType(); Agent agent5 = pAgent; if (type5 == ParentType.PT_INSTANCE) { agent5 = Agent.GetInstance(node.m_opl.GetInstanceNameString(), agent5.GetContextId()); } object v = Details.ComputeValue(obj2, obj3, node.m_operator); node.m_opl.SetValue(agent5, v); } else if (node.m_opr2 != null) { flag = true; Agent agent6 = pAgent; Agent agent7 = pAgent; if (node.m_opl.GetParentType() == ParentType.PT_INSTANCE) { agent6 = Agent.GetInstance(node.m_opl.GetInstanceNameString(), agent6.GetContextId()); } if (node.m_opr2.GetParentType() == ParentType.PT_INSTANCE) { agent7 = Agent.GetInstance(node.m_opr2.GetInstanceNameString(), agent7.GetContextId()); if (agent7 == null) { agent7 = agent6; } } object obj5 = node.m_opr2.GetValue(agent7); object obj6 = Details.ComputeValue(obj2, obj5, node.m_operator); node.m_opl.SetValue(agent6, obj6); } } if (!flag) { status = node.update_impl(pAgent, childStatus); } return(status); }
protected override EBTStatus update(Agent pAgent, EBTStatus childStatus) { EBTStatus result = EBTStatus.BT_SUCCESS; Compute compute = (Compute)base.GetNode(); bool flag = false; object value = null; if (compute.m_opl != null) { if (compute.m_opr1_m != null) { flag = true; ParentType parentType = compute.m_opr1_m.GetParentType(); Agent agent = pAgent; if (parentType == ParentType.PT_INSTANCE) { agent = Agent.GetInstance(compute.m_opr1_m.GetInstanceNameString(), agent.GetContextId()); } value = compute.m_opr1_m.run(agent, pAgent); } else if (compute.m_opr1 != null) { flag = true; Agent agent2 = pAgent; Agent agent3 = pAgent; ParentType parentType2 = compute.m_opl.GetParentType(); if (parentType2 == ParentType.PT_INSTANCE) { agent2 = Agent.GetInstance(compute.m_opl.GetInstanceNameString(), agent2.GetContextId()); } ParentType parentType3 = compute.m_opr1.GetParentType(); if (parentType3 == ParentType.PT_INSTANCE) { agent3 = Agent.GetInstance(compute.m_opr1.GetInstanceNameString(), agent3.GetContextId()); if (agent3 == null) { agent3 = agent2; } } compute.m_opl.SetFrom(agent3, compute.m_opr1, agent2); value = compute.m_opl.GetValue(agent2); } if (compute.m_opr2_m != null) { flag = true; ParentType parentType4 = compute.m_opr2_m.GetParentType(); Agent agent4 = pAgent; if (parentType4 == ParentType.PT_INSTANCE) { agent4 = Agent.GetInstance(compute.m_opr2_m.GetInstanceNameString(), agent4.GetContextId()); } object value2 = compute.m_opr2_m.run(agent4, pAgent); ParentType parentType5 = compute.m_opl.GetParentType(); Agent agent5 = pAgent; if (parentType5 == ParentType.PT_INSTANCE) { agent5 = Agent.GetInstance(compute.m_opl.GetInstanceNameString(), agent5.GetContextId()); } object v = Details.ComputeValue(value, value2, compute.m_operator); compute.m_opl.SetValue(agent5, v); } else if (compute.m_opr2 != null) { flag = true; Agent agent6 = pAgent; Agent agent7 = pAgent; ParentType parentType6 = compute.m_opl.GetParentType(); if (parentType6 == ParentType.PT_INSTANCE) { agent6 = Agent.GetInstance(compute.m_opl.GetInstanceNameString(), agent6.GetContextId()); } ParentType parentType7 = compute.m_opr2.GetParentType(); if (parentType7 == ParentType.PT_INSTANCE) { agent7 = Agent.GetInstance(compute.m_opr2.GetInstanceNameString(), agent7.GetContextId()); if (agent7 == null) { agent7 = agent6; } } object value3 = compute.m_opr2.GetValue(agent7); object v2 = Details.ComputeValue(value, value3, compute.m_operator); compute.m_opl.SetValue(agent6, v2); } } if (!flag) { result = compute.update_impl(pAgent, childStatus); } return(result); }