Esempio n. 1
0
        private void execAgents_()
        {
            if (!Workspace.Instance.IsExecAgents)
            {
                return;
            }

            m_IsExecuting = true;

            this.Agents.Sort();

            for (int i = 0; i < this.Agents.Count; ++i)
            {
                HeapItem_t pa = this.Agents[i];
                var        e  = pa.agents.Values.GetEnumerator();

                while (e.MoveNext())
                {
                    if (e.Current.IsActive())
                    {
                        e.Current.btexec();

                        // in case IsExecAgents was set to false by pA's bt
                        if (!Workspace.Instance.IsExecAgents)
                        {
                            break;
                        }
                    }
                }
            }

            m_IsExecuting = false;

            this.DelayProcessingAgents();
        }
Esempio n. 2
0
        private void execAgents_()
        {
            this.Agents.Sort();

            for (int i = 0; i < this.Agents.Count; ++i)
            {
                HeapItem_t pa = this.Agents[i];
                foreach (Agent pA in pa.agents.Values)
                {
                    if (pA.IsActive())
                    {
                        pA.btexec();

                        //in case IsExecAgents was set to false by pA's bt
                        if (!Workspace.Instance.IsExecAgents)
                        {
                            break;
                        }
                    }
                }
            }

            if (Agent.IdMask() != 0)
            {
                this.LogStaticVariables(null);
            }
        }
Esempio n. 3
0
        private void execAgents_()
        {
            this.DelayProcessingAgents();

            this.Agents.Sort();

            for (int i = 0; i < this.Agents.Count; ++i)
            {
                HeapItem_t pa = this.Agents[i];
                var        e  = pa.agents.Values.GetEnumerator();

                while (e.MoveNext())
                {
                    if (e.Current.IsActive())
                    {
                        e.Current.btexec();

                        //in case IsExecAgents was set to false by pA's bt
                        if (!Workspace.Instance.IsExecAgents)
                        {
                            break;
                        }
                    }
                }
            }

            if (Agent.IdMask() != 0)
            {
                this.LogStaticVariables(null);
            }
        }
Esempio n. 4
0
        void btexec_agents()
        {
            this.Agents.Sort();

            for (int i = 0; i < this.Agents.Count; ++i)
            {
                HeapItem_t pa = this.Agents[i];
                foreach (Agent pA in pa.agents.Values)
                {
                    if (pA.IsActive())
                    {
                        pA.btexec();

                        //in case m_bTickAgents was set to false by pA's bt
                        if (!this.m_bTickAgents)
                        {
                            break;
                        }
                    }
                }
            }

            if (Agent.IdMask() != 0)
            {
                int     contextId = this.GetContextId();
                Context c         = Context.GetContext(contextId);

                c.LogStaticVariables(null);
            }
        }
Esempio n. 5
0
        public void AddAgent(Agent pAgent)
        {
            int id       = pAgent.GetId();
            int priority = pAgent.GetPriority();
            int num3     = -1;

            for (int i = 0; i < this.Agents.Count; i++)
            {
                HeapItem_t _t2 = this.Agents[i];
                if (_t2.priority == priority)
                {
                    num3 = i;
                    break;
                }
            }
            if (num3 == -1)
            {
                HeapItem_t item = new HeapItem_t {
                    agents   = new DictionaryView <int, Agent>(),
                    priority = priority
                };
                item.agents[id] = pAgent;
                this.Agents.Add(item);
            }
            else
            {
                HeapItem_t _t3 = this.Agents[num3];
                _t3.agents[id] = pAgent;
            }
        }
Esempio n. 6
0
        public void RemoveAgent(Agent pAgent)
        {
            int id       = pAgent.GetId();
            int priority = pAgent.GetPriority();
            int num3     = -1;

            for (int i = 0; i < this.Agents.Count; i++)
            {
                HeapItem_t _t = this.Agents[i];
                if (_t.priority == priority)
                {
                    num3 = i;
                    break;
                }
            }
            if (num3 != -1)
            {
                HeapItem_t _t2 = this.Agents[num3];
                if (_t2.agents.ContainsKey(id))
                {
                    HeapItem_t _t3 = this.Agents[num3];
                    _t3.agents.Remove(id);
                }
            }
        }
Esempio n. 7
0
        private void execAgents_()
        {
            if (!Workspace.Instance.IsExecAgents)
            {
                return;
            }

            m_IsExecuting = true;

            this.Agents.Sort();

            for (int i = 0; i < this.Agents.Count; ++i)
            {
                HeapItem_t pa = this.Agents[i];
                var        e  = pa.agents.GetEnumerator();

                while (e.MoveNext())
                {
                    Agent pAgent = e.Current.Value;
                    if (pAgent.IsActive())
                    {
                        try
                        {
                            pAgent.btexec();
                        }
                        catch (System.Exception ex)
                        {
                            LogManager.Instance.Output(pAgent, "[Error] " + ex);
                            behaviac.Debug.LogError(ex.ToString());
                        }

                        // in case IsExecAgents was set to false by pA's bt
                        if (!Workspace.Instance.IsExecAgents)
                        {
                            break;
                        }
                    }
                }
            }

            m_IsExecuting = false;

            this.DelayProcessingAgents();
        }
Esempio n. 8
0
        public void AddAgent(Agent pAgent)
        {
            //ASSERT_MAIN_THREAD();
            int agentId   = pAgent.GetId();
            int priority  = pAgent.GetPriority();
            int itemIndex = this.Agents.FindIndex(delegate(HeapItem_t h) { return(h.priority == priority); });

            if (itemIndex == -1)
            {
                HeapItem_t pa = new HeapItem_t();
                pa.agents          = new Dictionary <int, Agent>();
                pa.priority        = priority;
                pa.agents[agentId] = pAgent;
                this.Agents.Add(pa);
            }
            else
            {
                this.Agents[itemIndex].agents[agentId] = pAgent;
            }
        }
Esempio n. 9
0
        private void LogCurrentState()
        {
            string msg = string.Format("LogCurrentStates {0} {1}", this.m_context_id, this.Agents.Count);

            behaviac.Debug.Log(msg);

            //force to log vars
            for (int i = 0; i < this.Agents.Count; ++i)
            {
                HeapItem_t pa = this.Agents[i];
                var        e  = pa.agents.Values.GetEnumerator();
                while (e.MoveNext())
                {
                    if (e.Current.IsMasked())
                    {
                        e.Current.LogVariables(true);
                    }
                }
            }
        }
Esempio n. 10
0
 private void btexec_agents()
 {
     this.Agents.Sort();
     for (int i = 0; i < this.Agents.Count; i++)
     {
         HeapItem_t _t = this.Agents[i];
         foreach (KeyValuePair <int, Agent> pair in _t.agents)
         {
             if (pair.Value.IsActive())
             {
                 pair.Value.btexec();
                 if (!this.m_bTickAgents)
                 {
                     break;
                 }
             }
         }
     }
     if (Agent.IdMask() != 0)
     {
         Context.GetContext(base.GetContextId()).LogStaticVariables(null);
     }
 }