コード例 #1
0
ファイル: Properties.cs プロジェクト: i17c/behaviac
        public object GetValue(Agent parent, Agent parHolder)
        {
            if (parent == null || m_bIsConst)
            {
                return(this.GetDefaultValue());
            }
            else
            {
                if (this.m_memberBase != null)
                {
#if !BEHAVIAC_RELEASE
                    ParentType pt = this.m_memberBase.GetParentType();
                    if (pt == ParentType.PT_INSTANCE)
                    {
                        Agent pInstance = Agent.GetInstance(this.GetInstanceNameString(), parHolder.GetContextId());
                        Debug.Check(Object.ReferenceEquals(pInstance, parHolder));
                    }
#endif//
                    if (this.m_pt == ParentType.PT_INSTANCE)
                    {
                        Agent pInstance = Agent.GetInstance(this.GetInstanceNameString(), parHolder.GetContextId());
                        parHolder = pInstance;
                    }

                    object pVariable = this.m_memberBase.Get(parHolder);

                    return(pVariable);
                }
                else
                {
                    return(parHolder.GetVariable(this.m_varaibleName));
                }
            }
        }
コード例 #2
0
 public void onexit_action(Agent pAgent, EBTStatus status)
 {
     this.onexit(pAgent, status);
     this.SetReturnStatus(EBTStatus.BT_INVALID);
     if (this.m_node != null)
     {
         bool flag = this.m_node.exitaction_impl(pAgent);
         if (flag || this.m_node.m_exitAction != null)
         {
             Agent agent = pAgent;
             if (!flag && this.m_node.m_exitAction != null)
             {
                 ParentType parentType = this.m_node.m_exitAction.GetParentType();
                 if (parentType == ParentType.PT_INSTANCE)
                 {
                     agent = Agent.GetInstance(this.m_node.m_exitAction.GetInstanceNameString(), agent.GetContextId());
                 }
             }
             if (!flag && this.m_node.m_exitAction != null)
             {
                 BehaviorTask.ms_lastExitStatus_ = status;
                 this.m_node.m_exitAction.run(agent, pAgent);
                 BehaviorTask.ms_lastExitStatus_ = EBTStatus.BT_INVALID;
             }
         }
     }
     this.UnInstantiatePars(pAgent);
 }
コード例 #3
0
ファイル: Properties.cs プロジェクト: i17c/behaviac
        public void SetValue(Agent parent, object v)
        {
            Debug.Check(!Object.ReferenceEquals(parent, null));
            Debug.Check(!m_bIsConst);

            string staticClassName = null;

            if (this.m_memberBase != null)
            {
#if !BEHAVIAC_RELEASE
                ParentType pt = this.m_memberBase.GetParentType();

                if (pt == ParentType.PT_INSTANCE)
                {
                    Agent pInstance = Agent.GetInstance(this.GetInstanceNameString(), parent.GetContextId());
                    Debug.Check(Object.ReferenceEquals(pInstance, parent));
                }
#endif//
                if (this.m_pt == ParentType.PT_INSTANCE)
                {
                    Agent pInstance = Agent.GetInstance(this.GetInstanceNameString(), parent.GetContextId());
                    parent = pInstance;
                }

                //don't update member as v is indeed the member itsef!
                //this.m_memberBase.Set(parent, v);

                if (this.m_memberBase.ISSTATIC())
                {
                    staticClassName = this.m_memberBase.GetClassNameString();
                }
            }

            parent.SetVariableRegistry(this.m_memberBase, this.m_varaibleName, v, staticClassName, this.m_variableId);
        }
コード例 #4
0
ファイル: Waitframes.cs プロジェクト: midgithub/notes
        protected virtual int GetFrames(Agent pAgent)
        {
            if (this.m_frames_var != null)
            {
                Debug.Check(this.m_frames_var != null);
                int frames = (int)this.m_frames_var.GetValue(pAgent);

                return(frames);
            }
            else if (this.m_frames_method != null)
            {
                ParentType pt      = this.m_frames_method.GetParentType();
                Agent      pParent = pAgent;
                if (pt == ParentType.PT_INSTANCE)
                {
                    pParent = Agent.GetInstance(this.m_frames_method.GetInstanceNameString(), pParent.GetContextId());
                    Debug.Check(pParent != null || Utils.IsStaticClass(this.m_frames_method.GetInstanceNameString()));
                }

                int frames = (int)this.m_frames_method.run(pParent, pAgent);

                return(frames);
            }

            return(0);
        }
