diff --git a/Gamemodes/Mingle.cs b/Gamemodes/Mingle.cs index cbc5904b0..858423bc5 100644 --- a/Gamemodes/Mingle.cs +++ b/Gamemodes/Mingle.cs @@ -13,32 +13,32 @@ public static class Mingle public static readonly HashSet HasPlayedFCs = []; public static bool GameGoing; - public static DateTime GameStartDateTime; - public static Dictionary RequiredPlayerCount = []; - public static HashSet AllRooms = []; + private static DateTime GameStartDateTime; + private static Dictionary RequiredPlayerCount = []; + private static HashSet AllRooms = []; private static readonly StringBuilder Suffix = new(); - public static long TimeEndTS; - public static long LastUpdateTS; - public static int Time; - public static bool DontEndGame; + private static long TimeEndTS; + private static long LastUpdateTS; + private static int Time; + private static bool CheckForGameEnd; - public static int TimeLimit; - public static int TimeDecreaseOnNoDeath; - public static int ExtraTimeOnAirship; - public static int ExtraTimeOnFungle; - public static bool DisplayCurrentPlayerCountInEachRoom; - public static int MinTime; - public static int MaxRequiredPlayersPerRoom; - public static int MaxWinningPlayers; + private static int TimeLimit; + private static int TimeDecreaseOnNoDeath; + private static int ExtraTimeOnAirship; + private static int ExtraTimeOnFungle; + private static bool DisplayCurrentPlayerCountInEachRoom; + private static int MinTime; + private static int MaxRequiredPlayersPerRoom; + private static int MaxWinningPlayers; - public static OptionItem TimeLimitOption; - public static OptionItem TimeDecreaseOnNoDeathOption; - public static OptionItem ExtraTimeOnAirshipOption; - public static OptionItem ExtraTimeOnFungleOption; - public static OptionItem DisplayCurrentPlayerCountInEachRoomOption; - public static OptionItem MinTimeOption; - public static OptionItem MaxRequiredPlayersPerRoomOption; - public static OptionItem MaxWinningPlayersOption; + private static OptionItem TimeLimitOption; + private static OptionItem TimeDecreaseOnNoDeathOption; + private static OptionItem ExtraTimeOnAirshipOption; + private static OptionItem ExtraTimeOnFungleOption; + private static OptionItem DisplayCurrentPlayerCountInEachRoomOption; + private static OptionItem MinTimeOption; + private static OptionItem MaxRequiredPlayersPerRoomOption; + private static OptionItem MaxWinningPlayersOption; public static OptionItem ChatDuringGameOption; public static void SetupCustomOption() @@ -112,7 +112,8 @@ public static class Mingle public static bool CheckGameEnd(out GameOverReason reason) { reason = GameOverReason.ImpostorsByKill; - if (GameStates.IsEnded || !GameGoing || TimeEndTS > Utils.TimeStamp) return false; + if (GameStates.IsEnded || !GameGoing || !CheckForGameEnd) return false; + CheckForGameEnd = false; var aapc = Main.CachedAlivePlayerControls(); switch (aapc.Count) @@ -127,7 +128,7 @@ public static class Mingle CustomWinnerHolder.ResetAndSetWinner(CustomWinner.Error); Logger.Warn("No players alive. Force ending the game", "Mingle"); return true; - case var p when p <= MaxWinningPlayers && !DontEndGame: + case var p when p <= MaxWinningPlayers: CustomWinnerHolder.WinnerIds = aapc.Select(x => x.PlayerId).ToHashSet(); Logger.Info($"Winners: {string.Join(", ", aapc.Select(x => x.GetRealName().RemoveHtmlTags()))}", "Mingle"); Main.DoBlockNameChange = true; @@ -298,8 +299,6 @@ public static class Mingle private static void KillPlayers() { - DontEndGame = true; - try { var aapc = Main.CachedAlivePlayerControls(); @@ -340,7 +339,7 @@ public static class Mingle } finally { - DontEndGame = false; + CheckForGameEnd = true; } } @@ -348,6 +347,8 @@ public static class Mingle public static void HandleDisconnect() { + CheckForGameEnd = true; + SystemTypes decreaseRoom = AllRooms.First(x => RequiredPlayerCount.TryGetValue(x, out var required) && GetNumPlayersInRoom(x) < required); if (RequiredPlayerCount[decreaseRoom] <= 1) RequiredPlayerCount.Remove(decreaseRoom); @@ -383,19 +384,33 @@ public static class Mingle } else { - Dictionary numPlayersInRoom = Main.EnumerateAlivePlayerControls().Select(x => (pc: x, room: x.GetPlainShipRoom())).GroupBy(x => !x.room ? SystemTypes.Outside : x.room.RoomId).ToDictionary(x => x.Key, x => x.Count()); + var aapc = Main.CachedAlivePlayerControls(); + var frames = 0; - yield return null; - - if (RequiredPlayerCount.All(x => numPlayersInRoom.GetValueOrDefault(x.Key, 0) == x.Value)) + foreach ((SystemTypes room, int requiredCount) in RequiredPlayerCount) { - Main.EnumerateAlivePlayerControls().NotifyPlayers(Utils.ColorString(Color.green, "✓"), 3f); - yield return null; - Time = Math.Max(Time - TimeDecreaseOnNoDeath, MinTime); - StartNewRound(); - yield break; + int count = 0; + + for (int index = 0; index < aapc.Count; index++) + if (aapc[index].IsInRoom(room) && ++count > requiredCount) + goto Skip; + + if (count != requiredCount) + goto Skip; + + if (frames < 28) + { + yield return null; + frames++; + } } + + Time = Math.Max(Time - TimeDecreaseOnNoDeath, MinTime); + StartNewRound(); + yield break; } + + Skip: yield return null; diff --git a/Modules/CustomTeamManager.cs b/Modules/CustomTeamManager.cs index 4cdf9a8ad..3f6699163 100644 --- a/Modules/CustomTeamManager.cs +++ b/Modules/CustomTeamManager.cs @@ -186,7 +186,7 @@ internal static class CustomTeamManager CustomTeam lastTeam = GetCustomTeam(lastPlayer.PlayerId); WinnerTeam = lastTeam; - CustomWinnerHolder.ResetAndSetWinner(CustomWinner.CustomTeam); + CustomWinnerHolder.SetWinnerOrAdditonalWinner(CustomWinner.CustomTeam); CustomWinnerHolder.WinnerIds = [lastPlayer.PlayerId]; return true; } @@ -242,7 +242,7 @@ internal static class CustomTeamManager } WinnerTeam = onlyTeam; - CustomWinnerHolder.ResetAndSetWinner(CustomWinner.CustomTeam); + CustomWinnerHolder.SetWinnerOrAdditonalWinner(CustomWinner.CustomTeam); CustomWinnerHolder.WinnerIds = winners; return true; } diff --git a/Modules/CustomWinnerHolder.cs b/Modules/CustomWinnerHolder.cs index 9e0399c6b..29e6bf7f1 100644 --- a/Modules/CustomWinnerHolder.cs +++ b/Modules/CustomWinnerHolder.cs @@ -88,15 +88,15 @@ public static class CustomWinnerHolder WinnerTeam = (CustomWinner)reader.ReadPackedInt32(); AdditionalWinnerTeams = []; - int AdditionalWinnerTeamsCount = reader.ReadPackedInt32(); - for (var i = 0; i < AdditionalWinnerTeamsCount; i++) AdditionalWinnerTeams.Add((AdditionalWinners)reader.ReadPackedInt32()); + int additionalWinnerTeamsCount = reader.ReadPackedInt32(); + for (var i = 0; i < additionalWinnerTeamsCount; i++) AdditionalWinnerTeams.Add((AdditionalWinners)reader.ReadPackedInt32()); WinnerRoles = []; - int WinnerRolesCount = reader.ReadPackedInt32(); - for (var i = 0; i < WinnerRolesCount; i++) WinnerRoles.Add((CustomRoles)reader.ReadPackedInt32()); + int winnerRolesCount = reader.ReadPackedInt32(); + for (var i = 0; i < winnerRolesCount; i++) WinnerRoles.Add((CustomRoles)reader.ReadPackedInt32()); WinnerIds = []; - int WinnerIdsCount = reader.ReadPackedInt32(); - for (var i = 0; i < WinnerIdsCount; i++) WinnerIds.Add(reader.ReadByte()); + int winnerIdsCount = reader.ReadPackedInt32(); + for (var i = 0; i < winnerIdsCount; i++) WinnerIds.Add(reader.ReadByte()); } } \ No newline at end of file diff --git a/Modules/GameOptionsSender/GameOptionsSender.cs b/Modules/GameOptionsSender/GameOptionsSender.cs index d3d4ea45a..cf2bf10d6 100644 --- a/Modules/GameOptionsSender/GameOptionsSender.cs +++ b/Modules/GameOptionsSender/GameOptionsSender.cs @@ -67,12 +67,13 @@ public abstract class GameOptionsSender for (byte i = 0; i < count; i++) { Il2CppSystem.Object logicComponent = GameManager.Instance.LogicComponents[i]; - if (logicComponent.TryCast(out _)) SendOptionsArray(optionArray, i); + if (logicComponent.TryCast(out _)) yield return SendOptionsArrayAsync(optionArray, i); yield return WaitFrameIfNecessary(); } } protected abstract void SendOptionsArray(Il2CppStructArray optionArray, byte logicOptionsIndex); + protected abstract IEnumerator SendOptionsArrayAsync(Il2CppStructArray optionArray, byte logicOptionsIndex); public abstract IGameOptions BuildGameOptions(); @@ -108,20 +109,6 @@ public abstract class GameOptionsSender for (var index = 0; index < AllSenders.Count; index++) { yield return WaitFrameIfNecessary(); - - if (PackedWriter != null && (PackedWriter.Length > 1000 || PackedWriterMessages >= AmongUsClient.Instance.GetMaxMessagePackingLimit())) - { - PackedWriter.EndMessage(); - var qa = DataFlagRateLimiter.Enqueue(() => AmongUsClient.Instance.SendOrDisconnect(PackedWriter)); - yield return qa.Wait(); - PackedWriterMessages = 0; - if (qa.Dropped) break; - PackedWriter.Clear(SendOption.Reliable); - PackedWriter.StartMessage(26); - PackedWriter.WritePacked(AmongUsClient.Instance.GameId); - } - - yield return WaitFrameIfNecessary(); if (index >= AllSenders.Count) break; GameOptionsSender sender = AllSenders[index]; diff --git a/Modules/GameOptionsSender/NormalGameOptionsSender.cs b/Modules/GameOptionsSender/NormalGameOptionsSender.cs index e169573ee..19fe3123c 100644 --- a/Modules/GameOptionsSender/NormalGameOptionsSender.cs +++ b/Modules/GameOptionsSender/NormalGameOptionsSender.cs @@ -1,4 +1,5 @@ using System; +using System.Collections; using AmongUs.GameOptions; using Hazel; using Il2CppInterop.Runtime.InteropTypes.Arrays; @@ -42,9 +43,19 @@ public sealed class NormalGameOptionsSender : GameOptionsSender return BasedGameOptions; } + protected override IEnumerator SendOptionsArrayAsync(Il2CppStructArray optionArray, byte logicOptionsIndex) + { + yield return DataFlagRateLimiter.Enqueue(SendOptionsAction(optionArray, logicOptionsIndex)).Wait(); + } + protected override void SendOptionsArray(Il2CppStructArray optionArray, byte logicOptionsIndex) { - DataFlagRateLimiter.Enqueue(() => + DataFlagRateLimiter.Enqueue(SendOptionsAction(optionArray, logicOptionsIndex)); + } + + private static Action SendOptionsAction(Il2CppStructArray optionArray, byte logicOptionsIndex) + { + return () => { MessageWriter writer = MessageWriter.Get(SendOption.Reliable); @@ -68,6 +79,6 @@ public sealed class NormalGameOptionsSender : GameOptionsSender AmongUsClient.Instance.SendOrDisconnect(writer); writer.Recycle(); - }); + }; } } \ No newline at end of file diff --git a/Modules/GameOptionsSender/PlayerGameOptionsSender.cs b/Modules/GameOptionsSender/PlayerGameOptionsSender.cs index 34e143a26..05d2cbd62 100644 --- a/Modules/GameOptionsSender/PlayerGameOptionsSender.cs +++ b/Modules/GameOptionsSender/PlayerGameOptionsSender.cs @@ -79,21 +79,6 @@ public sealed class PlayerGameOptionsSender(PlayerControl player) : GameOptionsS if (allSender is PlayerGameOptionsSender { IsDirty: true } sender) { - if (PackedWriter != null && (PackedWriter.Length > 500 || PackedWriterMessages >= AmongUsClient.Instance.GetMaxMessagePackingLimit())) - { - PackedWriter.EndMessage(); - var capturedWriter = PackedWriter; - DataFlagRateLimiter.Enqueue(() => - { - AmongUsClient.Instance.SendOrDisconnect(capturedWriter); - capturedWriter.Recycle(); - }, cleanup: capturedWriter.Recycle); - PackedWriterMessages = 0; - PackedWriter = MessageWriter.Get(SendOption.Reliable); - PackedWriter.StartMessage(26); - PackedWriter.WritePacked(AmongUsClient.Instance.GameId); - } - sender.SendGameOptions(); sender.IsDirty = false; } @@ -217,9 +202,58 @@ public sealed class PlayerGameOptionsSender(PlayerControl player) : GameOptionsS yield return base.SendGameOptionsAsync(); } + protected override IEnumerator SendOptionsArrayAsync(Il2CppStructArray optionArray, byte logicOptionsIndex) + { + if (PackedWriter.Length > 1000 || PackedWriterMessages >= AmongUsClient.Instance.GetMaxMessagePackingLimit()) + { + PackedWriter.EndMessage(); + var qa = DataFlagRateLimiter.Enqueue(() => AmongUsClient.Instance.SendOrDisconnect(PackedWriter)); + yield return qa.Wait(); + PackedWriterMessages = 0; + + if (qa.Dropped) + { + Main.Instance.StopCoroutine(ActiveCoroutine); + ActiveCoroutine = null; + PackedWriter.Recycle(); + PackedWriter = null; + yield return null; + yield break; + } + + PackedWriter.Clear(SendOption.Reliable); + PackedWriter.StartMessage(26); + PackedWriter.WritePacked(AmongUsClient.Instance.GameId); + } + + yield return WaitFrameIfNecessary(); + + PackedWriterMessages++; + + PackedWriter.StartMessage(6); + { + PackedWriter.Write(AmongUsClient.Instance.GameId); + PackedWriter.WritePacked(player.OwnerId); + + PackedWriter.StartMessage(1); + { + PackedWriter.WritePacked(GameManager.Instance.NetId); + PackedWriter.StartMessage(logicOptionsIndex); + { + PackedWriter.WriteBytesAndSize(optionArray); + } + PackedWriter.EndMessage(); + } + PackedWriter.EndMessage(); + } + PackedWriter.EndMessage(); + + Logger.Info($"PackedWriter message write complete - Length: {PackedWriter.Length}, Messages: {PackedWriterMessages}", "SendOptionsArrayAsync"); + } + protected override void SendOptionsArray(Il2CppStructArray optionArray, byte logicOptionsIndex) { - if (PackedWriter == null) + if (PackedWriter == null) // Single write { DataFlagRateLimiter.Enqueue(() => { @@ -249,6 +283,21 @@ public sealed class PlayerGameOptionsSender(PlayerControl player) : GameOptionsS }); return; } + + if (PackedWriter.Length > 1000 || PackedWriterMessages >= AmongUsClient.Instance.GetMaxMessagePackingLimit()) + { + PackedWriter.EndMessage(); + var capturedWriter = PackedWriter; + DataFlagRateLimiter.Enqueue(() => + { + AmongUsClient.Instance.SendOrDisconnect(capturedWriter); + capturedWriter.Recycle(); + }, cleanup: capturedWriter.Recycle); + PackedWriterMessages = 0; + PackedWriter = MessageWriter.Get(SendOption.Reliable); + PackedWriter.StartMessage(26); + PackedWriter.WritePacked(AmongUsClient.Instance.GameId); + } PackedWriterMessages++; @@ -270,7 +319,7 @@ public sealed class PlayerGameOptionsSender(PlayerControl player) : GameOptionsS } PackedWriter.EndMessage(); - Logger.Info($"PackedWriter message write complete - Length: {PackedWriter.Length}, Messages: {PackedWriterMessages}", "GameOptionsSender"); + Logger.Info($"PackedWriter message write complete - Length: {PackedWriter.Length}, Messages: {PackedWriterMessages}", "SendOptionsArray"); } public static void RemoveSender(PlayerControl player) diff --git a/Modules/Utils.cs b/Modules/Utils.cs index 3f25bc287..1cc0c22a4 100644 --- a/Modules/Utils.cs +++ b/Modules/Utils.cs @@ -1697,7 +1697,7 @@ public static class Utils else if (pc.IsAlive()) pc.Suicide(PlayerState.DeathReason.Bombed, terrorist.Object); } - CustomWinnerHolder.ResetAndSetWinner(CustomWinner.Terrorist); + CustomWinnerHolder.ShiftWinnerAndSetWinner(CustomWinner.Terrorist); CustomWinnerHolder.WinnerIds.Add(terrorist.PlayerId); } } @@ -1924,6 +1924,7 @@ public static class Utils // ============================================================================ int fullRpcSizeLimit = Options.MessageRpcSizeLimit.GetInt(); + if (vanilla && fullRpcSizeLimit > 1200) fullRpcSizeLimit = 1200; string resetName = Main.AllPlayerNames.GetValueOrDefault(sender.PlayerId, string.Empty); // -------------------------------------------------------------------------- diff --git a/Patches/ExilePatch.cs b/Patches/ExilePatch.cs index 21db80f8c..601a8b3a1 100644 --- a/Patches/ExilePatch.cs +++ b/Patches/ExilePatch.cs @@ -32,7 +32,7 @@ internal static class ExileControllerWrapUpPatch Logger.Info("The exiled player is an impostor, but the Innocent cannot win due to the settings", "Exeiled Winner Check"); else { - CustomWinnerHolder.ResetAndSetWinner(CustomWinner.Innocent); + CustomWinnerHolder.SetWinnerOrAdditonalWinner(CustomWinner.Innocent); Main.EnumeratePlayerControls() .Where(x => x.Is(CustomRoles.Innocent) && !x.IsAlive() && x.GetRealKiller()?.PlayerId == exiled.PlayerId) @@ -216,15 +216,22 @@ internal static class ExileControllerWrapUpPatch finally { WrapUpFinalizer(); } } } - - [HarmonyPatch(typeof(AirshipExileController), nameof(AirshipExileController.WrapUpAndSpawn))] - private static class AirshipExileControllerPatchAndroid + + [HarmonyPatch] + static class AirshipExileControllerPatch { - public static void Postfix(AirshipExileController __instance) + public static System.Reflection.MethodBase TargetMethod() { - if (Main.LIMap) return; + return Utils.GetStateMachineMoveNext(nameof(AirshipExileController.WrapUpAndSpawn)); + } + + public static void Postfix(Il2CppInterop.Runtime.InteropTypes.Il2CppObjectBase __instance, ref bool __result) + { + var wrapper = new StateMachineWrapper(__instance); + + if (wrapper.State != 1 || !__result || Main.LIMap) return; - try { WrapUpPostfix(__instance.initData.networkedPlayer); } + try { WrapUpPostfix(wrapper.Instance.initData.networkedPlayer); } finally { WrapUpFinalizer(); } } } diff --git a/Patches/IntroPatch.cs b/Patches/IntroPatch.cs index 9ea86284e..a79ae5d75 100644 --- a/Patches/IntroPatch.cs +++ b/Patches/IntroPatch.cs @@ -32,7 +32,7 @@ static class ShowRoleMoveNextPatch { var wrapper = new StateMachineWrapper(__instance); - if (wrapper.GetField("__1__state") != 1 || !__result) return; + if (wrapper.State != 1 || !__result) return; GameStates.InGame = true; SetUpRoleTextPatch.Postfix(wrapper.Instance); diff --git a/Patches/PlayerControlPatch.cs b/Patches/PlayerControlPatch.cs index 2de6fc432..3cfb8f566 100644 --- a/Patches/PlayerControlPatch.cs +++ b/Patches/PlayerControlPatch.cs @@ -692,7 +692,7 @@ internal static class MurderPlayerPatch if (Main.FirstDied == string.Empty && target.Is(CustomRoles.Youtuber)) { CustomSoundsManager.RPCPlayCustomSoundAll("Congrats"); - CustomWinnerHolder.ResetAndSetWinner(CustomWinner.Youtuber); + CustomWinnerHolder.SetWinnerOrAdditonalWinner(CustomWinner.Youtuber); CustomWinnerHolder.WinnerIds.Add(target.PlayerId); } diff --git a/Roles/Standard/Coven/SpellCaster.cs b/Roles/Standard/Coven/SpellCaster.cs index d2eccb647..c7e50bbdf 100644 --- a/Roles/Standard/Coven/SpellCaster.cs +++ b/Roles/Standard/Coven/SpellCaster.cs @@ -131,7 +131,7 @@ public class SpellCaster : CovenBase { if (IsWinConditionMet()) { - CustomWinnerHolder.ResetAndSetWinner(CustomWinner.Coven); + CustomWinnerHolder.ShiftWinnerAndSetWinner(CustomWinner.Coven); CustomWinnerHolder.WinnerIds.UnionWith(Main.EnumeratePlayerControls().Where(x => x.Is(Team.Coven)).Select(x => x.PlayerId)); } } diff --git a/Roles/Standard/Crewmate/Chaos/Dad.cs b/Roles/Standard/Crewmate/Chaos/Dad.cs index df8dc265c..2599585b4 100644 --- a/Roles/Standard/Crewmate/Chaos/Dad.cs +++ b/Roles/Standard/Crewmate/Chaos/Dad.cs @@ -342,7 +342,7 @@ public class Dad : RoleBase if (MilkTimer <= 0) { pc.TPToRandomVent(); - CustomWinnerHolder.ResetAndSetWinner(CustomWinner.Crewmate); + CustomWinnerHolder.ShiftWinnerAndSetWinner(CustomWinner.Crewmate); CustomWinnerHolder.WinnerIds.UnionWith(Main.EnumeratePlayerControls().Where(x => x.Is(Team.Crewmate)).Select(x => x.PlayerId)); } } diff --git a/Roles/Standard/Crewmate/Power/Speedrunner.cs b/Roles/Standard/Crewmate/Power/Speedrunner.cs index 668529de0..01aa3b424 100644 --- a/Roles/Standard/Crewmate/Power/Speedrunner.cs +++ b/Roles/Standard/Crewmate/Power/Speedrunner.cs @@ -64,7 +64,7 @@ internal class Speedrunner : RoleBase LateTask.New(() => { - if (!GameStates.IsEnded) CustomWinnerHolder.ResetAndSetWinner(CustomWinner.Crewmate); + if (!GameStates.IsEnded) CustomWinnerHolder.ShiftWinnerAndSetWinner(CustomWinner.Crewmate); }, 1f, log: false); } else if (completedTasks >= SpeedrunnerNotifyAtXTasksLeft.GetInt() && SpeedrunnerNotifyKillers.GetBool()) diff --git a/Roles/Standard/Impostor/Madmate/Hypocrite.cs b/Roles/Standard/Impostor/Madmate/Hypocrite.cs index 4f50efedf..0c6a85386 100644 --- a/Roles/Standard/Impostor/Madmate/Hypocrite.cs +++ b/Roles/Standard/Impostor/Madmate/Hypocrite.cs @@ -44,7 +44,7 @@ public class Hypocrite : RoleBase { Logger.Info($"Hypocrite ({pc.GetNameWithRole()}) finished all tasks", "Hypocrite"); pc.RPCPlayCustomSound("Congrats"); - CustomWinnerHolder.ResetAndSetWinner(CustomWinner.Impostor); + CustomWinnerHolder.ShiftWinnerAndSetWinner(CustomWinner.Impostor); } else if (NonImpGetsNotifyWhenLowTasks.GetBool() && completedTaskCount + 1 >= totalTaskCount - NotifyAtXTasksLeft.GetInt()) { diff --git a/Roles/Standard/Impostor/Support/Gangster.cs b/Roles/Standard/Impostor/Support/Gangster.cs index e6f62d046..40a1b0cf0 100644 --- a/Roles/Standard/Impostor/Support/Gangster.cs +++ b/Roles/Standard/Impostor/Support/Gangster.cs @@ -116,7 +116,7 @@ public class Gangster : RoleBase private static bool CanBeMadmate(PlayerControl pc) { - return pc != null && pc.IsCrewmate() && !pc.Is(CustomRoles.Madmate) + return pc && pc.IsCrewmate() && !pc.Is(CustomRoles.Madmate) && !( (pc.Is(CustomRoles.Sheriff) && !SheriffCanBeMadmate.GetBool()) || (pc.Is(CustomRoles.Mayor) && !MayorCanBeMadmate.GetBool()) || diff --git a/Roles/Standard/Neutral/Benign/Revolutionist.cs b/Roles/Standard/Neutral/Benign/Revolutionist.cs index 0196b3993..df6ae5e14 100644 --- a/Roles/Standard/Neutral/Benign/Revolutionist.cs +++ b/Roles/Standard/Neutral/Benign/Revolutionist.cs @@ -244,7 +244,7 @@ internal class Revolutionist : RoleBase { if (AmongUsClient.Instance.IsGameStarted && pc.IsDrawDone()) { - CustomWinnerHolder.ResetAndSetWinner(CustomWinner.Revolutionist); + CustomWinnerHolder.SetWinnerOrAdditonalWinner(CustomWinner.Revolutionist); Utils.GetDrawPlayerCount(pc.PlayerId, out List x); CustomWinnerHolder.WinnerIds.Add(pc.PlayerId); if (x != null) foreach (PlayerControl apc in x) CustomWinnerHolder.WinnerIds.Add(apc.PlayerId); diff --git a/Roles/Standard/Neutral/Evil/Arsonist.cs b/Roles/Standard/Neutral/Evil/Arsonist.cs index f949eb6f4..101ffc1b0 100644 --- a/Roles/Standard/Neutral/Evil/Arsonist.cs +++ b/Roles/Standard/Neutral/Evil/Arsonist.cs @@ -191,13 +191,13 @@ internal class Arsonist : RoleBase switch (apc) { case 1: - CustomWinnerHolder.ResetAndSetWinner(CustomWinner.Arsonist); + CustomWinnerHolder.SetWinnerOrAdditonalWinner(CustomWinner.Arsonist); CustomWinnerHolder.WinnerIds.Add(physics.myPlayer.PlayerId); break; case 2: if (Main.EnumerateAlivePlayerControls().Where(x => x.PlayerId != physics.myPlayer.PlayerId).All(x => x.GetCountTypes() == CountTypes.Crew)) { - CustomWinnerHolder.ResetAndSetWinner(CustomWinner.Arsonist); + CustomWinnerHolder.SetWinnerOrAdditonalWinner(CustomWinner.Arsonist); CustomWinnerHolder.WinnerIds.Add(physics.myPlayer.PlayerId); } diff --git a/Roles/Standard/Neutral/Evil/Collector.cs b/Roles/Standard/Neutral/Evil/Collector.cs index e9f7f872d..ef0883b76 100644 --- a/Roles/Standard/Neutral/Evil/Collector.cs +++ b/Roles/Standard/Neutral/Evil/Collector.cs @@ -89,7 +89,7 @@ public class Collector : RoleBase { if (check) return true; - CustomWinnerHolder.ResetAndSetWinner(CustomWinner.Collector); + CustomWinnerHolder.SetWinnerOrAdditonalWinner(CustomWinner.Collector); foreach (PlayerControl winner in pc) CustomWinnerHolder.WinnerIds.Add(winner.PlayerId); return true; diff --git a/Roles/Standard/Neutral/Evil/Doomsayer.cs b/Roles/Standard/Neutral/Evil/Doomsayer.cs index c9e9d837f..7372b0c9f 100644 --- a/Roles/Standard/Neutral/Evil/Doomsayer.cs +++ b/Roles/Standard/Neutral/Evil/Doomsayer.cs @@ -125,7 +125,7 @@ public class Doomsayer : RoleBase GuessingToWin[doomsayer.PlayerId] = DoomsayerAmountOfGuessesToWin.GetInt(); GuessesCount = DoomsayerAmountOfGuessesToWin.GetInt(); - CustomWinnerHolder.ResetAndSetWinner(CustomWinner.Doomsayer); + CustomWinnerHolder.SetWinnerOrAdditonalWinner(CustomWinner.Doomsayer); CustomWinnerHolder.WinnerIds.Add(doomsayer.PlayerId); } diff --git a/Roles/Standard/Neutral/Evil/Vector.cs b/Roles/Standard/Neutral/Evil/Vector.cs index 49ac22c16..0e8ecfa05 100644 --- a/Roles/Standard/Neutral/Evil/Vector.cs +++ b/Roles/Standard/Neutral/Evil/Vector.cs @@ -79,7 +79,7 @@ internal class Vector : RoleBase if (AmongUsClient.Instance.AmHost && VectorVentCount[pc.PlayerId] >= VectorVentNumWin) { pc.RPCPlayCustomSound("MarioCoin"); - CustomWinnerHolder.ResetAndSetWinner(CustomWinner.Vector); + CustomWinnerHolder.SetWinnerOrAdditonalWinner(CustomWinner.Vector); CustomWinnerHolder.WinnerIds.Add(pc.PlayerId); } } diff --git a/Roles/Standard/Neutral/Evil/Vulture.cs b/Roles/Standard/Neutral/Evil/Vulture.cs index da35c163f..a129af9ec 100644 --- a/Roles/Standard/Neutral/Evil/Vulture.cs +++ b/Roles/Standard/Neutral/Evil/Vulture.cs @@ -154,7 +154,7 @@ public class Vulture : RoleBase if (TotalEaten >= NumberOfReportsToWin.GetInt() && GameStates.IsInTask) { - CustomWinnerHolder.ResetAndSetWinner(CustomWinner.Vulture); + CustomWinnerHolder.SetWinnerOrAdditonalWinner(CustomWinner.Vulture); CustomWinnerHolder.WinnerIds.Add(pc.PlayerId); return false; } diff --git a/Roles/Standard/Neutral/Evil/Workaholic.cs b/Roles/Standard/Neutral/Evil/Workaholic.cs index 4d41765ed..9985b046a 100644 --- a/Roles/Standard/Neutral/Evil/Workaholic.cs +++ b/Roles/Standard/Neutral/Evil/Workaholic.cs @@ -80,7 +80,7 @@ internal class Workaholic : RoleBase foreach (PlayerControl pc in Main.EnumerateAlivePlayerControls()) pc.Suicide(pc.PlayerId == player.PlayerId ? PlayerState.DeathReason.Overtired : PlayerState.DeathReason.Ashamed, player); - CustomWinnerHolder.ResetAndSetWinner(CustomWinner.Workaholic); + CustomWinnerHolder.ShiftWinnerAndSetWinner(CustomWinner.Workaholic); CustomWinnerHolder.WinnerIds.Add(player.PlayerId); } } diff --git a/Roles/Standard/Neutral/Killing/Infection.cs b/Roles/Standard/Neutral/Killing/Infection.cs index 8d3b5ef01..855594d0a 100644 --- a/Roles/Standard/Neutral/Killing/Infection.cs +++ b/Roles/Standard/Neutral/Killing/Infection.cs @@ -358,7 +358,7 @@ public class Infection : RoleBase player.Suicide(PlayerState.DeathReason.Curse, infectionSource); } - CustomWinnerHolder.ResetAndSetWinner(CustomWinner.Infection); + CustomWinnerHolder.SetWinnerOrAdditonalWinner(CustomWinner.Infection); for (int index = 0; index < apc.Count; index++) { PlayerControl pc = apc[index]; diff --git a/Roles/Standard/Neutral/Killing/Thanos.cs b/Roles/Standard/Neutral/Killing/Thanos.cs index 31273a686..bf9362337 100644 --- a/Roles/Standard/Neutral/Killing/Thanos.cs +++ b/Roles/Standard/Neutral/Killing/Thanos.cs @@ -161,7 +161,7 @@ public class Thanos : RoleBase { if (CollectedStones.Count == StoneEnum.Length && CanWinAfterCollectingAllStones.GetBool()) { - CustomWinnerHolder.ResetAndSetWinner(CustomWinner.Thanos); + CustomWinnerHolder.ShiftWinnerAndSetWinner(CustomWinner.Thanos); CustomWinnerHolder.WinnerIds.Add(pc.PlayerId); return; }