mirror of
https://github.com/D1GQ/BetterAmongUs.git
synced 2026-10-19 15:51:52 +00:00
Fix null ref on game start for Android
This commit is contained in:
1 parent
7f39f16cfc
commit
d5072155bf
2 files changed
+18
-16
No files matched your search
@@ -19,6 +19,8 @@ internal static class LobbyPatch
|
||||
OptionPlayerItem.ResetAllValues();
|
||||
}
|
||||
|
||||
private static Transform? GameStartObj;
|
||||
|
||||
// Disable annoying lobby music if setting is enabled
|
||||
[HarmonyPatch(typeof(LobbyBehaviour), nameof(LobbyBehaviour.Update))]
|
||||
[HarmonyPostfix]
|
||||
@@ -26,6 +28,19 @@ internal static class LobbyPatch
|
||||
{
|
||||
if (BAUConfigs.DisableLobbyTheme.Value)
|
||||
SoundManager.instance.StopSound(LobbyBehaviour.Instance.MapTheme);
|
||||
|
||||
// Adjust GameStartManager position for better UI layout
|
||||
if (GameStartObj == null)
|
||||
{
|
||||
if (HudManager.InstanceExists)
|
||||
{
|
||||
GameStartObj = HudManager.Instance.transform.Find("GameStartManager");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
GameStartObj.SetLocalY(-2.8f);
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(LobbyBehaviour), nameof(LobbyBehaviour.RpcExtendLobbyTimer))]
|
||||
@@ -99,7 +114,7 @@ internal static class LobbyPatch
|
||||
__instance.GameStartTextParent.SetActive(false);
|
||||
__instance.StartButton.gameObject.SetActive(true);
|
||||
|
||||
if (__instance.startState == GameStartManager.StartingStates.Countdown)
|
||||
if (__instance.startState == global::GameStartManager.StartingStates.Countdown)
|
||||
{
|
||||
// Show cancel button with countdown
|
||||
__instance.StartButton.buttonText.text = string.Format("{0}: {1}", Translator.GetString(StringNames.Cancel), (int)__instance.countDownTimer + 1);
|
||||
@@ -118,7 +133,7 @@ internal static class LobbyPatch
|
||||
if (BAUModdedSupportFlags.HasFlag(BAUModdedSupportFlags.Disable_CancelStartingGame)) return true;
|
||||
|
||||
// If countdown is active, clicking cancels the start
|
||||
if (__instance.startState == GameStartManager.StartingStates.Countdown)
|
||||
if (__instance.startState == global::GameStartManager.StartingStates.Countdown)
|
||||
{
|
||||
SoundManager.instance.StopSound(__instance.gameStartSound);
|
||||
__instance.ResetStartState();
|
||||
@@ -128,7 +143,7 @@ internal static class LobbyPatch
|
||||
// Shift+click starts game immediately (bypasses countdown)
|
||||
if (Input.GetKey(KeyCode.LeftShift))
|
||||
{
|
||||
__instance.startState = GameStartManager.StartingStates.Countdown;
|
||||
__instance.startState = global::GameStartManager.StartingStates.Countdown;
|
||||
__instance.FinallyBegin();
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ using BetterAmongUs.Helpers;
|
||||
using BetterAmongUs.Managers;
|
||||
using BetterAmongUs.Modules;
|
||||
using HarmonyLib;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BetterAmongUs.Patches.Gameplay.Managers;
|
||||
|
||||
@@ -38,22 +37,10 @@ internal static class HudManagerPatch
|
||||
}, 1f, shouldLog: false);
|
||||
}
|
||||
|
||||
private static GameObject? gameStart;
|
||||
|
||||
[HarmonyPatch(typeof(HudManager), nameof(HudManager.Update))]
|
||||
[HarmonyPostfix]
|
||||
private static void HudManager_Update_Postfix(HudManager __instance)
|
||||
{
|
||||
// Adjust GameStartManager position for better UI layout
|
||||
if (gameStart == null)
|
||||
{
|
||||
gameStart = GameObject.Find("GameStartManager");
|
||||
}
|
||||
if (gameStart != null)
|
||||
{
|
||||
gameStart.transform.SetLocalY(-2.8f);
|
||||
}
|
||||
|
||||
// Manage in-game chat visibility based on settings and game state
|
||||
if (GameState.InGame)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user