コード例 #5
0
            protected override EBTStatus update(Agent pAgent, EBTStatus childStatus)
            {
                Debug.Check(this.GetNode() is Action, "node is not an Action");
                Action pActionNode = (Action)(this.GetNode());

                if (!this.CheckPredicates(pAgent))
                {
                    return(pActionNode.m_resultPreconditionFail);
                }

                EBTStatus result = EBTStatus.BT_SUCCESS;

                if (pActionNode.m_method != null)
                {
                    ParentType pt      = pActionNode.m_method.GetParentType();
                    Agent      pParent = pAgent;
                    if (pt == ParentType.PT_INSTANCE)
                    {
                        pParent = Agent.GetInstance(pActionNode.m_method.GetInstanceNameString(), pParent.GetContextId());
                        Debug.Check(pParent != null || Utils.IsStaticClass(pActionNode.m_method.GetInstanceNameString()));
                    }

                    int nodeId = this.GetId();
                    SetNodeId(nodeId);

                    object returnValue = pActionNode.m_method.run(pParent, pAgent);

                    if (pActionNode.m_resultOption != EBTStatus.BT_INVALID)
                    {
                        result = pActionNode.m_resultOption;
                    }
                    else if (pActionNode.m_resultFunctor != null)
                    {
                        ParentType pt1 = pActionNode.m_resultFunctor.GetParentType();
                        Agent      pParentCheckResult = pAgent;
                        if (pt1 == ParentType.PT_INSTANCE)
                        {
                            pParentCheckResult = Agent.GetInstance(pActionNode.m_resultFunctor.GetInstanceNameString(), pParent.GetContextId());
                            Debug.Check(pParentCheckResult != null || Utils.IsStaticClass(pActionNode.m_resultFunctor.GetInstanceNameString()));
                        }

                        result = (EBTStatus)pActionNode.m_resultFunctor.run(pParentCheckResult, pAgent, returnValue);
                    }
                    else
                    {
                        Debug.Check(returnValue is EBTStatus, "method's return type is not EBTStatus");
                        result = (EBTStatus)returnValue;
                    }

                    ClearNodeId();
                }
                else
                {
                    result = pActionNode.update_impl(pAgent, childStatus);
                }

                return(result);
            }
コード例 #6
0
        public static TAGENT GetInstance <TAGENT>(string agentInstanceName, int contextId) where TAGENT : Agent, new()
        {
            string text = agentInstanceName;

            if (string.IsNullOrEmpty(text))
            {
                text = typeof(TAGENT).get_FullName();
            }
            Agent instance = Agent.GetInstance(text, contextId);

            return((TAGENT)((object)instance));
        }
コード例 #7
0
        public Agent GetParentAgent(Agent pAgent)
        {
            Agent pParent = pAgent;

            if (!string.IsNullOrEmpty(this.m_instanceName) && this.m_instanceName != "Self")
            {
                pParent = Agent.GetInstance(this.m_instanceName, pParent.GetContextId());
                Debug.Check(pParent != null || Utils.IsStaticClass(this.m_instanceName));
            }

            return(pParent);
        }
コード例 #8
0
 public static int GetRandomValue(CMethodBase method, Agent pAgent)
 {
     if (method != null)
     {
         ParentType parentType = method.GetParentType();
         Agent      parent     = pAgent;
         if (parentType == ParentType.PT_INSTANCE)
         {
             parent = Agent.GetInstance(method.GetInstanceNameString(), parent.GetContextId());
         }
         return((int)method.run(parent, pAgent));
     }
     return(FrameRandom.Random(RandomMax));
 }
