mirror of
https://github.com/D1GQ/BetterAmongUs.git
synced 2026-10-20 01:46:19 +00:00
Tell exactly what's happening when game is loading
This commit is contained in:
1 parent
c02eaaefe3
commit
94e7d83ea9
3 files changed
+127
-35
No files matched your search
+117
-26
@@ -140,38 +140,129 @@ internal class ClientPatch
|
||||
{
|
||||
CustomLoadingBarManager.ToggleLoadingBar(true);
|
||||
|
||||
try
|
||||
if (GameState.IsHost)
|
||||
{
|
||||
while (Main.AllPlayerControls.Count > 0 && Main.AllPlayerControls.Any(pc => !pc.roleAssigned))
|
||||
yield return CoLoadingHost();
|
||||
}
|
||||
else
|
||||
{
|
||||
yield return CoLoadingClient();
|
||||
}
|
||||
|
||||
CustomLoadingBarManager.SetLoadingPercent(100f, "Complete");
|
||||
yield return new WaitForSeconds(0.25f);
|
||||
CustomLoadingBarManager.ToggleLoadingBar(false);
|
||||
}
|
||||
|
||||
private static IEnumerator CoLoadingHost()
|
||||
{
|
||||
var client = AmongUsClient.Instance.GetClient(AmongUsClient.Instance.ClientId);
|
||||
var clients = AmongUsClient.Instance.allClients.ToArray();
|
||||
|
||||
while (Main.AllPlayerControls.Count > 0 && Main.AllPlayerControls.Any(pc => !pc.roleAssigned))
|
||||
{
|
||||
if (!GameState.IsInGame)
|
||||
{
|
||||
if (!GameState.IsInGame)
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
|
||||
int totalPlayers = Main.AllPlayerControls.Count;
|
||||
if (totalPlayers == 0) yield break;
|
||||
|
||||
int playersWithRoles = Main.AllPlayerControls.Count(pc => pc.roleAssigned);
|
||||
float progress = (float)playersWithRoles / totalPlayers;
|
||||
|
||||
int percent = Mathf.RoundToInt(progress * 100f);
|
||||
|
||||
string loadingText = (GameState.IsHost && playersWithRoles > 0)
|
||||
? "Assigning Roles"
|
||||
: "Loading";
|
||||
|
||||
CustomLoadingBarManager.SetLoadingPercent(progress, loadingText);
|
||||
|
||||
yield return null;
|
||||
CustomLoadingBarManager.ToggleLoadingBar(false);
|
||||
yield break;
|
||||
}
|
||||
|
||||
CustomLoadingBarManager.SetLoadingPercent(100f, "Complete");
|
||||
yield return new WaitForSeconds(0.5f);
|
||||
string loadingText = "Initializing Game";
|
||||
float progress = 0f;
|
||||
|
||||
if (AmongUsClient.Instance.GameState != InnerNetClient.GameStates.Started)
|
||||
{
|
||||
loadingText = "Starting Game Session";
|
||||
progress = 0.1f;
|
||||
}
|
||||
else if (LobbyBehaviour.Instance)
|
||||
{
|
||||
loadingText = "Loading";
|
||||
progress = 0.2f;
|
||||
}
|
||||
else if (!ShipStatus.Instance || AmongUsClient.Instance.ShipLoadingAsyncHandle.IsValid())
|
||||
{
|
||||
bool isShipLoading = AmongUsClient.Instance.ShipLoadingAsyncHandle.IsValid();
|
||||
|
||||
loadingText = isShipLoading ? "Loading Ship Async" : "Spawning Ship";
|
||||
progress = isShipLoading ? 0.3f : 0.4f;
|
||||
}
|
||||
else if (Main.AllPlayerControls.Any(player => !player.roleAssigned))
|
||||
{
|
||||
int totalPlayers = Main.AllPlayerControls.Count;
|
||||
int assignedPlayers = Main.AllPlayerControls.Count(pc => pc.roleAssigned);
|
||||
float assignmentProgress = (float)assignedPlayers / Mathf.Max(1, totalPlayers);
|
||||
|
||||
loadingText = $"Assigning Roles ({assignedPlayers}/{totalPlayers})";
|
||||
progress = 0.4f + (0.3f * assignmentProgress);
|
||||
}
|
||||
else if (!client.IsReady)
|
||||
{
|
||||
int readyClients = clients.Count(c => c.IsReady);
|
||||
int totalClients = clients.Length;
|
||||
|
||||
loadingText = $"Waiting for Players ({readyClients}/{totalClients})";
|
||||
progress = 0.8f + (0.2f * readyClients / Mathf.Max(1, totalClients));
|
||||
}
|
||||
|
||||
int percent = Mathf.RoundToInt(progress * 100f);
|
||||
CustomLoadingBarManager.SetLoadingPercent(percent, loadingText);
|
||||
|
||||
yield return null;
|
||||
}
|
||||
finally
|
||||
}
|
||||
|
||||
private static IEnumerator CoLoadingClient()
|
||||
{
|
||||
var client = AmongUsClient.Instance.GetClient(AmongUsClient.Instance.ClientId);
|
||||
var clients = AmongUsClient.Instance.allClients.ToArray();
|
||||
|
||||
while (Main.AllPlayerControls.Count > 0 && Main.AllPlayerControls.Any(pc => !pc.roleAssigned))
|
||||
{
|
||||
CustomLoadingBarManager.ToggleLoadingBar(false);
|
||||
if (!GameState.IsInGame)
|
||||
{
|
||||
CustomLoadingBarManager.ToggleLoadingBar(false);
|
||||
yield break;
|
||||
}
|
||||
|
||||
string loadingText = "Initializing Game";
|
||||
float progress = 0;
|
||||
|
||||
if (AmongUsClient.Instance.GameState != InnerNetClient.GameStates.Started)
|
||||
{
|
||||
loadingText = "Starting Game Session";
|
||||
progress = 0.1f;
|
||||
}
|
||||
else if (LobbyBehaviour.Instance)
|
||||
{
|
||||
loadingText = "Loading";
|
||||
progress = 0.25f;
|
||||
}
|
||||
else if (!ShipStatus.Instance || AmongUsClient.Instance.ShipLoadingAsyncHandle.IsValid())
|
||||
{
|
||||
bool isShipLoading = AmongUsClient.Instance.ShipLoadingAsyncHandle.IsValid();
|
||||
|
||||
loadingText = isShipLoading ? "Loading Ship Async" : "Spawning Ship";
|
||||
progress = isShipLoading ? 0.35f : 0.4f;
|
||||
}
|
||||
else if (!client.IsReady)
|
||||
{
|
||||
loadingText = "Finalizing Connection";
|
||||
progress = 0.75f;
|
||||
}
|
||||
else
|
||||
{
|
||||
int readyClients = clients.Count(c => c.IsReady);
|
||||
int totalClients = clients.Length;
|
||||
|
||||
loadingText = $"Waiting for Players ({readyClients}/{totalClients})";
|
||||
progress = 0.85f + (0.15f * readyClients / Mathf.Max(1, totalClients));
|
||||
}
|
||||
|
||||
int percent = Mathf.RoundToInt(progress * 100f);
|
||||
CustomLoadingBarManager.SetLoadingPercent(percent, loadingText);
|
||||
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,17 +3,17 @@ using HarmonyLib;
|
||||
|
||||
namespace BetterAmongUs.Patches;
|
||||
|
||||
[HarmonyPatch(typeof(PlayerBanData), nameof(PlayerBanData.BanMinutesLeft), MethodType.Getter)]
|
||||
[HarmonyPatch(typeof(PlayerBanData))]
|
||||
internal static class DisconnectPenaltyPatch
|
||||
{
|
||||
internal static bool Prefix(PlayerBanData __instance, ref int __result)
|
||||
[HarmonyPatch(nameof(PlayerBanData.IsBanned), MethodType.Getter)]
|
||||
[HarmonyPrefix]
|
||||
internal static bool IsBanned_Prefix(PlayerBanData __instance, ref bool __result)
|
||||
{
|
||||
if (__instance.BanPoints != 0f)
|
||||
{
|
||||
__instance.BanPoints = 0f;
|
||||
__result = 0;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
Logger.InGame("TEST");
|
||||
__instance.BanPoints = 0f;
|
||||
__instance.banPoints = 0f;
|
||||
__result = false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -66,6 +66,7 @@ internal class FindAGameManagerPatch
|
||||
[HarmonyPostfix]
|
||||
internal static void HandleList_Postfix(FindAGameManager __instance, HttpMatchmakerManager.FindGamesListFilteredResponse response)
|
||||
{
|
||||
__instance.ResetContainers();
|
||||
GameListing[] games = response.Games.ToArray();
|
||||
|
||||
games = [.. games.OrderByDescending(game => game.PlayerCount).ThenBy(game => game.TrueHostName)];
|
||||
|
||||
Reference in new issue
Block a user