private static IEnumerator HandleCharacterChange() { //Pixelator.Instance.FadeToBlack(0.5f, false); InputDevice lastActiveDevice = GameManager.Instance.LastUsedInputDeviceForConversation; //Destroy Player 2 if (GameManager.Instance.CurrentGameType == GameManager.GameType.COOP_2_PLAYER) { GameManager.Instance.SecondaryPlayer.SetInputOverride("getting deleted"); GameManager.Instance.ClearSecondaryPlayer(); if (GameManager.Instance.PrimaryPlayer) { GameManager.Instance.PrimaryPlayer.ReinitializeMovementRestrictors(); } yield return(null); } //Build new Player 2 GameManager.Instance.CurrentGameType = GameManager.GameType.COOP_2_PLAYER; if (GameManager.Instance.PrimaryPlayer) { GameManager.Instance.PrimaryPlayer.ReinitializeMovementRestrictors(); } PlayerController newPlayer = GeneratePlayer(); yield return(null); GameUIRoot.Instance.ConvertCoreUIToCoopMode(); PhysicsEngine.Instance.RegisterOverlappingGhostCollisionExceptions(newPlayer.specRigidbody, null, false); GameManager.Instance.MainCameraController.ClearPlayerCache(); BraveInput.ReassignAllControllers(lastActiveDevice); if (Foyer.Instance) { Foyer.Instance.ProcessPlayerEnteredFoyer(newPlayer); Foyer.Instance.OnCoopModeChanged?.Invoke(); } GameManager.Instance.SecondaryPlayer.PlayerIDX = 1; GameManager.Instance.SecondaryPlayer.characterIdentity = PlayableCharacters.CoopCultist; //Reset Hooks.ResetCustomCharacters(); GameManager.Instance.RefreshAllPlayers(); yield break; }
public static void SwitchSecondaryCharacter(string[] args) { if (args == null || args.Length < 1) { return; } if (!GameManager.Instance.SecondaryPlayer) { Tools.PrintError("You need to enter co-op mode before using the character2 command"); return; } prefabPath = "Player" + args[0]; var prefab = (GameObject)BraveResources.Load(prefabPath, ".prefab"); if (prefab == null) { Tools.Print("Failed getting prefab for " + args[0]); return; } GameManager.Instance.StartCoroutine(HandleCharacterChange()); Hooks.ResetInfiniteGuns(); }