// ---- METHODS ------------------------------------------------------------------------------------------------

        void IResData.Load(ResFileLoader loader)
        {
            CurveIndex   = loader.ReadSByte();
            SubBindIndex = loader.ReadSByte();
            loader.Seek(2);
            Name = loader.LoadString();
        }
Ejemplo n.º 2
0
        // ---- METHODS ------------------------------------------------------------------------------------------------

        void IResData.Load(ResFileLoader loader)
        {
            loader.CheckSignature(_signature);
            if (loader.IsSwitch)
            {
                Switch.LightAnimParser.Read((Switch.Core.ResFileSwitchLoader)loader, this);
            }
            else
            {
                Flags = loader.ReadEnum <LightAnimFlags>(true);
                ushort numUserData = loader.ReadUInt16();
                FrameCount = loader.ReadInt32();
                byte numCurve = loader.ReadByte();
                LightTypeIndex        = loader.ReadSByte();
                DistanceAttnFuncIndex = loader.ReadSByte();
                AngleAttnFuncIndex    = loader.ReadSByte();
                BakedSize             = loader.ReadUInt32();
                Name                 = loader.LoadString();
                LightTypeName        = loader.LoadString();
                DistanceAttnFuncName = loader.LoadString();
                AngleAttnFuncName    = loader.LoadString();
                Curves               = loader.LoadList <AnimCurve>(numCurve);
                BaseData             = loader.LoadCustom(() => new LightAnimData(loader, AnimatedFields));
                UserData             = loader.LoadDict <UserData>();
            }
        }
Ejemplo n.º 3
0
        // ---- METHODS ------------------------------------------------------------------------------------------------

        void IResData.Load(ResFileLoader loader)
        {
            if (loader.IsSwitch)
            {
                Name         = loader.LoadString();
                CurveIndex   = loader.ReadSByte();
                SubBindIndex = loader.ReadSByte();
                loader.Seek(6);
            }
            else
            {
                CurveIndex   = loader.ReadSByte();
                SubBindIndex = loader.ReadSByte();
                loader.Seek(2);
                Name = loader.LoadString();
            }
        }
Ejemplo n.º 4
0
        // ---- METHODS ------------------------------------------------------------------------------------------------

        void IResData.Load(ResFileLoader loader)
        {
            if (loader.IsSwitch)
            {
                Name          = loader.LoadString();
                CurveIndex    = loader.ReadInt16();
                BeginConstant = loader.ReadUInt16();
                SubBindIndex  = loader.ReadSByte();
                loader.Seek(3); //padding
            }
            else
            {
                CurveIndex   = loader.ReadSByte();
                SubBindIndex = loader.ReadSByte();
                loader.Seek(2);
                Name = loader.LoadString();
            }
        }
Ejemplo n.º 5
0
        void IResData.Load(ResFileLoader loader)
        {
            loader.CheckSignature(_signature);
            Flags      = loader.ReadEnum <FogAnimFlags>(true);
            FrameCount = loader.ReadInt32();
            byte numCurve = loader.ReadByte();

            DistanceAttnFuncIndex = loader.ReadSByte();
            ushort numUserData = loader.ReadUInt16();

            BakedSize            = loader.ReadUInt32();
            Name                 = loader.LoadString();
            DistanceAttnFuncName = loader.LoadString();
            Curves               = loader.LoadList <AnimCurve>(numCurve);
            BaseData             = loader.LoadCustom(() => new FogAnimData(loader));
            UserData             = loader.LoadDict <UserData>();
        }
