GetAgents() public method

public GetAgents ( ) : List
return List
示例#1
0
        public void BuildAgentTree()
        {
            List <Agent> ag = simulator.GetAgents();

            if (agents == null || agents.Count != ag.Count || rebuildAgents)
            {
                rebuildAgents = false;
                if (agents == null)
                {
                    agents = new List <Agent>(ag.Count);
                }
                else
                {
                    agents.Clear();
                }

                agents.AddRange(simulator.GetAgents());
            }

            if (agentTree.Length != agents.Count * 2)
            {
                agentTree = new AgentTreeNode[agents.Count * 2];
                for (int i = 0; i < agentTree.Length; i++)
                {
                    agentTree[i] = new AgentTreeNode();
                }
            }

            if (agents.Count != 0)
            {
                BuildAgentTreeRecursive(0, agents.Count, 0);
            }
        }
示例#2
0
            public void Run()
            {
#if NET_4_6 || NET_STANDARD_2_0
                runFlag.Wait();
                runFlag.Reset();
#else
                runFlag.WaitOne();
#endif

                while (!terminate)
                {
                    try
                    {
                        List <Agent> agents = simulator.GetAgents();
                        if (task == 0)
                        {
                            for (int i = start; i < end; i++)
                            {
                                agents[i].CalculateNeighbours();
                                agents[i].CalculateVelocity(context);
                            }
                        }
                        else if (task == 1)
                        {
                            for (int i = start; i < end; i++)
                            {
                                agents[i].BufferSwitch();
                            }
                        }
                        else if (task == 2)
                        {
                            simulator.BuildQuadtree();
                        }
                        else
                        {
                            Debug.LogError("Invalid Task Number: " + task);
                            throw new System.Exception("Invalid Task Number: " + task);
                        }
                    }
                    catch (System.Exception e)
                    {
                        Debug.LogError(e);
                    }
                    waitFlag.Set();
#if NET_4_6 || NET_STANDARD_2_0
                    runFlag.Wait();
                    runFlag.Reset();
#else
                    runFlag.WaitOne();
#endif
                }
            }
示例#3
0
        public void BuildAgentTree()
        {
            //Dummy to avoid compiler warnings
            obstacleRoot       = new ObstacleTreeNode();
            obstacleRoot.right = obstacleRoot;
            obstacleRoot.left  = obstacleRoot;
            obstacleRoot       = null;

            List <Agent> ag = simulator.GetAgents();

            if (agents == null || agents.Count != ag.Count || rebuildAgents)
            {
                rebuildAgents = false;
                if (agents == null)
                {
                    agents = new List <Agent>(ag.Count);
                }
                else
                {
                    agents.Clear();
                }

                agents.AddRange(simulator.GetAgents());
            }

            if (agentTree.Length != agents.Count * 2)
            {
                agentTree = new AgentTreeNode[agents.Count * 2];
                for (int i = 0; i < agentTree.Length; i++)
                {
                    agentTree[i] = new AgentTreeNode();
                }
            }

            if (agents.Count != 0)
            {
                BuildAgentTreeRecursive(0, agents.Count, 0);
            }
        }
示例#4
0
            public void Run()
            {
                runFlag.WaitOne();

                while (!terminate)
                {
                    try {
                        List <Agent> agents = simulator.GetAgents();
                        if (task == 0)
                        {
                            for (int i = start; i < end; i++)
                            {
                                agents[i].CalculateNeighbours();
                                agents[i].CalculateVelocity(context);
                            }
                        }
                        else if (task == 1)
                        {
                            for (int i = start; i < end; i++)
                            {
                                agents[i].Update();
                                agents[i].BufferSwitch();
                            }
                        }
                        else if (task == 2)
                        {
                            simulator.BuildQuadtree();

                            /*} else if (task == 2) {
                             *  for (int i=start;i<end;i++) {
                             *      agents[i].BufferSwitch ();
                             *  }*/
                        }
                        else
                        {
                            EB.Debug.LogError("Invalid Task Number: {0}", task);
                            throw new System.Exception("Invalid Task Number: " + task);
                        }
                    } catch (System.Exception e) {
                        Debug.LogError(e);
                    }
                    waitFlag.Set();
                    runFlag.WaitOne();
                }
            }