コード例 #9
0
        public static bool DoCompare(Agent pAgent, VariableComparator comparator, Property opl, CMethodBase opl_m, Property opr)
        {
            bool bResult = false;

            if (opl != null)
            {
                Agent      agent_left = pAgent;
                ParentType pt         = opl.GetParentType();
                if (pt == ParentType.PT_INSTANCE)
                {
                    agent_left = Agent.GetInstance(opl.GetInstanceNameString(), agent_left.GetContextId());
                    Debug.Check(agent_left != null || Utils.IsStaticClass(opl.GetInstanceNameString()));
                }

                Agent agent_right = pAgent;
                pt = opr.GetParentType();
                if (pt == ParentType.PT_INSTANCE)
                {
                    agent_right = Agent.GetInstance(opr.GetInstanceNameString(), agent_left.GetContextId());
                    Debug.Check(agent_right != null || Utils.IsStaticClass(opr.GetInstanceNameString()));
                }

                bResult = comparator.Execute(agent_left, agent_right);
            }
            else if (opl_m != null)
            {
                ParentType pt         = opl_m.GetParentType();
                Agent      agent_left = pAgent;
                if (pt == ParentType.PT_INSTANCE)
                {
                    agent_left = Agent.GetInstance(opl_m.GetInstanceNameString(), agent_left.GetContextId());
                    Debug.Check(agent_left != null || Utils.IsStaticClass(opl_m.GetInstanceNameString()));
                }

                object returnValue = opl_m.run(agent_left, pAgent);

                Agent agent_right = pAgent;
                pt = opr.GetParentType();
                if (pt == ParentType.PT_INSTANCE)
                {
                    agent_right = Agent.GetInstance(opr.GetInstanceNameString(), agent_right.GetContextId());
                    Debug.Check(agent_right != null || Utils.IsStaticClass(opr.GetInstanceNameString()));
                }

                bResult = comparator.Execute(returnValue, agent_left, agent_right);
            }

            return(bResult);
        }
コード例 #10
0
        public void onexit_action(Agent pAgent, EBTStatus status)
        {
            this.onexit(pAgent, status);
            this.SetReturnStatus(EBTStatus.BT_INVALID);

            if (this.m_node != null)
            {
                bool exitImpl = ((BehaviorNode)(this.m_node)).exitaction_impl(pAgent);

                if (exitImpl || this.m_node.m_exitAction != null)
                {
                    Agent pParent = pAgent;

                    if (!exitImpl && this.m_node.m_exitAction != null)
                    {
                        ParentType pt = this.m_node.m_exitAction.GetParentType();
                        if (pt == ParentType.PT_INSTANCE)
                        {
                            pParent = Agent.GetInstance(this.m_node.m_exitAction.GetInstanceNameString(), pParent.GetContextId());
                            Debug.Check(pParent != null || Utils.IsStaticClass(this.m_node.m_exitAction.GetInstanceNameString()));
                        }
                    }

                    if (!exitImpl && this.m_node.m_exitAction != null)
                    {
                        ms_lastExitStatus_ = status;
                        this.m_node.m_exitAction.run(pParent, pAgent);

                        ms_lastExitStatus_ = EBTStatus.BT_INVALID;
                    }
                }
            }

            this.UnInstantiatePars(pAgent);
#if !BEHAVIAC_RELEASE
            if (Config.IsLoggingOrSocketing)
            {
                //BEHAVIAC_PROFILE_DEBUGBLOCK("Debug", true);
                if (status == EBTStatus.BT_SUCCESS)
                {
                    CHECK_BREAKPOINT(pAgent, this, "exit", EActionResult.EAR_success);
                }
                else
                {
                    CHECK_BREAKPOINT(pAgent, this, "exit", EActionResult.EAR_failure);
                }
            }
#endif
        }