Ejemplo n.º 6
0
        // ---- METHODS ------------------------------------------------------------------------------------------------

        void IResData.Load(ResFileLoader loader)
        {
            _flags = loader.ReadUInt16();
            ushort numKey = loader.ReadUInt16();

            AnimDataOffset = loader.ReadUInt32();
            StartFrame     = loader.ReadSingle();
            EndFrame       = loader.ReadSingle();
            Scale          = loader.ReadSingle();
            Offset         = loader.ReadSingle();
            if (loader.ResFile.Version >= 0x03040000)
            {
                Delta = loader.ReadSingle();
            }
            Frames = loader.LoadCustom(() =>
            {
                switch (FrameType)
                {
                case AnimCurveFrameType.Single:
                    return(loader.ReadSingles(numKey));

                case AnimCurveFrameType.Decimal10x5:
                    float[] dec10x5Frames = new float[numKey];
                    for (int i = 0; i < numKey; i++)
                    {
                        dec10x5Frames[i] = (float)loader.ReadDecimal10x5();
                    }
                    return(dec10x5Frames);

                case AnimCurveFrameType.Byte:
                    float[] byteFrames = new float[numKey];
                    for (int i = 0; i < numKey; i++)
                    {
                        byteFrames[i] = loader.ReadByte();
                    }
                    return(byteFrames);

                default:
                    throw new ResException($"Invalid {nameof(FrameType)}.");
                }
            });
            Keys = loader.LoadCustom(() =>
            {
                int elementsPerKey = ElementsPerKey;
                float[,] keys      = new float[numKey, elementsPerKey];
                switch (KeyType)
                {
                case AnimCurveKeyType.Single:
                    for (int i = 0; i < numKey; i++)
                    {
                        keys[i, 0] = loader.ReadSingle();
                    }
                    break;

                case AnimCurveKeyType.Int16:
                    for (int i = 0; i < numKey; i++)
                    {
                        for (int j = 0; j < elementsPerKey; j++)
                        {
                            keys[i, j] = loader.ReadUInt16();
                        }
                    }
                    break;

                case AnimCurveKeyType.SByte:
                    for (int i = 0; i < numKey; i++)
                    {
                        for (int j = 0; j < elementsPerKey; j++)
                        {
                            keys[i, j] = loader.ReadSByte();
                        }
                    }
                    break;

                default:
                    throw new ResException($"Invalid {nameof(KeyType)}.");
                }
                return(keys);
            });
        }
Ejemplo n.º 7
0
        // ---- METHODS ------------------------------------------------------------------------------------------------

        void IResData.Load(ResFileLoader loader)
        {
            _flags = loader.ReadUInt16();
            ushort numKey = loader.ReadUInt16();

            AnimDataOffset = loader.ReadUInt32();
            StartFrame     = loader.ReadSingle();
            EndFrame       = loader.ReadSingle();
            Scale          = loader.ReadSingle();
            Offset         = loader.ReadSingle();
            if (loader.ResFile.Version >= 0x03040000)
            {
                Delta = loader.ReadSingle();
            }

            Frames = loader.LoadCustom(() =>
            {
                switch (FrameType)
                {
                case AnimCurveFrameType.Single:
                    if (CurveType == AnimCurveType.StepInt)
                    {
                        float[] dec10x5Frame = new float[numKey];
                        for (int i = 0; i < numKey; i++)
                        {
                            dec10x5Frame[i] = loader.ReadUInt32();
                        }
                        return(dec10x5Frame);
                    }
                    else
                    {
                        return(loader.ReadSingles(numKey));
                    }

                case AnimCurveFrameType.Decimal10x5:
                    float[] dec10x5Frames = new float[numKey];
                    for (int i = 0; i < numKey; i++)
                    {
                        dec10x5Frames[i] = (float)loader.ReadDecimal10x5();
                    }
                    return(dec10x5Frames);

                case AnimCurveFrameType.Byte:
                    float[] byteFrames = new float[numKey];
                    for (int i = 0; i < numKey; i++)
                    {
                        byteFrames[i] = loader.ReadByte();
                    }
                    return(byteFrames);

                default:
                    throw new ResException($"Invalid {nameof(FrameType)}.");
                }
            });

            //Bools use bits to store values.
            if (CurveType == AnimCurveType.StepBool)
            {
                int KeyBool = 0;

                if (KeyType == AnimCurveKeyType.Single) //Read them as a int instead of a float
                {
                    KeyBool = loader.LoadCustom(() => loader.ReadInt32());
                }
                else if (KeyType == AnimCurveKeyType.Int16)
                {
                    KeyBool = loader.LoadCustom(() => loader.ReadInt16());
                }
                else if (KeyType == AnimCurveKeyType.SByte)
                {
                    KeyBool = loader.LoadCustom(() => loader.ReadSByte());
                }

                KeyStepBoolData = new bool[numKey];

                for (int i = 0; i < numKey; i++)
                {
                    bool set = (KeyBool & 0x1) != 0;
                    KeyBool >>= 1;

                    KeyStepBoolData[i] = set;
                }
            }
            else
            {
                Keys = loader.LoadCustom(() =>
                {
                    int elementsPerKey = ElementsPerKey;
                    float[,] keys      = new float[numKey, elementsPerKey];
                    switch (KeyType)
                    {
                    case AnimCurveKeyType.Single:
                        for (int i = 0; i < numKey; i++)
                        {
                            for (int j = 0; j < elementsPerKey; j++)
                            {
                                if (CurveType == AnimCurveType.StepInt)
                                {
                                    keys[i, j] = loader.ReadUInt32();
                                }
                                else
                                {
                                    keys[i, j] = loader.ReadSingle();
                                }
                            }
                        }
                        break;

                    case AnimCurveKeyType.Int16:
                        for (int i = 0; i < numKey; i++)
                        {
                            for (int j = 0; j < elementsPerKey; j++)
                            {
                                keys[i, j] = loader.ReadInt16();
                            }
                        }
                        break;

                    case AnimCurveKeyType.SByte:
                        for (int i = 0; i < numKey; i++)
                        {
                            for (int j = 0; j < elementsPerKey; j++)
                            {
                                keys[i, j] = loader.ReadSByte();
                            }
                        }
                        break;

                    default:
                        throw new ResException($"Invalid {nameof(KeyType)}.");
                    }
                    return(keys);
                });
            }
        }
