예제 #1
0
 static public void UpdateChunckData(ChunckData chunckData)
 {
     Chunck chunck = chuncks.Find(c => (c.iPos == chunckData.iPos) && (c.jPos == chunckData.jPos));
     if (chunck == null)
     {
         return;
     }
     chunck.SetData(chunckData);
 }
예제 #2
0
 public void SetData(ChunckData data)
 {
     iPos = data.iPos;
     jPos = data.jPos;
     map = new int[CHUNCKSIZE * CHUNCKSIZE];
     data.map.CopyTo(map, 0);
     texturedBlocks = new Dictionary<string, List<Block>>();
     for (int i = 0; i < data.blocks.Length; i++)
     {
         var b = new Block();
         b.SetData(data.blocks[i]);
         if (!texturedBlocks.ContainsKey(b.texture))
         {
             texturedBlocks.Add(b.texture, new List<Block>());
         }
         texturedBlocks[b.texture].Add(b);
     }
     this.transform.position = new Vector3(Chunck.TILESIZE * iPos * Chunck.CHUNCKSIZE, 0f, Chunck.TILESIZE * jPos * Chunck.CHUNCKSIZE);
 }
예제 #3
0
 static public void Add(ChunckData newChunckData)
 {
     if (chuncks.Find(c => (c.iPos == newChunckData.iPos) && (c.jPos == newChunckData.jPos)) != null)
     {
         return;
     }
     int i = newChunckData.iPos;
     int j = newChunckData.jPos;
     Chunck newChunck = Instantiate(Template);
     newChunck.SetData(newChunckData);
     chuncks.Add(newChunck);
     TrySetMesh(newChunck);
     newChunck.SetBlock();
     for (int x = 0; x < 3; x++)
     {
         for (int y = 0; y < 3; y++)
         {
             Chunck side = chuncks.Find(c => (c.iPos == i - 1 + x) && (c.jPos == j - 1 + y));
             TrySetMesh(side);
         }
     }
 }
예제 #4
0
        public void Tick()
        {
            lock (MinecraftServer.Worlds)
            {
                foreach (var i in MinecraftServer.Worlds)
                {
                    foreach (var p in i.Players)
                    {
                        if (p.Spawned && !p.SpawnedCunckLoaded)
                        {
                            ChunckData cd = new ChunckData()
                            {
                                Owner = p.OwnerID
                            };
                            cd.Data = i.WorldGenerator.GetChunck(0, 0);

                            NetworkService.EnqueuePacket(cd);

                            p.SpawnedCunckLoaded = true;
                        }
                    }
                }
            }
        }