Beispiel #1
0
        public static KoiCard ParseKoiChara(FileInfo file, BinaryReader reader, CardType gameType)
        {
            var loadVersion = new Version(reader.ReadString());

            if (0 > new Version("0.0.0").CompareTo(loadVersion))
            {
                //return null;
            }

            var faceLength = reader.ReadInt32();

            if (faceLength > 0)
            {
                //this.facePngData = reader.ReadBytes(num);
                reader.BaseStream.Seek(faceLength, SeekOrigin.Current);
            }

            var count       = reader.ReadInt32();
            var bytes       = reader.ReadBytes(count);
            var blockHeader = MessagePackSerializer.Deserialize <BlockHeader>(bytes);
            var num2        = reader.ReadInt64();
            var position    = reader.BaseStream.Position;

            ChaFileParameter parameter = null;
            var info = blockHeader.SearchInfo(ChaFileParameter.BlockName);

            if (info != null)
            {
                var value = new Version(info.version);
                if (0 <= ChaFileParameter.CurrentVersion.CompareTo(value))
                {
                    reader.BaseStream.Seek(position + info.pos, SeekOrigin.Begin);
                    var parameterBytes = reader.ReadBytes((int)info.size);

                    parameter = MessagePackSerializer.Deserialize <ChaFileParameter>(parameterBytes);
                    parameter.ComplementWithVersion();
                }
            }

            Dictionary <string, PluginData> extData = null;

            info = blockHeader.SearchInfo(ChaFileExtended.BlockName);
            if (info != null)
            {
                reader.BaseStream.Seek(position + info.pos, SeekOrigin.Begin);
                var parameterBytes = reader.ReadBytes((int)info.size);

                extData = MessagePackSerializer.Deserialize <Dictionary <string, PluginData> >(parameterBytes);
            }

            var card = new KoiCard(file, gameType, extData, parameter);

            return(card);
        }
Beispiel #2
0
 private KoiCard(FileInfo cardFile, CardType type, Dictionary <string, PluginData> extended, ChaFileParameter parameter) : base(cardFile, type, extended)
 {
     Parameter = parameter;
 }