コード例 #1
0
ファイル: Decoration.cs プロジェクト: Jorch72/CS-TrueCraft
        public static bool NeighboursBlock(IChunk chunk, Coordinates3D location, byte block, byte meta = 0x0)
        {
            var surrounding = new[] {
                location + Coordinates3D.Left,
                location + Coordinates3D.Right,
                location + Coordinates3D.Forwards,
                location + Coordinates3D.Backwards,
            };

            for (int i = 0; i < surrounding.Length; i++)
            {
                var toCheck = surrounding[i];
                if (toCheck.X < 0 || toCheck.X >= Chunk.Width || toCheck.Z < 0 || toCheck.Z >= Chunk.Depth || toCheck.Y < 0 || toCheck.Y >= Chunk.Height)
                {
                    return(false);
                }
                if (chunk.GetBlockID(toCheck).Equals(block))
                {
                    if (meta != 0x0 && chunk.GetMetadata(toCheck) != meta)
                    {
                        return(false);
                    }
                    return(true);
                }
            }
            return(false);
        }
コード例 #2
0
ファイル: RemoteClient.cs プロジェクト: Jorch72/CS-TrueCraft
        internal void LoadChunk(IChunk chunk)
        {
            QueuePacket(new ChunkPreamblePacket(chunk.Coordinates.X, chunk.Coordinates.Z));
            QueuePacket(CreatePacket(chunk));
            Server.Scheduler.ScheduleEvent("client.finalize-chunks", this,
                                           TimeSpan.Zero, server =>
            {
                return;

                LoadedChunks.Add(chunk.Coordinates);
                foreach (var kvp in chunk.TileEntities)
                {
                    var coords     = kvp.Key;
                    var descriptor = new BlockDescriptor
                    {
                        Coordinates = coords + new Coordinates3D(chunk.X, 0, chunk.Z),
                        Metadata    = chunk.GetMetadata(coords),
                        ID          = chunk.GetBlockID(coords),
                        BlockLight  = chunk.GetBlockLight(coords),
                        SkyLight    = chunk.GetSkyLight(coords)
                    };
                    var provider = Server.BlockRepository.GetBlockProvider(descriptor.ID);
                    provider.TileEntityLoadedForClient(descriptor, World, kvp.Value, this);
                }
            });
        }
コード例 #3
0
ファイル: World.cs プロジェクト: andy7731/TrueCraft
 private BlockDescriptor GetBlockDataFromChunk(Coordinates3D adjustedCoordinates, IChunk chunk, Coordinates3D coordinates)
 {
     return(new BlockDescriptor
     {
         ID = chunk.GetBlockID(adjustedCoordinates),
         Metadata = chunk.GetMetadata(adjustedCoordinates),
         BlockLight = chunk.GetBlockLight(adjustedCoordinates),
         SkyLight = chunk.GetSkyLight(adjustedCoordinates),
         Coordinates = coordinates
     });
 }
コード例 #4
0
ファイル: Decoration.cs プロジェクト: Zoxive/TrueCraft
 public static bool NeighboursBlock(IChunk chunk, Coordinates3D location, byte block, byte meta = 0x0)
 {
     var surrounding = new[] {
         location + Coordinates3D.Left,
         location + Coordinates3D.Right,
         location + Coordinates3D.Forwards,
         location + Coordinates3D.Backwards,
     };
     for (int i = 0; i < surrounding.Length; i++)
     {
         var toCheck = surrounding[i];
         if (toCheck.X < 0 || toCheck.X >= Chunk.Width || toCheck.Z < 0 || toCheck.Z >= Chunk.Depth || toCheck.Y < 0 || toCheck.Y >= Chunk.Height)
             return false;
         if (chunk.GetBlockID(toCheck).Equals(block))
         {
             if (meta != 0x0 && chunk.GetMetadata(toCheck) != meta)
                 return false;
             return true;
         }
     }
     return false;
 }
コード例 #5
0
ファイル: ReadOnlyWorld.cs プロジェクト: Jorch72/CS-TrueCraft
 public byte GetMetadata(Coordinates3D coordinates)
 {
     return(Chunk.GetMetadata(coordinates));
 }
コード例 #6
0
 private async Task ApplyChunkAsync(IChunk chunk, Point index)
 {
     // TODO: It would be better to directly replace the chunk via ChunkLoader
     for (var y = 0; y < Chunk.Size; y++)
     {
         for (var x = 0; x < Chunk.Size; x++)
         {
             var position = index * Chunk.Size + new Point(x, y);
             await Map.SetAsync(position, chunk[x, y]);
             await Map.SetMetadataAsync(position, chunk.GetMetadata(new Point(x, y)));
         }
     }
 }
コード例 #7
0
ファイル: World.cs プロジェクト: Luigifan/TrueCraft
 private BlockDescriptor GetBlockDataFromChunk(Coordinates3D adjustedCoordinates, IChunk chunk, Coordinates3D coordinates)
 {
     return new BlockDescriptor
     {
         ID = chunk.GetBlockID(adjustedCoordinates),
         Metadata = chunk.GetMetadata(adjustedCoordinates),
         BlockLight = chunk.GetBlockLight(adjustedCoordinates),
         SkyLight = chunk.GetSkyLight(adjustedCoordinates),
         Coordinates = coordinates
     };
 }