MCSharp.Server.doPhysics C# (CSharp) Method

doPhysics() public static method

public static doPhysics ( ) : void
return void
        public static void doPhysics()
        {
            int wait = 250;
            while (true)
            {
                try
                {
                    if (wait > 0)
                    {
                        Thread.Sleep(wait);
                    }
                    DateTime Start = DateTime.Now;
                    levels.ForEach(delegate(Map L)    //update every level
                    {
                        L.CalcPhysics();
                    });
                    TimeSpan Took = DateTime.Now - Start;
                    wait = (int) 250 - (int) Took.TotalMilliseconds;
                    if (wait < -Properties.PhysicsOverload)
                    {
                        levels.ForEach(delegate(Map L)    //update every level
                        {
                            try
                            {
                                L.Physics = Physics.Off;
                                L.ClearPhysics();
                            }
                            catch
                            {

                            }
                        });
                        Logger.Log("!PHYSICS SHUTDOWN!", LogType.Warning);
                        Player.GlobalMessage("!PHYSICS SHUTDOWN!");
                        wait = 250;
                    }
                    else if (wait < (int) (-Properties.PhysicsOverload * 0.75f))
                    {
                        Logger.Log("Physics is getting a bit overloaded...", LogType.Debug);
                    }
                }
                catch (Exception e)
                {
                    Logger.Log("Physics error!", LogType.Error);
                    Logger.Log(e.Message, LogType.ErrorMessage);
                    wait = 250;
                }

            }
        }