Exemple #1
0
 public void Read(bool hasTypeTree, AssetsFileReader reader, uint version)
 {
     classId = reader.ReadInt32();
     if (version >= 0x10)
     {
         unknown16_1 = reader.ReadByte();
     }
     if (version >= 0x11)
     {
         scriptIndex = reader.ReadUInt16();
     }
     else
     {
         scriptIndex = 0xffff;
     }
     if ((version < 0x11 && classId < 0) || (version >= 0x11 && classId == 0x72))
     {
         scriptHash1 = reader.ReadUInt32();
         scriptHash2 = reader.ReadUInt32();
         scriptHash3 = reader.ReadUInt32();
         scriptHash4 = reader.ReadUInt32();
     }
     typeHash1 = reader.ReadUInt32();
     typeHash2 = reader.ReadUInt32();
     typeHash3 = reader.ReadUInt32();
     typeHash4 = reader.ReadUInt32();
     if (hasTypeTree)
     {
         typeFieldsExCount = reader.ReadUInt32();
         stringTableLen    = reader.ReadUInt32();
         typeFieldsEx      = new TypeField_0D[typeFieldsExCount];
         for (int i = 0; i < typeFieldsExCount; i++)
         {
             TypeField_0D typefield0d = new TypeField_0D();
             typefield0d.Read(reader, version);
             typeFieldsEx[i] = typefield0d;
         }
         stringTable = Encoding.UTF8.GetString(reader.ReadBytes((int)stringTableLen));
         if (version >= 0x15)
         {
             dependenciesCount = reader.ReadInt32();
             dependencies      = new int[dependenciesCount];
             for (int i = 0; i < dependenciesCount; i++)
             {
                 dependencies[i] = reader.ReadInt32();
             }
         }
     }
 }
        ///public AssetTypeTemplateField()
        ///public void Clear()
        public bool From0D(Type_0D u5Type, int fieldIndex)
        {
            TypeField_0D field = u5Type.typeFieldsEx[fieldIndex];

            name      = field.GetNameString(u5Type.stringTable);
            type      = field.GetTypeString(u5Type.stringTable);
            valueType = AssetTypeValueField.GetValueTypeByTypeName(type);
            isArray   = field.isArray == 1 ? true : false;
            align     = (field.flags & 0x4000) != 0x00 ? true : false;
            hasValue  = (valueType == EnumValueTypes.ValueType_None) ? false : true;

            List <int> childrenIndexes = new List <int>();
            int        thisDepth       = u5Type.typeFieldsEx[fieldIndex].depth;

            for (int i = fieldIndex + 1; i < u5Type.typeFieldsExCount; i++)
            {
                if (u5Type.typeFieldsEx[i].depth == thisDepth + 1)
                {
                    childrenCount++;
                    childrenIndexes.Add(i);
                }
                if (u5Type.typeFieldsEx[i].depth <= thisDepth)
                {
                    break;
                }
            }
            children = new AssetTypeTemplateField[childrenCount];
            int child = 0;

            for (int i = fieldIndex + 1; i < u5Type.typeFieldsExCount; i++)
            {
                if (u5Type.typeFieldsEx[i].depth == thisDepth + 1)
                {
                    children[child] = new AssetTypeTemplateField();
                    children[child].From0D(u5Type, childrenIndexes[child]);
                    child++;
                }
                if (u5Type.typeFieldsEx[i].depth <= thisDepth)
                {
                    break;
                }
            }
            return(true);
        }
Exemple #3
0
 public ulong Read(bool hasTypeTree, ulong absFilePos, AssetsFileReader reader, uint version, uint typeVersion, bool bigEndian)
 {
     classId = reader.ReadInt32();
     if (version >= 0x10)
     {
         unknown16_1 = reader.ReadByte();
     }
     if (version >= 0x11)
     {
         scriptIndex = reader.ReadUInt16();
     }
     //if ((version < 0x11 && classId < 0) || (version >= 0x11 && scriptIndex != 0xFFFF)) //original is if (classId == 114)
     //if ((version < 0x11 && classId < 0) || (version >= 0x11 && scriptIndex != 0xFFFF))
     if ((version < 0x11 && classId < 0) || (version >= 0x11 && classId == 114))
     {
         unknown1 = reader.ReadUInt32();
         unknown2 = reader.ReadUInt32();
         unknown3 = reader.ReadUInt32();
         unknown4 = reader.ReadUInt32();
     }
     unknown5 = reader.ReadUInt32();
     unknown6 = reader.ReadUInt32();
     unknown7 = reader.ReadUInt32();
     unknown8 = reader.ReadUInt32();
     if (hasTypeTree)
     {
         typeFieldsExCount = reader.ReadUInt32();
         stringTableLen    = reader.ReadUInt32();
         pTypeFieldsEx     = new TypeField_0D[typeFieldsExCount];
         for (int i = 0; i < typeFieldsExCount; i++)
         {
             TypeField_0D typefield0d = new TypeField_0D();
             typefield0d.Read(reader.Position, reader, version, bigEndian);
             pTypeFieldsEx[i] = typefield0d;
         }
         pStringTable = Encoding.UTF8.GetString(reader.ReadBytes((int)stringTableLen));
     }
     return(reader.Position);
 }