Beispiel #1
0
        public void Write(BinaryWriter writer)
        {
            version = DATA_VERSION;
            var start = writer.BaseStream.Position;

            writer.Write(version);
            writer.Write(modid);
            var overwritePosition = writer.BaseStream.Position;

            writer.Write((long)0);
            if (!(SRModLoader.GetMod(modid) is SRMod mod))
            {
                throw new Exception($"Unrecognized mod id: {modid}");
            }
            var saveInfo = SaveRegistry.GetSaveInfo(mod);

            writer.Write(identifiableData.Count);
            foreach (var data in identifiableData)
            {
                data.Write(writer, saveInfo);
            }

            writer.Write(extendedData.Count);
            foreach (var data in extendedData)
            {
                data.Write(writer);
            }

            playerData.Write(writer);
            pediaData.Write(writer);

            BinaryUtils.WriteDictionary(writer, customAmmo, (x, y) => AmmoIdentifier.Write(y, x), (x, y) =>
            {
                x.Write(y.Count);
                foreach (var v in y)
                {
                    x.Write(v != null);
                    if (v != null)
                    {
                        v.Write(x.BaseStream);
                    }
                }
            });

            DataPiece.Serialize(writer, extendedWorldData);

            worldData.Write(writer);

            var cur = writer.BaseStream.Position;

            writer.BaseStream.Seek(overwritePosition, SeekOrigin.Begin);
            byteLength = cur - (start);
            writer.Write(byteLength);
            writer.BaseStream.Seek(cur, SeekOrigin.Begin);
        }
 public void Write(BinaryWriter writer)
 {
     AmmoIdentifier.Write(identifier, writer);
     model.Write(writer);
 }