示例#1
0
            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);
            }