Beispiel #1
0
        public void Run()
        {
            UpdateBounds();
            Quelea.UpdateDatastructure(min, max, (int)(Number.Clamp((min.DistanceTo(max) / 5), 5, 25)), (IList <T>)Quelea.SpatialObjects);
            IList <T> toRemove = new List <T>();

            foreach (T quelea in Quelea)
            {
                quelea.Run();
                if (environment != null)
                {
                    quelea.RefPosition = environment.ClosestRefPointOnRef(quelea.RefPosition);
                    quelea.Position    = environment.ClosestPointOnRef(quelea.RefPosition);
                }
                else
                {
                    quelea.RefPosition = quelea.Position;
                    quelea.Position    = quelea.RefPosition;
                }
                quelea.PositionHistory.Add(quelea.Position);
                if (quelea.IsDead())
                {
                    toRemove.Add(quelea);
                }
            }

            foreach (AbstractEmitterType emitter in emitters)
            {
                if (emitter.ContinuousFlow && (timestep % emitter.CreationRate == 0))
                {
                    if ((emitter.NumAgents == 0) || (Quelea.Count < emitter.NumAgents))
                    {
                        Add(emitter);
                    }
                }
            }

            foreach (T deadQuelea in toRemove)
            {
                Quelea.Remove(deadQuelea);
            }
            timestep++;
        }