コード例 #11
0
ファイル: Assignment.cs プロジェクト: TonyDongGuaPi/joework
            protected override EBTStatus update(Agent pAgent, EBTStatus childStatus)
            {
                EBTStatus  result     = EBTStatus.BT_SUCCESS;
                Assignment assignment = (Assignment)base.GetNode();

                if (assignment.m_opr_m != null && assignment.m_opl != null)
                {
                    ParentType parentType = assignment.m_opr_m.GetParentType();
                    Agent      agent      = pAgent;
                    if (parentType == ParentType.PT_INSTANCE)
                    {
                        agent = Agent.GetInstance(assignment.m_opr_m.GetInstanceNameString(), agent.GetContextId());
                    }
                    object     v           = assignment.m_opr_m.run(agent, pAgent);
                    ParentType parentType2 = assignment.m_opl.GetParentType();
                    Agent      agent2      = pAgent;
                    if (parentType2 == ParentType.PT_INSTANCE)
                    {
                        agent2 = Agent.GetInstance(assignment.m_opl.GetInstanceNameString(), agent2.GetContextId());
                    }
                    assignment.m_opl.SetValue(agent2, v);
                }
                else if (assignment.m_opr != null && assignment.m_opl != null)
                {
                    Agent      agent3      = pAgent;
                    Agent      agent4      = pAgent;
                    ParentType parentType3 = assignment.m_opl.GetParentType();
                    if (parentType3 == ParentType.PT_INSTANCE)
                    {
                        agent3 = Agent.GetInstance(assignment.m_opl.GetInstanceNameString(), agent3.GetContextId());
                    }
                    ParentType parentType4 = assignment.m_opr.GetParentType();
                    if (parentType4 == ParentType.PT_INSTANCE)
                    {
                        agent4 = Agent.GetInstance(assignment.m_opr.GetInstanceNameString(), agent4.GetContextId());
                        if (agent4 == null)
                        {
                            agent4 = agent3;
                        }
                    }
                    assignment.m_opl.SetFrom(agent4, assignment.m_opr, agent3);
                }
                else
                {
                    result = assignment.update_impl(pAgent, childStatus);
                }
                return(result);
            }
コード例 #12
0
ファイル: Property.cs プロジェクト: isoundy000/wzry-1
 public object GetValue(Agent parent, Agent parHolder)
 {
     if ((parent == null) || this.m_bIsConst)
     {
         return(this.GetDefaultValue());
     }
     if (this.m_memberBase == null)
     {
         return(parHolder.GetVariable(this.m_varaibleName));
     }
     if (this.m_pt == ParentType.PT_INSTANCE)
     {
         parHolder = Agent.GetInstance(this.GetInstanceNameString(), parHolder.GetContextId());
     }
     return(this.m_memberBase.Get(parHolder));
 }
コード例 #13
0
            protected override EBTStatus update(Agent pAgent, EBTStatus childStatus)
            {
                Action action = (Action)base.GetNode();

                if (!this.CheckPredicates(pAgent))
                {
                    return(action.m_resultPreconditionFail);
                }
                EBTStatus result;

                if (action.m_method != null)
                {
                    ParentType parentType = action.m_method.GetParentType();
                    Agent      agent      = pAgent;
                    if (parentType == ParentType.PT_INSTANCE)
                    {
                        agent = Agent.GetInstance(action.m_method.GetInstanceNameString(), agent.GetContextId());
                    }
                    int id = base.GetId();
                    Action.ActionTask.SetNodeId(id);
                    object obj = action.m_method.run(agent, pAgent);
                    if (action.m_resultOption != EBTStatus.BT_INVALID)
                    {
                        result = action.m_resultOption;
                    }
                    else if (action.m_resultFunctor != null)
                    {
                        ParentType parentType2 = action.m_resultFunctor.GetParentType();
                        Agent      parent      = pAgent;
                        if (parentType2 == ParentType.PT_INSTANCE)
                        {
                            parent = Agent.GetInstance(action.m_resultFunctor.GetInstanceNameString(), agent.GetContextId());
                        }
                        result = (EBTStatus)((int)action.m_resultFunctor.run(parent, pAgent, obj));
                    }
                    else
                    {
                        result = (EBTStatus)((int)obj);
                    }
                    Action.ActionTask.ClearNodeId();
                }
                else
                {
                    result = action.update_impl(pAgent, childStatus);
                }
                return(result);
            }
コード例 #14
0
ファイル: Property.cs プロジェクト: isoundy000/wzry-1
        public void SetValue(Agent parent, object v)
        {
            string staticClassName = null;

            if (this.m_memberBase != null)
            {
                if (this.m_pt == ParentType.PT_INSTANCE)
                {
                    parent = Agent.GetInstance(this.GetInstanceNameString(), parent.GetContextId());
                }
                if (this.m_memberBase.ISSTATIC())
                {
                    staticClassName = this.m_memberBase.GetClassNameString();
                }
            }
            parent.SetVariableRegistry(this.m_memberBase, this.m_varaibleName, v, staticClassName, this.m_variableId);
        }
