Beispiel #1
0
        public FbnBinaryList <T> ReadList <T>(FbnBinaryChunkType type, int field04) where T : class, IFbnListEntry
        {
            var list = new FbnBinaryList <T>(type, field04);

            ReadList(list);
            return(list);
        }
Beispiel #2
0
        public void ReadList <T>(FbnBinaryList <T> list) where T : class, IFbnListEntry
        {
            var entryCount = ReadInt32();

            SeekCurrent(12);

            for (int i = 0; i < entryCount; i++)
            {
                var entry = ReadListEntry(list.Type);
                list.Add(( T )entry);
            }
        }
Beispiel #3
0
        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);
            }
        }
Beispiel #4
0
        public void WriteList <T>(FbnBinaryList <T> list, int alignment = -1) where T : IFbnListEntry
        {
            if (list == null)
            {
                return;
            }

            WriteChunk(list, () =>
            {
                // List header
                Write(list.Count);
                Write(0);
                Write(0);
                Write(0);

                // Write entries
                WriteObjects(list);

                if (alignment > 0)
                {
                    Align(alignment);
                }
            });
        }