コード例 #1
0
        public Character Read()
        {
            var character   = new Character();
            var magicNumber = ReadMagicNumber();

            ValidateMagicNumber(magicNumber);

            var schemaVersion = _reader.ReadSingle();

            character.Version = SchemaVersion.Find(schemaVersion);

            character.UseQualifiedNames = _reader.ReadBoolean();
            character.UseSubpowerFields = _reader.ReadBoolean();

            // archetype
            character.Archetype = new ArchetypeReader(_reader).Read();

            // alignment is a lookup value
            // ideally this would be data driven
            if (character.Version > SchemaVersion.v1_0_0)
            {
                character.Alignment = Alignment.Find(_reader.ReadInt32(), string.Empty);
            }

            character.Name = _reader.ReadString();

            // read the first build with a build reader
            // if multiple builds are supported in the future, I assume it will be a version bump
            character.Builds = new List <Build>();
            var build = new BuildReader(character, _reader).Read();

            character.Builds.Add(build);

            return(character);
        }