private void Read(FbnBinaryReader reader) { while (reader.Position < reader.BaseStream.Length) { var startPosition = reader.Position; var type = ( FbnBinaryChunkType )reader.ReadInt32(); var field04 = reader.ReadInt32(); var size = reader.ReadInt32(); /* var dataOffset = */ reader.ReadInt32(); var endPosition = startPosition + size; switch (type) { case FbnBinaryChunkType.HitDefinitionList: Field04 = field04; reader.ReadList(this); break; default: throw new NotImplementedException($"Reading block type {type} is not yet implemented"); } reader.SeekBegin(endPosition); } }
private void Read(FbnBinaryReader reader) { // TODO: make code less fragile (too many switch cases) while (reader.Position < reader.BaseStream.Length) { var startPosition = reader.Position; var type = ( FbnBinaryChunkType )reader.ReadInt32(); var field04 = reader.ReadInt32(); var size = reader.ReadInt32(); /* var dataOffset = */ reader.ReadInt32(); var endPosition = startPosition + size; switch (type) { case FbnBinaryChunkType.Header: Field04 = field04; break; case FbnBinaryChunkType.HitTriggerList: HitTriggers = reader.ReadList <FbnTriggerVolume>(type, field04); break; case FbnBinaryChunkType.EntranceList: Entrances = reader.ReadList <FbnEntrance>(type, field04); break; case FbnBinaryChunkType.Type8: Block8Entries = reader.ReadList <FbnBlock8Entry>(type, field04); break; case FbnBinaryChunkType.Type9: Block9Entries = reader.ReadList <FbnBlock9Entry>(type, field04); break; case FbnBinaryChunkType.Type10: Block10Entries = reader.ReadList <FbnBlock10Entry>(type, field04); break; case FbnBinaryChunkType.Type11: Block11Entries = reader.ReadList <FbnBlock11Entry>(type, field04); break; case FbnBinaryChunkType.MessageTriggerList: MessageTriggers = reader.ReadList <FbnMessageTrigger>(type, field04); break; case FbnBinaryChunkType.Type18: Block18Entries = reader.ReadList <FbnBlock18Entry>(type, field04); break; case FbnBinaryChunkType.Type19: Block19Entries = reader.ReadList <FbnTriggerVolume>(type, field04); break; case FbnBinaryChunkType.Type22: Block22Entries = reader.ReadList <FbnTriggerVolume>(type, field04); break; default: throw new NotImplementedException($"Reading block type {type} is not yet implemented"); } reader.SeekBegin(endPosition); } }
public FbnBinary(Stream stream, bool leaveOpen) : this() { using (var reader = new FbnBinaryReader(stream, Encoding.Default, leaveOpen, Endianness.Big)) Read(reader); }