Beispiel #1
0
        /// <summary>
        /// Use the portal to despawn an agent from the in flow.
        /// </summary>
        /// <returns>The agent that the node removed.</returns>
        public Agent Leave()
        {
            // Check if any agents are leaving
            if (ExternalOut.Count < 1)
            {
                return(null);
            }
            // Get first agent leaving
            Agent a = ExternalOut[0];

            // Remove from queue
            ExternalOut.RemoveAt(0);
            // Despawn the agent
            if (Station != null)
            {
                ((Port)Station).Leave(a);
            }
            // Return it for use by the graph
            return(a);
        }
Beispiel #2
0
        /// <summary>
        /// Flushes the external inflow to the outflow and inflow to the external outflow, then sorts the both queues.
        /// </summary>
        public new void Flush()
        {
            Agent a;

            while (In.Count > 0)
            {
                a = In[0];
                In.Remove(a);
                ExternalOut.Add(a);
            }
            ExternalOut.Sort();

            while (ExternalIn.Count > 0)
            {
                a = ExternalIn[0];
                ExternalIn.Remove(a);
                Out.Add(a);
            }
            Out.Sort();
        }