Ejemplo n.º 8
0
        void IResData.Load(ResFileLoader loader)
        {
            long   FrameArrayOffset = 0;
            long   KeyArrayOffset   = 0;
            ushort numKey           = 0;

            if (loader.IsSwitch)
            {
                FrameArrayOffset = loader.ReadOffset();
                KeyArrayOffset   = loader.ReadOffset();
                _flags           = loader.ReadUInt16();
                numKey           = loader.ReadUInt16();
                AnimDataOffset   = loader.ReadUInt32();
                StartFrame       = loader.ReadSingle();
                EndFrame         = loader.ReadSingle();
                Scale            = loader.ReadSingle();
                Offset           = loader.ReadSingle();
                Delta            = loader.ReadSingle();
                int padding = loader.ReadInt32();
            }
            else
            {
                _flags         = loader.ReadUInt16();
                numKey         = loader.ReadUInt16();
                AnimDataOffset = loader.ReadUInt32();
                StartFrame     = loader.ReadSingle();
                EndFrame       = loader.ReadSingle();
                Scale          = loader.ReadSingle();
                Offset         = loader.ReadSingle();
                if (loader.ResFile.Version >= 0x03040000)
                {
                    Delta = loader.ReadSingle();
                }
                FrameArrayOffset = loader.ReadOffset();
                KeyArrayOffset   = loader.ReadOffset();
            }

            Frames = loader.LoadCustom(() =>
            {
                switch (FrameType)
                {
                case AnimCurveFrameType.Single:
                    return(loader.ReadSingles(numKey));

                case AnimCurveFrameType.Decimal10x5:
                    float[] dec10x5Frames = new float[numKey];
                    for (int i = 0; i < numKey; i++)
                    {
                        dec10x5Frames[i] = (float)loader.ReadDecimal10x5();
                    }
                    return(dec10x5Frames);

                case AnimCurveFrameType.Byte:
                    float[] byteFrames = new float[numKey];
                    for (int i = 0; i < numKey; i++)
                    {
                        byteFrames[i] = loader.ReadByte();
                    }
                    return(byteFrames);

                default:
                    throw new ResException($"Invalid {nameof(FrameType)}.");
                }
            }, (uint)FrameArrayOffset);
            Keys = loader.LoadCustom(() =>
            {
                int elementsPerKey = ElementsPerKey;
                float[,] keys      = new float[numKey, elementsPerKey];
                switch (KeyType)
                {
                case AnimCurveKeyType.Single:
                    for (int i = 0; i < numKey; i++)
                    {
                        for (int j = 0; j < elementsPerKey; j++)
                        {
                            if (CurveType == AnimCurveType.StepInt || CurveType == AnimCurveType.StepBool)
                            {
                                keys[i, j] = loader.ReadUInt32();
                            }
                            else
                            {
                                keys[i, j] = loader.ReadSingle();
                            }
                        }
                    }
                    break;

                case AnimCurveKeyType.Int16:
                    for (int i = 0; i < numKey; i++)
                    {
                        for (int j = 0; j < elementsPerKey; j++)
                        {
                            keys[i, j] = loader.ReadInt16();
                        }
                    }
                    break;

                case AnimCurveKeyType.SByte:
                    for (int i = 0; i < numKey; i++)
                    {
                        for (int j = 0; j < elementsPerKey; j++)
                        {
                            keys[i, j] = loader.ReadSByte();
                        }
                    }
                    break;

                default:
                    throw new ResException($"Invalid {nameof(KeyType)}.");
                }
                return(keys);
            }, (uint)KeyArrayOffset);

            //Bools use bits to store values.
            if (CurveType == AnimCurveType.StepBool)
            {
                int keyIndex = 0;

                KeyStepBoolData = new bool[numKey];
                for (int i = 0; i < Keys.Length; i++)
                {
                    if (numKey <= keyIndex)
                    {
                        break;
                    }

                    int value = (int)Keys[i, 0];

                    //Bit shift each key value
                    for (int j = 0; j < 32; j++)
                    {
                        if (numKey <= keyIndex)
                        {
                            break;
                        }

                        bool set = (value & 0x1) != 0;
                        value >>= 1;

                        KeyStepBoolData[keyIndex] = set;
                        keyIndex++;
                    }
                }
            }
        }