private static MeshTextureObject ReadMTO(BinaryReader reader)
        {
            MeshTextureObject obj3 = new MeshTextureObject {
                Mesh    = IOFunctions.ReadZeroTerminatedUnicode(reader),
                Texture = IOFunctions.ReadZeroTerminatedUnicode(reader),
                Bool1   = reader.ReadBoolean(),
                Bool2   = reader.ReadBoolean()
            };

            return(obj3);
        }
        // read from file
        public UnitVariantFile Decode(Stream stream)
        {
            UnitVariantFile file = new UnitVariantFile();

            using (BinaryReader reader = new BinaryReader(stream)) {
                byte[] buffer = reader.ReadBytes(4);
                if ((((buffer [0] != 0x56) || (buffer [1] != 0x52)) || (buffer [2] != 0x4e)) || (buffer [3] != 0x54))
                {
                    throw new FileLoadException("Illegal unit_variant file: Does not start with 'VRNT'");
                }
                file.Version = reader.ReadUInt32();
                int entries = (int)reader.ReadUInt32();
                file.Unknown1 = reader.ReadUInt32();
                byte[] buffer3 = reader.ReadBytes(4);
                file.B1       = buffer3 [0];
                file.B2       = buffer3 [1];
                file.B3       = buffer3 [2];
                file.B4       = buffer3 [3];
                file.Unknown2 = BitConverter.ToUInt32(buffer3, 0);
                if (file.Version == 2)
                {
                    file.Unknown3 = reader.ReadInt32();
                }
                file.UnitVariantObjects = new List <UnitVariantObject> (entries);
                for (int i = 0; i < entries; i++)
                {
                    UnitVariantObject item = ReadObject(reader);
                    file.UnitVariantObjects.Add(item);
                }
                for (int j = 0; j < file.UnitVariantObjects.Count; j++)
                {
                    for (int k = 0; k < file.UnitVariantObjects[j].StoredEntryCount; k++)
                    {
                        MeshTextureObject mto = ReadMTO(reader);
                        file.UnitVariantObjects [j].MeshTextureList.Add(mto);
                    }
                }
            }
            return(file);
        }
Exemplo n.º 3
0
 public void RemoveMesh(MeshTextureObject mto)
 {
     MeshTextureList.Remove(mto);
 }
Exemplo n.º 4
0
 public void AddMesh(MeshTextureObject mto)
 {
     MeshTextureList.Add(mto);
 }