using FSO.Files.Utils;
using System.Collections.Generic;
using System.IO;
namespace FSO.Files.Formats.IFF.Chunks
{
///
/// This chunk type contains general neighbourhood data within a neighbourhood.iff file.
/// The only thing this was used for initially was tracking the tutorial.
///
/// As of hot date, it also includes inventory data, which was added as something of an afterthought.
///
public class NGBH : IffChunk
{
public short[] NeighborhoodData = new short[16];
public Dictionary> InventoryByID = new Dictionary>();
public uint Version;
///
/// Reads a NGBH chunk from a stream.
///
/// An Iff instance.
/// A Stream object holding a OBJf chunk.
public override void Read(IffFile iff, Stream stream)
{
using (var io = IoBuffer.FromStream(stream, ByteOrder.LITTLE_ENDIAN))
{
io.ReadUInt32(); //pad
Version = io.ReadUInt32(); //0x49 for latest game
string magic = io.ReadCString(4); //HBGN
for (int i=0; i<16; i++)
{
NeighborhoodData[i] = io.ReadInt16();
}
if (!io.HasMore) return; //no inventory present (yet)
var count = io.ReadInt32();
for (int i = 0; i < count; i++)
{
if (io.ReadInt32() != 1) { }
var neighID = io.ReadInt16();
var inventoryCount = io.ReadInt32();
var inventory = new List();
for (int j=0; j