コード例 #15
0
        public static Agent GetParentAgent(Agent pAgent, string instanceName)
        {
            Agent pParent = pAgent;

            if (!string.IsNullOrEmpty(instanceName) && instanceName != "Self")
            {
                pParent = Agent.GetInstance(instanceName, (pParent != null) ? pParent.GetContextId() : 0);

                if (pAgent != null && pParent == null && !Utils.IsStaticClass(instanceName))
                {
                    pParent = pAgent.GetVariable <Agent>(instanceName);
                    Debug.Check(pParent != null);
                }
            }

            return(pParent);
        }
コード例 #16
0
 public object GetValue(Agent parent)
 {
     if (parent == null || this.m_bIsConst)
     {
         return(this.GetDefaultValue());
     }
     if (this.m_memberBase != null)
     {
         if (this.m_pt == ParentType.PT_INSTANCE)
         {
             Agent instance = Agent.GetInstance(this.GetInstanceNameString(), parent.GetContextId());
             parent = instance;
         }
         return(this.m_memberBase.Get(parent));
     }
     return(parent.GetVariable(this.m_varaibleName));
 }
コード例 #17
0
ファイル: Action.cs プロジェクト: wujiangu/wanshiwu0.1
            protected override EBTStatus update(Agent pAgent, EBTStatus childStatus)
            {
                Action node = (Action)base.GetNode();

                if (!this.CheckPredicates(pAgent))
                {
                    return(node.m_resultPreconditionFail);
                }
                EBTStatus resultOption = EBTStatus.BT_SUCCESS;

                if (node.m_method == null)
                {
                    return(node.update_impl(pAgent, childStatus));
                }
                ParentType parentType = node.m_method.GetParentType();
                Agent      parent     = pAgent;

                if (parentType == ParentType.PT_INSTANCE)
                {
                    parent = Agent.GetInstance(node.m_method.GetInstanceNameString(), parent.GetContextId());
                }
                SetNodeId(base.GetId());
                object param = node.m_method.run(parent, pAgent);

                if (node.m_resultOption != EBTStatus.BT_INVALID)
                {
                    resultOption = node.m_resultOption;
                }
                else if (node.m_resultFunctor != null)
                {
                    ParentType type2    = node.m_resultFunctor.GetParentType();
                    Agent      instance = pAgent;
                    if (type2 == ParentType.PT_INSTANCE)
                    {
                        instance = Agent.GetInstance(node.m_resultFunctor.GetInstanceNameString(), parent.GetContextId());
                    }
                    resultOption = (EBTStatus)((int)node.m_resultFunctor.run(instance, pAgent, param));
                }
                else
                {
                    resultOption = (EBTStatus)((int)param);
                }
                ClearNodeId();
                return(resultOption);
            }
コード例 #18
0
ファイル: WaitFrames.cs プロジェクト: TonyDongGuaPi/joework
 protected virtual int GetFrames(Agent pAgent)
 {
     if (this.m_frames_var != null)
     {
         return((int)this.m_frames_var.GetValue(pAgent));
     }
     if (this.m_frames_method != null)
     {
         ParentType parentType = this.m_frames_method.GetParentType();
         Agent      agent      = pAgent;
         if (parentType == ParentType.PT_INSTANCE)
         {
             agent = Agent.GetInstance(this.m_frames_method.GetInstanceNameString(), agent.GetContextId());
         }
         return((int)this.m_frames_method.run(agent, pAgent));
     }
     return(0);
 }
