Beispiel #1
0
        public void Read(Stream stream)
        {
            if (stream.ReadU32() != 0x3027)
            {
                throw new NotAVintFileException();
            }

            int nameIndex = stream.ReadS32();

            this.DocumentType = stream.ReadU16();
            if (this.DocumentType != 1)
            {
                throw new UnsupportedVintFileVersionException();
            }

            this.AnimationTime = stream.ReadF32();
            UInt32 metadataCount         = stream.ReadU32();
            UInt32 criticalResourceCount = stream.ReadU32();

            this.ReadStrings(stream, stream.ReadU32());
            UInt16 elementCount   = stream.ReadU16();
            UInt16 animationCount = stream.ReadU16();

            // not absolutely sure this is the name index... so...
            if (nameIndex != 0)
            {
                throw new Exception();
            }

            this.Name = this.Strings[nameIndex];

            for (int i = 0; i < criticalResourceCount; i++)
            {
                byte unk1 = stream.ReadU8();
                int  criticalResourceIndex = stream.ReadS32();
                if (unk1 == 0)
                {
                    this.CriticalResources.Add(this.Strings[criticalResourceIndex]);
                }
            }

            this.Metadata.Clear();
            for (int i = 0; i < metadataCount; i++)
            {
                int key   = stream.ReadS32();
                int value = stream.ReadS32();
                this.Metadata[this.Strings[key]] = this.Strings[value];
            }

            for (int i = 0; i < elementCount; i++)
            {
                VintObject element = new VintObject();
                element.Read(stream, this);
                this.Elements.Add(element);
            }

            for (int i = 0; i < animationCount; i++)
            {
                VintObject animation = new VintObject();
                animation.Read(stream, this);
                this.Animations.Add(animation);
            }
        }
Beispiel #2
0
        public void Read(Stream stream, VintFile vint)
        {
            this.Name = vint.Strings[stream.ReadS32()];
            this.Type = vint.Strings[stream.ReadS32()];
            UInt16 childCount = stream.ReadU16();

            byte unk4 = stream.ReadU8();

            UInt32 unk5 = stream.ReadU32();

            this.Overrides.Clear();
            if (stream.ReadU8() > 0)
            {
                string overrideName = vint.Strings[stream.ReadS32()];
                /*UInt32 overrideSize =*/ stream.ReadU32();

                if (this.Overrides.ContainsKey(overrideName))
                {
                    throw new Exception("duplicate override name");
                }

                this.Overrides[overrideName] = new Dictionary <string, VintProperty>();

                while (true)
                {
                    byte propertyType = stream.ReadU8();
                    if (propertyType == 0)
                    {
                        break;
                    }

                    UInt32 hash         = stream.ReadU32();
                    string propertyName = VintPropertyNames.Lookup(hash);
                    if (this.Overrides[overrideName].ContainsKey(propertyName))
                    {
                        throw new Exception("duplicate override property name");
                    }
                    this.Overrides[overrideName][propertyName] = this.GetProperty(stream, propertyType);
                    this.Overrides[overrideName][propertyName].Read(stream, vint);
                }
            }

            this.Baseline.Clear();
            while (true)
            {
                byte propertyType = stream.ReadU8();
                if (propertyType == 0)
                {
                    break;
                }

                UInt32 hash         = stream.ReadU32();
                string propertyName = VintPropertyNames.Lookup(hash);
                if (this.Baseline.ContainsKey(propertyName))
                {
                    throw new Exception("duplicate baseline property name");
                }
                this.Baseline[propertyName] = this.GetProperty(stream, propertyType);
                this.Baseline[propertyName].Read(stream, vint);
            }

            for (int i = 0; i < childCount; i++)
            {
                VintObject child = new VintObject();
                child.Read(stream, vint);
                this.Children.Add(child);
            }
        }