Exemplo n.º 1
0
        void AddChunks(PlayerHandler player)
        {
            Vector2Int cam = player.transform.position.ToChunkCoords();

            for (int i = 0; i < player.loadDistance; i++)
            {
                for (int x = cam.x - i; x <= cam.x + i; x++)
                {
                    for (int z = cam.y - i; z <= cam.y + i; z++)
                    {
                        Vector2Int pos = new Vector2Int(x, z);
                        if (!loadedChunksPerUser[player.id].Contains(pos))
                        {
                            Chunk c = GetChunk(x, z);
                            if (!c.Generated)
                            {
                                c = Chunk.Load(new Vector2Int(x, z));
                                if (c == null)
                                {
                                    c = World.Get.GenerateChunk(x, z);
                                }
                                else
                                {
                                    AddChunk(c);
                                }
                            }
                            PacketSender.ChunkSend(player.id, c);
                            loadedChunksPerUser[player.id].Add(pos);
                            return;
                        }
                    }
                }
            }

            player.loadDistance++;
            if (player.loadDistance >= Settings.RenderDistance)
            {
                player.loadDistance = 2;
            }
        }
Exemplo n.º 2
0
 public Vector3 GenerateSpawnPoint(Guid id, int cx = 100, int cz = 100)
 {
     PacketSender.ChunkSend(id, GenerateChunk(cx, cz));
     return(new Vector3(7.5f + cx * Settings.ChunkSize.x, GetChunk(cx, cz).HeightMap[7, 7] + 3, 7.5f + cz * Settings.ChunkSize.z));
 }