public static List <SetObjectShadow> GetShadowLayout(string fileName)
        {
            BinaryReader LayoutFileReader = new BinaryReader(new FileStream(fileName, FileMode.Open));

            LayoutFileReader.BaseStream.Position = 0;

            string FileMagic = new string(LayoutFileReader.ReadChars(4));

            if (FileMagic != "sky2")
            {
                System.Windows.Forms.MessageBox.Show("This is not a valid Shadow the Hedgehog layout file.");
                return(null);
            }

            int AmountOfObjects         = LayoutFileReader.ReadInt32();
            List <SetObjectShadow> list = new List <SetObjectShadow>(AmountOfObjects);
            uint TotalMiscLenght        = LayoutFileReader.ReadUInt32();

            for (int i = 0; i < AmountOfObjects; i++)
            {
                LayoutFileReader.BaseStream.Position = 12 + i * 0x2C;

                if (LayoutFileReader.BaseStream.Position >= LayoutFileReader.BaseStream.Length)
                {
                    break;
                }

                Vector3 Position = new Vector3(LayoutFileReader.ReadSingle(), LayoutFileReader.ReadSingle(), LayoutFileReader.ReadSingle());
                Vector3 Rotation = new Vector3(LayoutFileReader.ReadSingle(), LayoutFileReader.ReadSingle(), LayoutFileReader.ReadSingle());

                byte[] UnkBytes = LayoutFileReader.ReadBytes(8);

                byte Type             = LayoutFileReader.ReadByte();
                byte List             = LayoutFileReader.ReadByte();
                byte Link             = LayoutFileReader.ReadByte();
                byte Rend             = LayoutFileReader.ReadByte();
                int  MiscSettingCount = LayoutFileReader.ReadInt32();

                SetObjectShadow TempObject = new SetObjectShadow(List, Type, Position, Rotation, Link, Rend, MiscSettingCount, UnkBytes);

                list.Add(TempObject);
            }

            LayoutFileReader.BaseStream.Position = 12 + AmountOfObjects * 0x2C;
            for (int i = 0; i < list.Count; i++)
            {
                list[i].objectManager.MiscSettings = LayoutFileReader.ReadBytes(list[i].MiscSettingCount);
                list[i].CreateTransformMatrix();
            }

            LayoutFileReader.Close();

            return(list);
        }
        private static SetObjectHeroes SetObjectShadowToHeroes(SetObjectShadow i)
        {
            bool MatchNotFound = false;
            byte List          = 0;
            byte Type          = 0;

            byte[] MiscSettings = new byte[36];

            switch (i.List)
            {
            case 0:
                List = 0;
                if (i.Type == 0x00)
                {
                    Type = 0x03;                     // Ring
                }
                else if (i.Type == 0x01)
                {
                    Type = 0x01;                          // Spring
                }
                else if (i.Type == 0x02)
                {
                    Type = 0x02;                          // 3Spring
                }
                else if (i.Type == 0x03)
                {
                    Type = 0x0B;                          // Dash panel
                }
                else if (i.Type == 0x04)
                {
                    Type = 0x0F;                          // Dash ramp
                }
                else if (i.Type == 0x05)
                {
                    Type = 0x0E;                          // Checkpoint
                }
                else if (i.Type == 0x06)
                {
                    Type = 0x0C;                          // Dash Ring
                }
                else if (i.Type == 0x07)
                {
                    Type = 0x31;                          // Case
                }
                else if (i.Type == 0x08)
                {
                    Type = 0x1D;                          // Pulley
                }
                else if (i.Type == 0x09)
                {
                    Type = 0x20;                          // Gun Wood box
                }
                else if (i.Type == 0x0A)
                {
                    Type = 0x21;                          // Metal box
                }
                else if (i.Type == 0x0B)
                {
                    Type = 0x22;                          // Unbreakable box
                }
                else if (i.Type == 0x0C)
                {
                    Type = 0x20;             // Normal Wood box
                }
                else if (i.Type == 0x0F)     // Moving platform
                {
                    // List = 0x13;
                    // Type = 0x06; // Egg fleet square platform
                    List = 0x5;
                    Type = 0xA;          // dice
                }
                else if (i.Type == 0x10) // Ring
                {
                    Type = 0x03;

                    MiscSettings[5] = i.objectManager.MiscSettings[0];
                    MiscSettings[4] = i.objectManager.MiscSettings[1];

                    MiscSettings[7] = i.objectManager.MiscSettings[4];
                    MiscSettings[6] = i.objectManager.MiscSettings[5];

                    MiscSettings[11] = i.objectManager.MiscSettings[8];
                    MiscSettings[10] = i.objectManager.MiscSettings[9];
                    MiscSettings[9]  = i.objectManager.MiscSettings[10];
                    MiscSettings[8]  = i.objectManager.MiscSettings[11];

                    MiscSettings[15] = i.objectManager.MiscSettings[12];
                    MiscSettings[14] = i.objectManager.MiscSettings[13];
                    MiscSettings[13] = i.objectManager.MiscSettings[14];
                    MiscSettings[12] = i.objectManager.MiscSettings[15];

                    if (i.objectManager.MiscSettings[0] == 1)
                    {
                        i.Rotation.Y += 180;
                    }
                }
                else if (i.Type == 0x11)
                {
                    Type = 0x04;                          // Hint
                }
                else if (i.Type == 0x12)
                {
                    Type = 0x18;                          // Item balloon
                }
                else if (i.Type == 0x13)
                {
                    Type = 0x19;                          // Item balloon
                }
                else if (i.Type == 0x14)
                {
                    Type = 0x1B;                          // Goal ring
                }
                else if (i.Type == 0x15)
                {
                    Type = 0x05;                          // Switch
                }
                // else if (i.Type == 0x1D) Type = 0x67; // Key
                else if (i.Type == 0x1F)
                {
                    Type = 0x80;                          // Teleport
                }
                else if (i.Type == 0x3A)
                {
                    Type = 0x24;             // shadow box
                }
                else if (i.Type == 0x65)     // Beetle
                {
                    List = 0x15;
                    Type = 0x00;
                }
                else if (i.Type == 0x78)     // Egg bommer
                {
                    List = 0x15;
                    Type = 0x20;                          //Klagen
                }
                else if (i.Type == 0x79 | i.Type == 0x8D) // Egg pawn
                {
                    List = 0x15;
                    Type = 0x10;
                }
                else if (i.Type == 0x7A | i.Type == 0x90)     // Shadow android / worm
                {
                    List = 0x15;
                    Type = 0x70;     // Cameron
                }
                else
                {
                    MatchNotFound = true;
                }
                break;

            case 0x07:
                if (i.Type == 0xD1)     // Digital searchlight
                {
                    List         = 0x00;
                    Type         = 0x2E; // Fan
                    i.Rotation.X = 0;
                    i.Rotation.Y = 0;
                    i.Rotation.Z = 0;
                }
                else if (i.Type == 0xD5)     // Digital big block
                {
                    float scale = BitConverter.ToSingle(i.objectManager.MiscSettings, 4);
                    if (BitConverter.ToSingle(i.objectManager.MiscSettings, 8) < scale)
                    {
                        scale = BitConverter.ToSingle(i.objectManager.MiscSettings, 8);
                    }
                    if (BitConverter.ToSingle(i.objectManager.MiscSettings, 12) < scale)
                    {
                        scale = BitConverter.ToSingle(i.objectManager.MiscSettings, 12);
                    }

                    if (i.objectManager.MiscSettings[0] < 9)
                    {
                        List = 0x01;
                        Type = 0x80;     // Flower

                        MiscSettings[4] = i.objectManager.MiscSettings[0];

                        MiscSettings[8]  = BitConverter.GetBytes(scale)[3];
                        MiscSettings[9]  = BitConverter.GetBytes(scale)[2];
                        MiscSettings[10] = BitConverter.GetBytes(scale)[1];
                        MiscSettings[11] = BitConverter.GetBytes(scale)[0];
                    }
                    else
                    {
                        List = 0x01;
                        Type = 0x88;     // stone

                        MiscSettings[4] = BitConverter.GetBytes(scale)[3];
                        MiscSettings[5] = BitConverter.GetBytes(scale)[2];
                        MiscSettings[6] = BitConverter.GetBytes(scale)[1];
                        MiscSettings[7] = BitConverter.GetBytes(scale)[0];
                    }
                }
                else if (i.Type == 0xD7)     // Digital panel
                {
                    List = 0x05;
                    Type = 0x05;     // Casino panel

                    if (i.objectManager.MiscSettings[0] == 1)
                    {
                        i.Rotation.X -= 90;
                    }
                    else
                    {
                        MiscSettings[4] = BitConverter.GetBytes(5f)[3];
                        MiscSettings[5] = BitConverter.GetBytes(5f)[2];
                        MiscSettings[6] = BitConverter.GetBytes(5f)[1];
                        MiscSettings[7] = BitConverter.GetBytes(5f)[0];
                    }
                }
                else if (i.Type == 0xDB)     // Digital core
                {
                    List = 0x00;
                    Type = 0x1B;         // Goal
                }
                else if (i.Type == 0xDE) // Digital spring
                {
                    List = 0x05;
                    Type = 0x01;     // Green spring

                    MiscSettings[4] = BitConverter.GetBytes(4f)[3];
                    MiscSettings[5] = BitConverter.GetBytes(4f)[2];
                    MiscSettings[6] = BitConverter.GetBytes(4f)[1];
                    MiscSettings[7] = BitConverter.GetBytes(4f)[0];
                }
                else if (i.Type == 0xDF)     // Firewall
                {
                    List = 0x00;
                    Type = 0x15;     // Spikeball

                    MiscSettings[8]  = BitConverter.GetBytes(2f)[3];
                    MiscSettings[9]  = BitConverter.GetBytes(2f)[2];
                    MiscSettings[10] = BitConverter.GetBytes(2f)[1];
                    MiscSettings[11] = BitConverter.GetBytes(2f)[0];
                    MiscSettings[12] = BitConverter.GetBytes(2f)[3];
                    MiscSettings[13] = BitConverter.GetBytes(2f)[2];
                    MiscSettings[14] = BitConverter.GetBytes(2f)[1];
                    MiscSettings[15] = BitConverter.GetBytes(2f)[0];
                }
                else if (i.Type == 0xE2)     // Spinning cube dark
                {
                    List = 0x05;
                    Type = 0x84;         // Dice big
                }
                else if (i.Type == 0xE5) // Spinning cube PURPLE
                {
                    List            = 0x05;
                    Type            = 0x84; // Dice big
                    MiscSettings[7] = 1;
                }
                else
                {
                    MatchNotFound = true;
                }
                break;

            case 0x0B:
                if (i.Type == 0xBB | i.Type == 0xC9)     // small lantern, castle file
                {
                    List = 0x11;
                    Type = 0x04;     // flame torch
                }
                else
                {
                    MatchNotFound = true;
                }
                break;

            case 0x0C:
                if (i.Type == 0xDE)     // bouncy ball
                {
                    List = 0x05;
                    Type = 0x01;     // Green spring

                    MiscSettings[4] = BitConverter.GetBytes(4f)[3];
                    MiscSettings[5] = BitConverter.GetBytes(4f)[2];
                    MiscSettings[6] = BitConverter.GetBytes(4f)[1];
                    MiscSettings[7] = BitConverter.GetBytes(4f)[0];
                }
                else if (i.Type == 0x82)     // ghost
                {
                    List = 0x11;
                    Type = 0x05;         // ghost
                }
                else if (i.Type == 0x88) // zipline balloon
                {
                    List = 0x11;
                    Type = 0x00;     // teleport switch
                }
                else
                {
                    MatchNotFound = true;
                }
                break;

            case 0x11:
                if (i.Type == 0x33)     // Castle door
                {
                    List = 0x11;
                    Type = 0x01;     // castle door
                }
                else
                {
                    MatchNotFound = true;
                }
                break;

            case 0x13:
                if (i.Type == 0xF1)     // Lava shelter door
                {
                    List = 0x07;
                    Type = 0x06;         // Rail canyon door
                }
                else if (i.Type == 0xEF) // LASER
                {
                    List = 0x00;
                    Type = 0x16;
                }
                else
                {
                    MatchNotFound = true;
                }
                break;

            default:
                MatchNotFound = true;
                break;
            }

            if (MatchNotFound)
            {
                return(null);
            }
            else
            {
                return(new SetObjectHeroes(List, Type, i.Position,
                                           new Vector3(DegreesToBAMS(i.Rotation.X), DegreesToBAMS(i.Rotation.Y), DegreesToBAMS(i.Rotation.Z)), 0, (byte)(2 * i.Rend)));
            }
        }