add basic Tile serialize/deserialize to binary methods
This commit is contained in:
parent
7435ccfaed
commit
fb7b85d6ab
|
@ -218,6 +218,7 @@
|
|||
<Compile Include="Graphics\Atlas\Json\JsonTextureAtlasDefinition.cs" />
|
||||
<Compile Include="Graphics\Atlas\Json\JsonTextureAtlasTile.cs" />
|
||||
<Compile Include="Graphics\Atlas\Json\TextureAtlasLoader.cs" />
|
||||
<Compile Include="TileMap\TileDataSerializer.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
|
||||
<ItemGroup>
|
||||
|
@ -248,6 +249,7 @@
|
|||
<Folder Include="TileMap\Prefabs\" />
|
||||
<Folder Include="TileMap\Meshes\Json\" />
|
||||
<Folder Include="Graphics\Atlas\Json\" />
|
||||
<Folder Include="TileMap\Json\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Resources\Fonts\Vera.ttf" />
|
||||
|
|
41
Blarg.GameFramework/TileMap/TileDataSerializer.cs
Normal file
41
Blarg.GameFramework/TileMap/TileDataSerializer.cs
Normal file
|
@ -0,0 +1,41 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace Blarg.GameFramework.TileMap
|
||||
{
|
||||
public static class TileDataSerializer
|
||||
{
|
||||
public static void Serialize(Tile src, BinaryWriter writer)
|
||||
{
|
||||
writer.Write(src.TileIndex);
|
||||
writer.Write(src.Flags);
|
||||
writer.Write(src.TileLight);
|
||||
writer.Write(src.SkyLight);
|
||||
writer.Write(src.Rotation);
|
||||
writer.Write(src.ParentTileOffsetX);
|
||||
writer.Write(src.ParentTileOffsetY);
|
||||
writer.Write(src.ParentTileOffsetZ);
|
||||
writer.Write(src.ParentTileWidth);
|
||||
writer.Write(src.ParentTileHeight);
|
||||
writer.Write(src.ParentTileDepth);
|
||||
writer.Write(src.Color);
|
||||
}
|
||||
|
||||
public static void Deserialize(BinaryReader reader, Tile dest)
|
||||
{
|
||||
dest.TileIndex = reader.ReadInt16();
|
||||
dest.Flags = reader.ReadInt16();
|
||||
dest.TileLight = reader.ReadByte();
|
||||
dest.SkyLight = reader.ReadByte();
|
||||
dest.Rotation = reader.ReadByte();
|
||||
dest.ParentTileOffsetX = reader.ReadByte();
|
||||
dest.ParentTileOffsetY = reader.ReadByte();
|
||||
dest.ParentTileOffsetZ = reader.ReadByte();
|
||||
dest.ParentTileWidth = reader.ReadByte();
|
||||
dest.ParentTileHeight = reader.ReadByte();
|
||||
dest.ParentTileDepth = reader.ReadByte();
|
||||
dest.Color = reader.ReadInt32();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in a new issue