public static BinaryClassChunk DeserializeHeader(
     System.Type t,
     BitBuffer data,
     BinaryClassChunk target = null,
     bool root     = true,
     bool skipData = false)
 {
     if (target == null)
     {
         target = Activator.CreateInstance(t, (object[])null) as BinaryClassChunk;
     }
     try
     {
         long num1 = 0;
         if (root)
         {
             num1 = data.ReadLong();
             if (num1 != BinaryClassChunk.MagicNumber(t) && num1 != 5033950674723417L)
             {
                 target._result = DeserializeResult.InvalidMagicNumber;
                 return(target);
             }
             target._checksum = data.ReadUInt();
         }
         ushort num2 = data.ReadUShort();
         ushort num3 = BinaryClassChunk.ChunkVersion(t);
         if ((int)num2 != (int)num3 && (!(target is LevelData) || num2 != (ushort)2))
         {
             target._result = (int)num2 <= (int)num3 ? DeserializeResult.FileVersionTooOld : DeserializeResult.FileVersionTooNew;
             return(target);
         }
         if (num2 == (ushort)2 && target is LevelData && data.ReadBool())
         {
             BinaryClassChunk binaryClassChunk = BinaryClassChunk.DeserializeHeader(Editor.GetType(data.ReadString()), data, root: false);
             if (binaryClassChunk != null && binaryClassChunk._result == DeserializeResult.HeaderDeserialized)
             {
                 binaryClassChunk.Deserialize();
                 target._headerDictionary["metaData"] = binaryClassChunk;
             }
         }
         target._magicNumber = num1;
         target._version     = num2;
         target._size        = data.ReadUInt();
         target._offset      = (uint)data.position;
         target._data        = data;
         target._result      = DeserializeResult.HeaderDeserialized;
         if (skipData)
         {
             data.position = (int)target._offset + (int)target._size;
         }
         return(target);
     }
     catch (Exception ex)
     {
         target._exception = ex;
         target._result    = DeserializeResult.ExceptionThrown;
         return(target);
     }
 }
        public override void OnDeserialize(BitBuffer msg)
        {
            this._index = msg.ReadByte();
            byte num1 = msg.ReadByte();
            DeviceInputMapping deviceInputMapping = new DeviceInputMapping();

            switch (num1)
            {
            case 0:
                deviceInputMapping.deviceOverride = (InputDevice) new Keyboard("", 0);
                break;

            case 1:
                deviceInputMapping.deviceOverride = (InputDevice) new XInputPad(0);
                break;

            default:
                deviceInputMapping.deviceOverride = (InputDevice) new DInputPad(0);
                break;
            }
            deviceInputMapping.deviceOverride.overrideMap = deviceInputMapping;
            if (msg.ReadBool())
            {
                byte num2 = msg.ReadByte();
                for (int index = 0; index < (int)num2; ++index)
                {
                    byte key  = msg.ReadByte();
                    int  num3 = msg.ReadInt();
                    deviceInputMapping.map[Triggers.fromIndex[key]] = num3;
                }
                if (msg.ReadBool())
                {
                    byte num3 = msg.ReadByte();
                    for (int index1 = 0; index1 < (int)num3; ++index1)
                    {
                        int key    = msg.ReadInt();
                        int index2 = (int)msg.ReadByte();
                        deviceInputMapping.graphicMap[key] = Input.buttonStyles[index2].texture.textureName;
                    }
                }
            }
            this._mapping = deviceInputMapping;
            base.OnDeserialize(msg);
        }