Beispiel #1
0
        public void Read(EndianBinaryReader reader)
        {
            XData = new XData(reader);
            if (reader.ReadUInt32() != 10100)
            {
                throw new InvalidDataException("Invalid CND Binary");
            }

            reader.BaseStream.Seek(0x20, SeekOrigin.Begin);
            uint visOffs  = reader.ReadUInt32();
            uint unk1     = reader.ReadUInt32();
            uint nameOffs = reader.ReadUInt32();
            uint typeOffs = reader.ReadUInt32();
            uint rndOffs  = reader.ReadUInt32();

            reader.BaseStream.Seek(nameOffs, SeekOrigin.Begin);
            Name = Encoding.UTF8.GetString(reader.ReadBytes(reader.ReadInt32()));
            reader.BaseStream.Seek(typeOffs, SeekOrigin.Begin);
            Type = Encoding.UTF8.GetString(reader.ReadBytes(reader.ReadInt32()));

            VisualSection = new List <CNDStruct>();
            reader.BaseStream.Seek(visOffs, SeekOrigin.Begin);
            uint visCount = reader.ReadUInt32();

            for (int i = 0; i < visCount; i++)
            {
                reader.BaseStream.Seek(visOffs + 4 + (i * 4), SeekOrigin.Begin);
                reader.BaseStream.Seek(reader.ReadUInt32(), SeekOrigin.Begin);
                VisualSection.Add(new CNDStruct(reader));
            }

            RenderSection = new List <CNDStruct>();
            reader.BaseStream.Seek(rndOffs, SeekOrigin.Begin);
            uint rndCount = reader.ReadUInt32();

            for (int i = 0; i < rndCount; i++)
            {
                reader.BaseStream.Seek(rndOffs + 4 + (i * 4), SeekOrigin.Begin);
                reader.BaseStream.Seek(reader.ReadUInt32(), SeekOrigin.Begin);
                RenderSection.Add(new CNDStruct(reader));
            }

            if (VisualSection.Count > 0)
            {
                if (VisualSection[0].Groups[0].Name != "")
                {
                    NewVersion = true;
                }
                else if (RenderSection.Count > 0)
                {
                    if (RenderSection[0].Groups[0].Name != "")
                    {
                        NewVersion = true;
                    }
                }
            }
        }
Beispiel #2
0
 public CNDBin(string name, string type, bool isNewVersion, Endianness endianness)
 {
     XData         = new XData(endianness);
     Name          = name;
     Type          = type;
     VisualSection = new List <CNDStruct>();
     RenderSection = new List <CNDStruct>();
     NewVersion    = isNewVersion;
 }