Ejemplo n.º 1
0
        public void Read(BinaryReader reader, ModSaveInfo info)
        {
            dataLength    = reader.ReadInt64();
            dataID        = DataIdentifier.Read(reader);
            IsCustomModel = reader.ReadBoolean();
            switch (dataID.Type)
            {
            case IdentifierType.ACTOR:
                ReadData <CustomActorData, VanillaActorData>(reader, info);
                break;

            case IdentifierType.GADGET:
                ReadData <CustomGadgetData, VanillaGadgetData>(reader, info);
                break;

            case IdentifierType.LANDPLOT:
                ReadData <CustomLandPlotData, VanillaPlotData>(reader, info);
                break;

            case IdentifierType.GORDO:
                ReadData <GordoV01>(reader);
                break;

            case IdentifierType.TREASUREPOD:
                ReadData <TreasurePodV01>(reader);
                break;

            case IdentifierType.EXCHANGEOFFER:
                ReadData <ExchangeOfferV04>(reader);
                break;

            default:
                throw new NotImplementedException();
            }
        }
Ejemplo n.º 2
0
        public void Read(BinaryReader reader, ModSaveInfo info)
        {
            dataLength    = reader.ReadInt64();
            dataID        = DataIdentifier.Read(reader);
            IsCustomModel = reader.ReadBoolean();
            switch (dataID.Type)
            {
            case IdentifierType.ACTOR:
                ReadData <CustomActorData, VanillaActorData>(reader, info);
                break;

            case IdentifierType.GADGET:
                ReadData <CustomGadgetData, VanillaGadgetData>(reader, info);
                break;

            default:
                throw new NotImplementedException();
            }
        }
Ejemplo n.º 3
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;
                        }
                    }
                }
            }
        }