Exemplo n.º 1
0
        public void ReadData(BinaryReader reader)
        {
            ammoDataEntries.Clear();

            int count = reader.ReadInt32();

            for (int i = 0; i < count; i++)
            {
                var newEntry = new IdentifiableAmmoData();
                newEntry.Read(reader);

                ammoDataEntries.Add(newEntry);
            }

            segments.Clear();
            count = reader.ReadInt32();
            for (int i = 0; i < count; i++)
            {
                long start = reader.BaseStream.Position;
                var  mod   = new ModDataSegment();
                try
                {
                    mod.Read(reader);
                    segments.Add(mod);
                }
                catch (Exception e)
                {
                    Debug.Log($"Encountered exception {e}\nskipping loading {mod.modid} skipping {mod.byteLength} bytes in the stream");
                    reader.BaseStream.Seek(start + mod.byteLength, SeekOrigin.Begin);
                }
            }
        }
Exemplo n.º 2
0
        public void ReadData(BinaryReader reader)
        {
            ammoDataEntries.Clear();

            int count = reader.ReadInt32();

            for (int i = 0; i < count; i++)
            {
                var newEntry = new IdentifiableAmmoData();
                newEntry.Read(reader);

                ammoDataEntries.Add(newEntry);
            }

            segments.Clear();
            count = reader.ReadInt32();
            for (int i = 0; i < count; i++)
            {
                long start = reader.BaseStream.Position;
                var  mod   = new ModDataSegment();
                try
                {
                    mod.Read(reader);
                    segments.Add(mod);
                }
                catch (Exception e)
                {
                    Debug.Log($"Encountered exception {e}\nskipping loading {mod.modid} skipping {mod.byteLength} bytes in the stream");
                    reader.BaseStream.Seek(start + mod.byteLength, SeekOrigin.Begin);
                }
            }

            if (version >= 1)
            {
                enumTranslator = new EnumTranslator();
                enumTranslator.Read(reader);
                if (version >= 2)
                {
                    partialData.Clear();
                    count = reader.ReadInt32();
                    for (int i = 0; i < count; i++)
                    {
                        var id       = DataIdentifier.Read(reader);
                        var dataType = DataIdentifier.IdentifierTypeToData[id.Type];
                        if (PartialData.TryGetPartialData(dataType, out var data))
                        {
                            data.Read(reader);
                            partialData[id] = data;
                        }
                        else
                        {
                            Debug.LogError("No partial data for data identifier type " + id.Type);
                        }
                    }
                    if (version >= 3)
                    {
                        try
                        {
                            appearancesData.Read(reader);
                        }
                        catch (Exception e)
                        {
                            throw;
                        }
                    }
                }
            }
        }