コード例 #19
0
            protected override EBTStatus update(Agent pAgent, EBTStatus childStatus)
            {
                EBTStatus  status = EBTStatus.BT_SUCCESS;
                Assignment node   = (Assignment)base.GetNode();

                if ((node.m_opr_m != null) && (node.m_opl != null))
                {
                    ParentType parentType = node.m_opr_m.GetParentType();
                    Agent      parent     = pAgent;
                    if (parentType == ParentType.PT_INSTANCE)
                    {
                        parent = Agent.GetInstance(node.m_opr_m.GetInstanceNameString(), parent.GetContextId());
                    }
                    object     v        = node.m_opr_m.run(parent, pAgent);
                    ParentType type2    = node.m_opl.GetParentType();
                    Agent      instance = pAgent;
                    if (type2 == ParentType.PT_INSTANCE)
                    {
                        instance = Agent.GetInstance(node.m_opl.GetInstanceNameString(), instance.GetContextId());
                    }
                    node.m_opl.SetValue(instance, v);
                    return(status);
                }
                if ((node.m_opr != null) && (node.m_opl != null))
                {
                    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_opr.GetParentType() == ParentType.PT_INSTANCE)
                    {
                        pAgentFrom = Agent.GetInstance(node.m_opr.GetInstanceNameString(), pAgentFrom.GetContextId());
                        if (pAgentFrom == null)
                        {
                            pAgentFrom = pAgentTo;
                        }
                    }
                    node.m_opl.SetFrom(pAgentFrom, node.m_opr, pAgentTo);
                    return(status);
                }
                return(node.update_impl(pAgent, childStatus));
            }
コード例 #20
0
            public static int GetRandomValue(CMethodBase method, Agent pAgent)
            {
                int result;

                if (method != null)
                {
                    ParentType parentType = method.GetParentType();
                    Agent      agent      = pAgent;
                    if (parentType == ParentType.PT_INSTANCE)
                    {
                        agent = Agent.GetInstance(method.GetInstanceNameString(), agent.GetContextId());
                    }
                    result = (int)method.run(agent, pAgent);
                }
                else
                {
                    result = (int)FrameRandom.Random(CompositeStochastic.CompositeStochasticTask.RandomMax);
                }
                return(result);
            }
コード例 #21
0
        public bool onenter_action(Agent pAgent)
        {
            //this needs to be before onenter
            this.InstantiatePars(pAgent);

            bool bResult = this.onenter(pAgent);

            if (this.m_node != null)
            {
                if (!((BehaviorNode)(this.m_node)).enteraction_impl(pAgent))
                {
                    if (this.m_node.m_enterAction != null)
                    {
                        ParentType pt      = this.m_node.m_enterAction.GetParentType();
                        Agent      pParent = pAgent;
                        if (pt == ParentType.PT_INSTANCE)
                        {
                            pParent = Agent.GetInstance(this.m_node.m_enterAction.GetInstanceNameString(), pParent.GetContextId());
                            Debug.Check(pParent != null || Utils.IsStaticClass(this.m_node.m_enterAction.GetInstanceNameString()));
                        }

                        this.m_node.m_enterAction.run(pParent, pAgent);
                    }
                }
            }

            if (!bResult)
            {
                this.UnInstantiatePars(pAgent);
            }
            else
            {
#if !BEHAVIAC_RELEASE
                //BEHAVIAC_PROFILE_DEBUGBLOCK("Debug", true);

                CHECK_BREAKPOINT(pAgent, this, "enter", bResult ? EActionResult.EAR_success : EActionResult.EAR_failure);
#endif
            }

            return(bResult);
        }
コード例 #22
0
        public bool onenter_action(Agent pAgent)
        {
            this.InstantiatePars(pAgent);
            bool flag = this.onenter(pAgent);

            if (((this.m_node != null) && !this.m_node.enteraction_impl(pAgent)) && (this.m_node.m_enterAction != null))
            {
                ParentType parentType = this.m_node.m_enterAction.GetParentType();
                Agent      parent     = pAgent;
                if (parentType == ParentType.PT_INSTANCE)
                {
                    parent = Agent.GetInstance(this.m_node.m_enterAction.GetInstanceNameString(), parent.GetContextId());
                }
                this.m_node.m_enterAction.run(parent, pAgent);
            }
            if (!flag)
            {
                this.UnInstantiatePars(pAgent);
            }
            return(flag);
        }
