Пример #1
0
        public void Initialize()
        {
            IsWorldTimeStarted = true;
            _worldProvider.Initialize();

            SpawnPoint       = new PlayerLocation(_worldProvider.GetSpawnPoint());
            CurrentWorldTime = _worldProvider.GetTime();

            if (_worldProvider.IsCaching)
            {
                Stopwatch chunkLoading = new Stopwatch();
                chunkLoading.Start();
                // Pre-cache chunks for spawn coordinates
                int i = 0;
                foreach (var chunk in GenerateChunks(new ChunkCoordinates(SpawnPoint), new Dictionary <Tuple <int, int>, McpeBatch>()))
                {
                    i++;
                }
                Log.InfoFormat("World pre-cache {0} chunks completed in {1}ms", i, chunkLoading.ElapsedMilliseconds);
            }

            StartTimeInTicks = DateTime.UtcNow.Ticks;

            _levelTicker = new Timer(WorldTick, null, 0, _worldTickTime);             // MC worlds tick-time
        }
Пример #2
0
        public void Initialize()
        {
            IsWorldTimeStarted = true;
            _worldProvider.Initialize();

            SpawnPoint       = _worldProvider.GetSpawnPoint();
            CurrentWorldTime = _worldProvider.GetTime();

            if (_worldProvider.IsCaching)
            {
                ThreadPool.QueueUserWorkItem(delegate(object state)
                {
                    Stopwatch chunkLoading = new Stopwatch();
                    chunkLoading.Start();
                    // Pre-cache chunks for spawn coordinates
                    int i = 0;
                    foreach (var chunk in GenerateChunks(new ChunkCoordinates(SpawnPoint.X >> 4, SpawnPoint.Z >> 4), new Dictionary <Tuple <int, int>, ChunkColumn>()))
                    {
                        chunk.GetBytes();
                        i++;
                    }
                    Log.InfoFormat("World pre-cache {0} chunks completed in {1}ms", i, chunkLoading.ElapsedMilliseconds);
                });
            }

            StartTimeInTicks = DateTime.UtcNow.Ticks;

            _levelTicker = new Timer(WorldTick, null, 0, _worldTickTime);             // MC worlds tick-time
        }
Пример #3
0
        public void Initialize()
        {
            //IsWorldTimeStarted = false;
            _worldProvider.Initialize();

            SpawnPoint       = SpawnPoint ?? new PlayerLocation(_worldProvider.GetSpawnPoint());
            CurrentWorldTime = _worldProvider.GetTime();

            if (_worldProvider.IsCaching)
            {
                Stopwatch chunkLoading = new Stopwatch();
                chunkLoading.Start();
                // Pre-cache chunks for spawn coordinates
                int i = 0;
                foreach (var chunk in GenerateChunks(new ChunkCoordinates(SpawnPoint), new Dictionary <Tuple <int, int>, McpeBatch>(), ViewDistance))
                {
                    if (chunk != null)
                    {
                        i++;
                    }
                }
                Log.InfoFormat("World pre-cache {0} chunks completed in {1}ms", i, chunkLoading.ElapsedMilliseconds);
            }

            if (Config.GetProperty("CheckForSafeSpawn", false))
            {
                var chunk = _worldProvider.GenerateChunkColumn(new ChunkCoordinates(SpawnPoint));
                chunk.RecalcHeight();

                var height = GetHeight((BlockCoordinates)SpawnPoint);
                if (height > SpawnPoint.Y)
                {
                    SpawnPoint.Y = height + 2;
                }
                Log.Debug("Checking for safe spawn");
            }

            StartTimeInTicks = DateTime.UtcNow.Ticks;

            _tickTimer = new Stopwatch();
            _tickTimer.Restart();
            //_levelTicker = new Timer(WorldTick, null, 50, _worldTickTime); // MC worlds tick-time


            //_tickerThread = new Thread(RunWorldTick);
            //_tickerThread.Priority = ThreadPriority.Highest;
            //_tickerThread.IsBackground = true;
            //_tickerThread.Start();
            //_tickerThreadTimer.Start();

            _tickerHighPrecisionTimer = new HighPrecisionTimer(50, WorldTick);
            //_mmTickTimer = new MultiMediaTimer();
            //_mmTickTimer.Mode = TimerMode.Periodic;
            //_mmTickTimer.Period = 50;
            //_mmTickTimer.Resolution = 1;
            //_mmTickTimer.SynchronizingObject = null;
            //_mmTickTimer.Tick += WorldTick;
            //_mmTickTimer.Start();
        }
Пример #4
0
        public void Initialize()
        {
            IsWorldTimeStarted = true;
            _worldProvider.Initialize();

            SpawnPoint       = new PlayerLocation(_worldProvider.GetSpawnPoint());
            CurrentWorldTime = _worldProvider.GetTime();

            if (_worldProvider.IsCaching)
            {
                Stopwatch chunkLoading = new Stopwatch();
                chunkLoading.Start();
                // Pre-cache chunks for spawn coordinates
                int i = 0;
                foreach (var chunk in GenerateChunks(new ChunkCoordinates(SpawnPoint), new Dictionary <Tuple <int, int>, McpeBatch>(), ViewDistance))
                {
                    if (chunk != null)
                    {
                        i++;
                    }
                }
                Log.InfoFormat("World pre-cache {0} chunks completed in {1}ms", i, chunkLoading.ElapsedMilliseconds);
            }

            StartTimeInTicks = DateTime.UtcNow.Ticks;

            //_levelTicker = new Timer(WorldTick, null, 0, _worldTickTime); // MC worlds tick-time

            //_tickerThread = new Thread(RunWorldTick);
            //_tickerThread.Priority = ThreadPriority.Highest;
            //_tickerThread.IsBackground = true;
            //_tickerThread.Start();
            //_tickerThreadTimer.Start();

            _tickerHighPrecisionTimer       = new HighPrecisionTimer(50);
            _tickerHighPrecisionTimer.Tick += _tickerHighPrecisionTimer_Tick;
        }