本文整理汇总了C#中fCraft.Map.ReadMetadata方法的典型用法代码示例。如果您正苦于以下问题:C# Map.ReadMetadata方法的具体用法?C# Map.ReadMetadata怎么用?C# Map.ReadMetadata使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fCraft.Map
的用法示例。
在下文中一共展示了Map.ReadMetadata方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Load
public Map Load( Stream MapStream )
{
// Reset the seeker to the front of the stream
// This should probably be done differently.
MapStream.Seek( 0, SeekOrigin.Begin );
Map map = new Map();
BinaryReader reader = new BinaryReader( MapStream );
// Read in the magic number
if ( reader.ReadUInt32() != Identifier ) {
throw new FormatException();
}
// Read in the map dimesions
map.widthX = reader.ReadInt16();
map.widthY = reader.ReadInt16();
map.height = reader.ReadInt16();
// Read in the spawn location
map.spawn.x = reader.ReadInt16();
map.spawn.y = reader.ReadInt16();
map.spawn.h = reader.ReadInt16();
// Read in the spawn orientation
map.spawn.r = reader.ReadByte();
map.spawn.l = reader.ReadByte();
// Read the metadata
map.ReadMetadata( reader );
if( !map.ValidateHeader() ) {
throw new Exception( "One or more of the map dimensions are invalid." );
}
// Read in the map data
map.blocks = new Byte[map.GetBlockCount()];
using ( GZipStream decompressor = new GZipStream( MapStream, CompressionMode.Decompress, true ) ) {
decompressor.Read( map.blocks, 0, map.blocks.Length );
}
return map;
}