Ejemplo n.º 1
0
 private bool LoadJoystickAssignmentsNow(UserDataStore_PlayerPrefs.ControllerAssignmentSaveInfo data)
 {
     try
     {
         if (ReInput.controllers.joystickCount == 0)
         {
             return(false);
         }
         if (data == null && (data = this.LoadControllerAssignmentData()) == null)
         {
             return(false);
         }
         foreach (Player player in ReInput.players.AllPlayers)
         {
             player.controllers.ClearControllersOfType(ControllerType.Joystick);
         }
         List <UserDataStore_PlayerPrefs.JoystickAssignmentHistoryInfo> list = (!this.loadJoystickAssignments) ? null : new List <UserDataStore_PlayerPrefs.JoystickAssignmentHistoryInfo>();
         foreach (Player player2 in ReInput.players.AllPlayers)
         {
             if (data.ContainsPlayer(player2.id))
             {
                 UserDataStore_PlayerPrefs.ControllerAssignmentSaveInfo.PlayerInfo playerInfo = data.players[data.IndexOfPlayer(player2.id)];
                 for (int i = 0; i < playerInfo.joystickCount; i++)
                 {
                     UserDataStore_PlayerPrefs.ControllerAssignmentSaveInfo.JoystickInfo joystickInfo2 = playerInfo.joysticks[i];
                     if (joystickInfo2 != null)
                     {
                         Joystick joystick = this.FindJoystickPrecise(joystickInfo2);
                         if (joystick != null)
                         {
                             if (list.Find((UserDataStore_PlayerPrefs.JoystickAssignmentHistoryInfo x) => x.joystick == joystick) == null)
                             {
                                 list.Add(new UserDataStore_PlayerPrefs.JoystickAssignmentHistoryInfo(joystick, joystickInfo2.id));
                             }
                             player2.controllers.AddController(joystick, false);
                         }
                     }
                 }
             }
         }
         if (this.allowImpreciseJoystickAssignmentMatching)
         {
             foreach (Player player3 in ReInput.players.AllPlayers)
             {
                 if (data.ContainsPlayer(player3.id))
                 {
                     UserDataStore_PlayerPrefs.ControllerAssignmentSaveInfo.PlayerInfo playerInfo2 = data.players[data.IndexOfPlayer(player3.id)];
                     for (int j = 0; j < playerInfo2.joystickCount; j++)
                     {
                         UserDataStore_PlayerPrefs.ControllerAssignmentSaveInfo.JoystickInfo joystickInfo = playerInfo2.joysticks[j];
                         if (joystickInfo != null)
                         {
                             Joystick joystick2 = null;
                             int      num       = list.FindIndex((UserDataStore_PlayerPrefs.JoystickAssignmentHistoryInfo x) => x.oldJoystickId == joystickInfo.id);
                             if (num >= 0)
                             {
                                 joystick2 = list[num].joystick;
                             }
                             else
                             {
                                 List <Joystick> list2;
                                 if (!this.TryFindJoysticksImprecise(joystickInfo, out list2))
                                 {
                                     goto IL_30F;
                                 }
                                 using (List <Joystick> .Enumerator enumerator4 = list2.GetEnumerator())
                                 {
                                     while (enumerator4.MoveNext())
                                     {
                                         Joystick match = enumerator4.Current;
                                         if (list.Find((UserDataStore_PlayerPrefs.JoystickAssignmentHistoryInfo x) => x.joystick == match) == null)
                                         {
                                             joystick2 = match;
                                             break;
                                         }
                                     }
                                 }
                                 if (joystick2 == null)
                                 {
                                     goto IL_30F;
                                 }
                                 list.Add(new UserDataStore_PlayerPrefs.JoystickAssignmentHistoryInfo(joystick2, joystickInfo.id));
                             }
                             player3.controllers.AddController(joystick2, false);
                         }
                         IL_30F :;
                     }
                 }
             }
         }
     }
     catch
     {
     }
     if (ReInput.configuration.autoAssignJoysticks)
     {
         ReInput.controllers.AutoAssignJoysticks();
     }
     return(true);
 }
Ejemplo n.º 2
0
 private bool SaveControllerAssignments()
 {
     try
     {
         UserDataStore_PlayerPrefs.ControllerAssignmentSaveInfo controllerAssignmentSaveInfo = new UserDataStore_PlayerPrefs.ControllerAssignmentSaveInfo(ReInput.players.allPlayerCount);
         for (int i = 0; i < ReInput.players.allPlayerCount; i++)
         {
             Player player = ReInput.players.AllPlayers[i];
             UserDataStore_PlayerPrefs.ControllerAssignmentSaveInfo.PlayerInfo playerInfo = new UserDataStore_PlayerPrefs.ControllerAssignmentSaveInfo.PlayerInfo();
             controllerAssignmentSaveInfo.players[i] = playerInfo;
             playerInfo.id          = player.id;
             playerInfo.hasKeyboard = player.controllers.hasKeyboard;
             playerInfo.hasMouse    = player.controllers.hasMouse;
             UserDataStore_PlayerPrefs.ControllerAssignmentSaveInfo.JoystickInfo[] array = new UserDataStore_PlayerPrefs.ControllerAssignmentSaveInfo.JoystickInfo[player.controllers.joystickCount];
             playerInfo.joysticks = array;
             for (int j = 0; j < player.controllers.joystickCount; j++)
             {
                 Joystick joystick = player.controllers.Joysticks[j];
                 array[j] = new UserDataStore_PlayerPrefs.ControllerAssignmentSaveInfo.JoystickInfo
                 {
                     instanceGuid       = joystick.deviceInstanceGuid,
                     id                 = joystick.id,
                     hardwareIdentifier = joystick.hardwareIdentifier
                 };
             }
         }
         PlayerPrefs.SetString(this.playerPrefsKey_controllerAssignments, JsonWriter.ToJson(controllerAssignmentSaveInfo));
         PlayerPrefs.Save();
     }
     catch
     {
     }
     return(true);
 }
Ejemplo n.º 3
0
 private bool LoadKeyboardAndMouseAssignmentsNow(UserDataStore_PlayerPrefs.ControllerAssignmentSaveInfo data)
 {
     try
     {
         if (data == null && (data = this.LoadControllerAssignmentData()) == null)
         {
             return(false);
         }
         foreach (Player player in ReInput.players.AllPlayers)
         {
             if (data.ContainsPlayer(player.id))
             {
                 UserDataStore_PlayerPrefs.ControllerAssignmentSaveInfo.PlayerInfo playerInfo = data.players[data.IndexOfPlayer(player.id)];
                 if (this.loadKeyboardAssignments)
                 {
                     player.controllers.hasKeyboard = playerInfo.hasKeyboard;
                 }
                 if (this.loadMouseAssignments)
                 {
                     player.controllers.hasMouse = playerInfo.hasMouse;
                 }
             }
         }
     }
     catch
     {
     }
     return(true);
 }