mirror of
https://github.com/Gurge44/EndlessHostRoles.git
synced 2026-10-20 01:46:25 +00:00
fix major bug
This commit is contained in:
1 parent
bf9338b318
commit
0a804e083e
2 files changed
+50
-16
No files matched your search
@@ -152,7 +152,7 @@ public static class TheMindGame
|
||||
|
||||
public static string GetSuffix(PlayerControl seer, PlayerControl target)
|
||||
{
|
||||
if (!target.IsAlive()) return string.Empty;
|
||||
if (!target.IsAlive() || !Main.IntroDestroyed) return string.Empty;
|
||||
|
||||
var sb = new StringBuilder("<#ffffff>");
|
||||
|
||||
@@ -297,7 +297,7 @@ public static class TheMindGame
|
||||
|
||||
foreach (IEnumerable<PlayerControl> players in groups)
|
||||
{
|
||||
(SystemTypes room, Vector2 location) = map.Positions.ExceptBy(GroupRooms.Values, x => x.Key).RandomElement();
|
||||
(SystemTypes room, Vector2 location) = map.Positions.IntersectBy(AllRooms, x => x.Key).ExceptBy(GroupRooms.Values, x => x.Key).RandomElement();
|
||||
GroupRooms[group] = room;
|
||||
List<byte> ids = [];
|
||||
|
||||
@@ -318,7 +318,7 @@ public static class TheMindGame
|
||||
|
||||
Utils.SetChatVisibleForAll();
|
||||
|
||||
yield return NotifyEveryone("TMG.Tutorial.Basics", 4);
|
||||
yield return NotifyEveryone("TMG.Tutorial.Basics", 6);
|
||||
if (Stop) yield break;
|
||||
|
||||
yield return NotifyEveryone("TMG.Notify.Round", 2, 1);
|
||||
@@ -348,6 +348,7 @@ public static class TheMindGame
|
||||
{
|
||||
LastTimeWarning = Utils.TimeStamp;
|
||||
Utils.SendMessage(string.Format(Translator.GetString("TMG.Message.TimeLeft"), (int)timer), title: Translator.GetString("TMG.Message.TimeLeftTitle"));
|
||||
LateTask.New(() => Utils.NotifyRoles(SpecifyTarget: Main.AllAlivePlayerControls.MinBy(x => x.PlayerId)), 1f, log: false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -412,6 +413,7 @@ public static class TheMindGame
|
||||
{
|
||||
LastTimeWarning = Utils.TimeStamp;
|
||||
Utils.SendMessage(string.Format(Translator.GetString("TMG.Message.TimeLeft"), (int)timer), title: Translator.GetString("TMG.Message.TimeLeftTitle"));
|
||||
LateTask.New(() => Utils.NotifyRoles(SpecifyTarget: Main.AllAlivePlayerControls.MinBy(x => x.PlayerId)), 1f, log: false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -455,6 +457,7 @@ public static class TheMindGame
|
||||
{
|
||||
LastTimeWarning = Utils.TimeStamp;
|
||||
Utils.SendMessage(string.Format(Translator.GetString("TMG.Message.TimeLeft"), (int)timer2), title: Translator.GetString("TMG.Message.TimeLeftTitle"));
|
||||
LateTask.New(() => Utils.NotifyRoles(SpecifyTarget: Main.AllAlivePlayerControls.MinBy(x => x.PlayerId)), 1f, log: false);
|
||||
}
|
||||
|
||||
if (Main.AllAlivePlayerControls.Length == AmReady.Count)
|
||||
@@ -497,6 +500,7 @@ public static class TheMindGame
|
||||
{
|
||||
LastTimeWarning = Utils.TimeStamp;
|
||||
Utils.SendMessage(string.Format(Translator.GetString("TMG.Message.TimeLeft"), (int)timer), title: Translator.GetString("TMG.Message.TimeLeftTitle"));
|
||||
LateTask.New(() => Utils.NotifyRoles(SpecifyTarget: Main.AllAlivePlayerControls.MinBy(x => x.PlayerId)), 1f, log: false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using AmongUs.Data;
|
||||
@@ -15,7 +16,6 @@ using EHR.Neutral;
|
||||
using EHR.Patches;
|
||||
using HarmonyLib;
|
||||
using Hazel;
|
||||
using Il2CppSystem.Collections;
|
||||
using InnerNet;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
@@ -410,7 +410,7 @@ internal static class ChangeRoleSettings
|
||||
|
||||
return;
|
||||
|
||||
System.Collections.IEnumerator PopulateSkinItems()
|
||||
IEnumerator PopulateSkinItems()
|
||||
{
|
||||
while (!ShipStatus.Instance) yield return null;
|
||||
BlockPopulateSkins = false;
|
||||
@@ -454,16 +454,43 @@ internal static class StartGameHostPatch
|
||||
};
|
||||
}
|
||||
|
||||
private static IEnumerator WaitAndSmoothlyUpdate(this LoadingBarManager loadingBarManager, float startPercent, float targetPercent, float duration, string loadingText)
|
||||
{
|
||||
float startTime = Time.time;
|
||||
|
||||
while (Time.time - startTime < duration)
|
||||
{
|
||||
float t = (Time.time - startTime) / duration;
|
||||
float newPercent = Mathf.Lerp(startPercent, targetPercent, t);
|
||||
|
||||
try
|
||||
{
|
||||
loadingBarManager.SetLoadingPercent(newPercent, StringNames.LoadingBarGameStart);
|
||||
loadingBarManager.loadingBar.loadingText.text = loadingText;
|
||||
}
|
||||
catch (Exception e) { Utils.ThrowException(e); }
|
||||
|
||||
yield return null;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
loadingBarManager.SetLoadingPercent(targetPercent, StringNames.LoadingBarGameStart);
|
||||
loadingBarManager.loadingBar.loadingText.text = loadingText;
|
||||
}
|
||||
catch (Exception e) { Utils.ThrowException(e); }
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(AmongUsClient), nameof(AmongUsClient.CoStartGameHost))]
|
||||
[HarmonyPrefix]
|
||||
public static bool CoStartGameHost_Prefix(AmongUsClient __instance, ref IEnumerator __result)
|
||||
public static bool CoStartGameHost_Prefix(AmongUsClient __instance, ref Il2CppSystem.Collections.IEnumerator __result)
|
||||
{
|
||||
AUClient = __instance;
|
||||
__result = StartGameHost().WrapToIl2Cpp();
|
||||
return false;
|
||||
}
|
||||
|
||||
private static System.Collections.IEnumerator StartGameHost()
|
||||
private static IEnumerator StartGameHost()
|
||||
{
|
||||
string loadingTextText1 = GetString("LoadingBarText.1");
|
||||
LoadingBarManager loadingBarManager = FastDestroyableSingleton<LoadingBarManager>.Instance;
|
||||
@@ -488,12 +515,6 @@ internal static class StartGameHostPatch
|
||||
}
|
||||
catch (Exception e) { Utils.ThrowException(e); }
|
||||
|
||||
foreach (NetworkedPlayerInfo playerInfo in GameData.Instance.AllPlayers)
|
||||
{
|
||||
playerInfo.Disconnected = true;
|
||||
playerInfo.MarkDirty();
|
||||
}
|
||||
|
||||
if (LobbyBehaviour.Instance)
|
||||
LobbyBehaviour.Instance.Despawn();
|
||||
|
||||
@@ -563,7 +584,7 @@ internal static class StartGameHostPatch
|
||||
{
|
||||
if (totalSeconds < (double)num)
|
||||
{
|
||||
loadingBarManager.SetLoadingPercent(10 + (float)(totalSeconds / (double)num * 90.0), StringNames.LoadingBarGameStartWaitingPlayers);
|
||||
loadingBarManager.SetLoadingPercent(10 + (float)(totalSeconds / (double)num * 80.0), StringNames.LoadingBarGameStartWaitingPlayers);
|
||||
|
||||
int timeoutIn = num - (int)totalSeconds;
|
||||
loadingBarManager.loadingBar.loadingText.text = string.Format(GetString("LoadingBarText.2"), clientsReady, allClientsCount, timeoutIn);
|
||||
@@ -578,11 +599,10 @@ internal static class StartGameHostPatch
|
||||
}
|
||||
|
||||
AUClient.SendClientReady();
|
||||
loadingBarManager.ToggleLoadingBar(false);
|
||||
yield return AssignRoles();
|
||||
}
|
||||
|
||||
private static System.Collections.IEnumerator AssignRoles()
|
||||
private static IEnumerator AssignRoles()
|
||||
{
|
||||
if (AmongUsClient.Instance.IsGameOver || GameStates.IsLobby || GameEndChecker.Ended) yield break;
|
||||
|
||||
@@ -994,6 +1014,16 @@ internal static class StartGameHostPatch
|
||||
}
|
||||
|
||||
|
||||
foreach (NetworkedPlayerInfo playerInfo in GameData.Instance.AllPlayers)
|
||||
{
|
||||
playerInfo.Disconnected = true;
|
||||
playerInfo.MarkDirty();
|
||||
}
|
||||
|
||||
LoadingBarManager loadingBarManager = FastDestroyableSingleton<LoadingBarManager>.Instance;
|
||||
yield return loadingBarManager.WaitAndSmoothlyUpdate(90f, 100f, 2f, GetString("LoadingBarText.1"));
|
||||
loadingBarManager.ToggleLoadingBar(false);
|
||||
|
||||
Main.AllPlayerControls.Do(SetRoleSelf);
|
||||
|
||||
RpcSetRoleReplacer.EndReplace();
|
||||
|
||||
Reference in new issue
Block a user