Ejemplo n.º 1
0
        // ---- METHODS ------------------------------------------------------------------------------------------------

        void IResData.Load(ResFileLoader loader)
        {
            if (loader.ResFile.Version >= 0x03040000)
            {
                loader.CheckSignature(_signature);
            }
            else
            {
                loader.ReadChars(4);
            }
            Name   = loader.LoadString();
            Path   = loader.LoadString();
            _flags = loader.ReadUInt16();
            ushort numAnim  = 0;
            ushort numCurve = 0;

            if (loader.ResFile.Version >= 0x03040000)
            {
                ushort numUserData = loader.ReadUInt16();
                FrameCount = loader.ReadInt32();
                numAnim    = loader.ReadUInt16();
                numCurve   = loader.ReadUInt16();
                BakedSize  = loader.ReadUInt32();
            }
            else
            {
                FrameCount = loader.ReadInt16();
                numAnim    = loader.ReadUInt16();
                numCurve   = loader.ReadUInt16();
                ushort numUserData = loader.ReadUInt16();
                BakedSize = loader.ReadUInt32();
                int padding2 = loader.ReadInt16();
            }
            BindModel    = loader.Load <Model>();
            BindIndices  = loader.LoadCustom(() => loader.ReadUInt16s(numAnim));
            Names        = loader.LoadCustom(() => loader.LoadStrings(numAnim)); // Offset to name list.
            Curves       = loader.LoadList <AnimCurve>(numCurve);
            BaseDataList = loader.LoadCustom(() =>
            {
                bool[] baseData = new bool[numAnim];
                int i           = 0;
                while (i < numAnim)
                {
                    byte b = loader.ReadByte();
                    for (int j = 0; j < 8 && i < numAnim; j++)
                    {
                        baseData[i++] = b.GetBit(j);
                    }
                }
                return(baseData);
            });
            UserData = loader.LoadDict <UserData>();
        }
Ejemplo n.º 2
0
        // ---- METHODS ------------------------------------------------------------------------------------------------

        void IResData.Load(ResFileLoader loader)
        {
            if (loader.IsSwitch)
            {
                Name = loader.LoadString();
                uint DataOffset = loader.ReadOffset();
                uint count      = 0;
                if (loader.ResFile.VersionMajor2 <= 2 && loader.ResFile.VersionMajor == 0)
                {
                    char[] Reserved = loader.ReadChars(8);
                    count = loader.ReadUInt32();
                    Type  = (UserDataType)loader.ReadUInt32();
                }
                else
                {
                    count = loader.ReadUInt32();
                    Type  = loader.ReadEnum <UserDataType>(true);
                    char[] Reserved = loader.ReadChars(43);
                }

                switch (Type)
                {
                case UserDataType.Byte:
                    _value = loader.LoadCustom(() => loader.ReadSBytes((int)count), DataOffset);
                    break;

                case UserDataType.Int32:
                    _value = loader.LoadCustom(() => loader.ReadInt32s((int)count), DataOffset);
                    break;

                case UserDataType.Single:
                    _value = loader.LoadCustom(() => loader.ReadSingles((int)count), DataOffset);
                    break;

                case UserDataType.String:
                    _value = loader.LoadCustom(() => loader.LoadStrings((int)count, Encoding.UTF8), DataOffset);
                    break;

                case UserDataType.WString:
                    _value = loader.LoadCustom(() => loader.LoadStrings((int)count, Encoding.Unicode), DataOffset);
                    break;
                }
            }
            else
            {
                Name = loader.LoadString();
                ushort count = loader.ReadUInt16();
                Type = loader.ReadEnum <UserDataType>(true);
                loader.Seek(1);
                switch (Type)
                {
                case UserDataType.Int32:
                    _value = loader.ReadInt32s(count);
                    break;

                case UserDataType.Single:
                    _value = loader.ReadSingles(count);
                    break;

                case UserDataType.String:
                    _value = loader.LoadStrings(count, Encoding.UTF8);
                    break;

                case UserDataType.WString:
                    _value = loader.LoadStrings(count, Encoding.Unicode);
                    break;

                case UserDataType.Byte:
                    _value = loader.ReadBytes(count);
                    break;
                }
            }
        }