示例#1
0
        private void RunThread()
        {
            while (!ThreadCancellationTokenSource.IsCancellationRequested)
            {
                Vector3 pp = Vector3.Zero;
                var     e  = base.WorldReceiver?.GetPlayerEntity();
                if (e != null)
                {
                    pp = e.KnownPosition;
                }
                //var pp = base.WorldReceiver.GetPlayerEntity();
                ChunkCoordinates currentCoordinates =
                    new ChunkCoordinates(new PlayerLocation(pp.X, pp.Y, pp.Z));

                if (PreviousChunkCoordinates.DistanceTo(currentCoordinates) >= 1)
                {
                    PreviousChunkCoordinates = currentCoordinates;

                    foreach (var chunk in GenerateChunks(currentCoordinates, Options.VideoOptions.RenderDistance))
                    {
                        var c = (ChunkColumn)chunk;

                        base.LoadChunk(chunk, c.X, c.Z, true);
                        LoadEntities(c);
                    }
                }

                Thread.Sleep(500);
            }
        }
示例#2
0
        private void RunThread()
        {
            SpinWait sw = new SpinWait();

            while (!ThreadCancellationTokenSource.IsCancellationRequested)
            {
                if (!World.Player.IsSpawned)
                {
                    sw.SpinOnce();
                    continue;
                }

                /*var e = base.WorldReceiver?.Player;
                 * if (e != null)
                 * {
                 *      pp = e.KnownPosition;
                 * }*/
                //var pp = base.WorldReceiver.Player;
                ChunkCoordinates currentCoordinates =
                    new ChunkCoordinates(World.Player.KnownPosition);

                if (PreviousChunkCoordinates.DistanceTo(currentCoordinates) >= 1)
                {
                    PreviousChunkCoordinates = currentCoordinates;

                    foreach (var chunk in GenerateChunks(currentCoordinates, OptionsProvider.AlexOptions.VideoOptions.RenderDistance))
                    {
                        var c = (ChunkColumn)chunk;

                        base.World.ChunkManager.AddChunk(c, currentCoordinates, false);
                        //EventDispatcher.DispatchEvent(new ChunkReceivedEvent(currentCoordinates, c));
                        LoadEntities(c);
                    }
                }

                //sw.SpinOnce();
                Thread.Sleep(500);
            }
        }