DS-Pokemon-Rom-Editor/DS_Map/AreaData.cs
AdAstra-LD 403feaadc0 Minor fixes
Fixed one-line conditionals, fixed some script command names, enabled some of the quick script cmd buttons
2021-01-01 05:17:43 +01:00

60 lines
1.8 KiB
C#
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System.IO;
namespace DS_Map
{
/// <summary>
/// Class to store area data in Pokémon NDS games
/// </summary>
public class AreaData
{
#region Fields (2)
public ushort buildingsTileset;
public ushort mapTileset;
public ushort dynamicTextureType;
public ushort unknown1;
public byte areaType;
public byte lightType;
#endregion
#region Constructors (1)
public AreaData(Stream data, string version)
{
using (BinaryReader reader = new BinaryReader(data))
{
buildingsTileset = reader.ReadUInt16();
mapTileset = reader.ReadUInt16();
if (version == "Diamond" || version == "Pearl" || version == "Platinum") {
unknown1 = reader.ReadUInt16();
lightType = reader.ReadByte();
} else {
dynamicTextureType = reader.ReadUInt16();
areaType = reader.ReadByte();
lightType = reader.ReadByte();
}
}
}
#endregion
#region Methods (1)
public byte[] SaveAreaData(string version)
{
MemoryStream newData = new MemoryStream();
using (BinaryWriter writer = new BinaryWriter(newData))
{
writer.Write(buildingsTileset);
writer.Write(mapTileset);
if (version == "Diamond" || version == "Pearl" || version == "Platinum") {
writer.Write(unknown1);
writer.Write(lightType);
} else {
writer.Write(dynamicTextureType);
writer.Write(areaType);
writer.Write(lightType);
}
}
return newData.ToArray();
}
#endregion
}
}