コード例 #23
0
ファイル: Condition.cs プロジェクト: TonyDongGuaPi/joework
        public static bool DoCompare(Agent pAgent, VariableComparator comparator, Property opl, CMethodBase opl_m, Property opr)
        {
            bool result = false;

            if (opl != null)
            {
                Agent      agent      = pAgent;
                ParentType parentType = opl.GetParentType();
                if (parentType == ParentType.PT_INSTANCE)
                {
                    agent = Agent.GetInstance(opl.GetInstanceNameString(), agent.GetContextId());
                }
                Agent agentR = pAgent;
                parentType = opr.GetParentType();
                if (parentType == ParentType.PT_INSTANCE)
                {
                    agentR = Agent.GetInstance(opr.GetInstanceNameString(), agent.GetContextId());
                }
                result = comparator.Execute(agent, agentR);
            }
            else if (opl_m != null)
            {
                ParentType parentType2 = opl_m.GetParentType();
                Agent      agent2      = pAgent;
                if (parentType2 == ParentType.PT_INSTANCE)
                {
                    agent2 = Agent.GetInstance(opl_m.GetInstanceNameString(), agent2.GetContextId());
                }
                object lhs    = opl_m.run(agent2, pAgent);
                Agent  agent3 = pAgent;
                parentType2 = opr.GetParentType();
                if (parentType2 == ParentType.PT_INSTANCE)
                {
                    agent3 = Agent.GetInstance(opr.GetInstanceNameString(), agent3.GetContextId());
                }
                result = comparator.Execute(lhs, agent2, agent3);
            }
            return(result);
        }
コード例 #24
0
ファイル: Condition.cs プロジェクト: isoundy000/wzry-1
        public static bool DoCompare(Agent pAgent, VariableComparator comparator, Property opl, CMethodBase opl_m, Property opr)
        {
            bool flag = false;

            if (opl != null)
            {
                Agent agentL = pAgent;
                if (opl.GetParentType() == ParentType.PT_INSTANCE)
                {
                    agentL = Agent.GetInstance(opl.GetInstanceNameString(), agentL.GetContextId());
                }
                Agent instance = pAgent;
                if (opr.GetParentType() == ParentType.PT_INSTANCE)
                {
                    instance = Agent.GetInstance(opr.GetInstanceNameString(), agentL.GetContextId());
                }
                return(comparator.Execute(agentL, instance));
            }
            if (opl_m == null)
            {
                return(flag);
            }
            ParentType parentType = opl_m.GetParentType();
            Agent      parent     = pAgent;

            if (parentType == ParentType.PT_INSTANCE)
            {
                parent = Agent.GetInstance(opl_m.GetInstanceNameString(), parent.GetContextId());
            }
            object lhs    = opl_m.run(parent, pAgent);
            Agent  agentR = pAgent;

            if (opr.GetParentType() == ParentType.PT_INSTANCE)
            {
                agentR = Agent.GetInstance(opr.GetInstanceNameString(), agentR.GetContextId());
            }
            return(comparator.Execute(lhs, parent, agentR));
        }
コード例 #25
0
            //generate a random float value between 0 and 1.
            public static float GetRandomValue(CMethodBase method, Agent pAgent)
            {
                float value = 0;

                if (method != null)
                {
                    ParentType pt      = method.GetParentType();
                    Agent      pParent = pAgent;
                    if (pt == ParentType.PT_INSTANCE)
                    {
                        pParent = Agent.GetInstance(method.GetInstanceNameString(), pParent.GetContextId());
                        Debug.Check(pParent != null || Utils.IsStaticClass(method.GetInstanceNameString()));
                    }

                    value = (float)method.run(pParent, pAgent);
                }
                else
                {
                    value = RandomGenerator.GetInstance().GetRandom();
                }

                Debug.Check(value >= 0.0f && value < 1.0f);
                return(value);
            }
コード例 #26
0
 public static TAGENT GetInstance <TAGENT>() where TAGENT : Agent, new()
 {
     return(Agent.GetInstance <TAGENT>(null, 0));
 }
コード例 #27
0
 public static TAGENT GetInstance <TAGENT>(string agentInstanceName) where TAGENT : Agent, new()
 {
     return(Agent.GetInstance <TAGENT>(agentInstanceName, 0));
 }
コード例 #28
0
 public static Agent GetInstance(string agentInstanceName)
 {
     return(Agent.GetInstance(agentInstanceName, 0));
 }
コード例 #29
0
            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);
            }
コード例 #30
0
            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);
            }