Ejemplo n.º 1
0
        /// <summary>
        /// Ticks the entire region.
        /// </summary>
        public void Tick()
        {
            if (Delta <= 0)
            {
                return;
            }
            opsat += Delta;
            while (opsat > 1.0)
            {
                opsat -= 1.0;
                OncePerSecondActions();
            }
            Stopwatch sw = new Stopwatch();

            sw.Start();
            if (Delta > TheWorld.TargetDelta * 2)
            {
                PhysicsWorld.TimeStepSettings.TimeStepDuration = Delta * 0.5;
            }
            else
            {
                PhysicsWorld.TimeStepSettings.TimeStepDuration = TheWorld.TargetDelta;
            }
            PhysicsWorld.Update(Delta);
            sw.Stop();
            TheServer.PhysicsTimeC += sw.Elapsed.TotalMilliseconds;
            TheServer.PhysicsTimes++;
            sw.Reset();
            // TODO: Async tick
            sw.Start();
            for (int i = 0; i < Tickers.Count; i++)
            {
                if (!Tickers[i].Removed && Tickers[i] is PhysicsEntity)
                {
                    (Tickers[i] as PhysicsEntity).PreTick();
                }
            }
            for (int i = 0; i < Tickers.Count; i++)
            {
                if (!Tickers[i].Removed)
                {
                    Tickers[i].Tick();
                }
            }
            for (int i = 0; i < Tickers.Count; i++)
            {
                if (!Tickers[i].Removed && Tickers[i] is PhysicsEntity)
                {
                    (Tickers[i] as PhysicsEntity).EndTick();
                }
            }
            for (int i = 0; i < DespawnQuick.Count; i++)
            {
                DespawnEntity(DespawnQuick[i]);
            }
            DespawnQuick.Clear();
            for (int i = 0; i < Joints.Count; i++) // TODO: Optimize!
            {
                if (Joints[i].Enabled && Joints[i] is BaseFJoint)
                {
                    ((BaseFJoint)Joints[i]).Solve();
                }
            }
            sw.Stop();
            TheServer.EntityTimeC += sw.Elapsed.TotalMilliseconds;
            TheServer.EntityTimes++;
        }
Ejemplo n.º 2
0
        public void Tick(double delta)
        {
            Delta           = delta;
            GlobalTickTime += Delta;
            if (Delta <= 0)
            {
                return;
            }
            physBoost    = defPhysBoost;
            physThisTick = 0;
            opsat       += Delta;
            while (opsat > 1.0)
            {
                opsat -= 1.0;
                OncePerSecondActions();
            }
            Stopwatch sw = new Stopwatch();

            sw.Start();
            PhysicsWorld.Update((double)delta);
            sw.Stop();
            TheServer.PhysicsTimeC += sw.Elapsed.TotalMilliseconds;
            TheServer.PhysicsTimes++;
            sw.Reset();
            // TODO: Async tick
            sw.Start();
            for (int i = 0; i < Tickers.Count; i++)
            {
                if (!Tickers[i].Removed && Tickers[i] is PhysicsEntity)
                {
                    ((PhysicsEntity)Tickers[i]).PreTick();
                }
            }
            for (int i = 0; i < Tickers.Count; i++)
            {
                if (!Tickers[i].Removed)
                {
                    Tickers[i].Tick();
                }
            }
            for (int i = 0; i < Tickers.Count; i++)
            {
                if (!Tickers[i].Removed && Tickers[i] is PhysicsEntity)
                {
                    ((PhysicsEntity)Tickers[i]).EndTick();
                }
            }
            for (int i = 0; i < DespawnQuick.Count; i++)
            {
                DespawnEntity(DespawnQuick[i]);
            }
            DespawnQuick.Clear();
            for (int i = 0; i < Joints.Count; i++) // TODO: Optimize!
            {
                if (Joints[i].Enabled && Joints[i] is BaseFJoint)
                {
                    ((BaseFJoint)Joints[i]).Solve();
                }
            }
            sw.Stop();
            TheServer.EntityTimeC += sw.Elapsed.TotalMilliseconds;
            TheServer.EntityTimes++;
        }