diff --git a/src/CrowdedMod/Components/MeetingHudPagingBehaviour.cs b/src/CrowdedMod/Components/MeetingHudPagingBehaviour.cs
index 5b7616a..d859a42 100644
--- a/src/CrowdedMod/Components/MeetingHudPagingBehaviour.cs
+++ b/src/CrowdedMod/Components/MeetingHudPagingBehaviour.cs
@@ -25,7 +25,7 @@ public override void Update()
{
base.Update();
- if (meetingHud.state is MeetingHud.VoteStates.Animating or MeetingHud.VoteStates.Proceeding ||
+ if (meetingHud.state is MeetingHud.MeetingStates.Animating or MeetingHud.MeetingStates.Proceeding ||
meetingHud.TimerText.text.Contains($" ({PageIndex + 1}/{MaxPageIndex + 1})"))
return;
diff --git a/src/CrowdedMod/CrowdedMod.csproj b/src/CrowdedMod/CrowdedMod.csproj
index 2789976..64e9a0a 100644
--- a/src/CrowdedMod/CrowdedMod.csproj
+++ b/src/CrowdedMod/CrowdedMod.csproj
@@ -2,7 +2,7 @@
net6.0
- 2.10.0
+ 2.12.0
CrowdedMods, andry08
latest
@@ -11,15 +11,15 @@
Steam
- 2024.9.4
+ 2026.9.29
-
-
+
+
-
+
diff --git a/src/CrowdedMod/CrowdedModPlugin.cs b/src/CrowdedMod/CrowdedModPlugin.cs
index 7a18fb2..1af56be 100644
--- a/src/CrowdedMod/CrowdedModPlugin.cs
+++ b/src/CrowdedMod/CrowdedModPlugin.cs
@@ -12,11 +12,10 @@ namespace CrowdedMod;
[BepInAutoPlugin("xyz.crowdedmods.crowdedmod")]
[BepInProcess("Among Us.exe")]
[BepInDependency(ReactorPlugin.Id)]
-[ReactorModFlags(ModFlags.RequireOnAllClients)]
[BepInDependency("gg.reactor.debugger", BepInDependency.DependencyFlags.SoftDependency)]
public partial class CrowdedModPlugin : BasePlugin
{
- public const int MaxPlayers = 254; // allegedly. should stick to 127 tho
+ public const int MaxPlayers = 255; // allegedly. should stick to 127 tho
public const int MaxImpostors = MaxPlayers / 2;
public static bool ForceDisableFreeColor { get; set; } = false;
diff --git a/src/CrowdedMod/Patches/CreateGameOptionsPatches.cs b/src/CrowdedMod/Patches/CreateGameOptionsPatches.cs
index a7bb22b..eb1e9d4 100644
--- a/src/CrowdedMod/Patches/CreateGameOptionsPatches.cs
+++ b/src/CrowdedMod/Patches/CreateGameOptionsPatches.cs
@@ -1,188 +1,137 @@
-using System;
-using AmongUs.GameOptions;
using HarmonyLib;
-using Reactor.Utilities.Extensions;
using TMPro;
using UnityEngine;
+using UnityEngine.Events;
+using UnityEngine.UI;
+using Object = UnityEngine.Object;
+/// Taken from AleLuduMod https://github.com/townofus-pl/AleLuduMod/blob/main/AleLuduMod/Patches/CreateGameOptionsPatches.cs
namespace CrowdedMod.Patches;
internal static class CreateGameOptionsPatches
{
- private static bool HasManyImpostors(this IGameOptions options) =>
- options.GameMode is GameModes.Normal or GameModes.NormalFools;
-
- private static bool IsHost(this CreateOptionsPicker picker) => picker.mode == SettingsMode.Host;
-
- [HarmonyPatch(typeof(CreateOptionsPicker), nameof(CreateOptionsPicker.Awake))]
- public static class CreateOptionsPicker_Awake
+ private static GameOptionButton _minButton = null!;
+ private static GameOptionButton _maxButton = null!;
+ private static GameOptionButton _doubleMinusButton = null!;
+ private static GameOptionButton _doublePlusButton = null!;
+
+ [HarmonyPatch(typeof(CreateGameOptions), nameof(CreateGameOptions.Start))]
+ public static class CreateGameOptions_Start
{
- public static void Postfix(CreateOptionsPicker __instance)
+ public static void Postfix(CreateGameOptions __instance)
{
- if (!__instance.IsHost()) return;
-
+ // move stuff to make space for -5 and +5 buttons
+ foreach (Il2CppSystem.Object obj in __instance.capacityOption.transform)
{
- var firstButtonRenderer = __instance.MaxPlayerButtons[0];
- firstButtonRenderer.GetComponentInChildren().text = "-";
- firstButtonRenderer.enabled = false;
-
- var firstButtonButton = firstButtonRenderer.GetComponent();
- firstButtonButton.OnClick.RemoveAllListeners();
- firstButtonButton.OnClick.AddListener((Action)(() =>
- {
- for (var i = 1; i < 11; i++)
- {
- var playerButton = __instance.MaxPlayerButtons[i];
-
- var tmp = playerButton.GetComponentInChildren();
- var newValue = Mathf.Max(byte.Parse(tmp.text) - 10, byte.Parse(playerButton.name) - 2);
- tmp.text = newValue.ToString();
- }
-
- __instance.UpdateMaxPlayersButtons(__instance.GetTargetOptions());
- }));
- firstButtonRenderer.Destroy();
-
- var lastButtonRenderer = __instance.MaxPlayerButtons[^1];
- lastButtonRenderer.GetComponentInChildren().text = "+";
- lastButtonRenderer.enabled = false;
-
- var lastButtonButton = lastButtonRenderer.GetComponent();
- lastButtonButton.OnClick.RemoveAllListeners();
- lastButtonButton.OnClick.AddListener((Action)(() =>
- {
- for (var i = 1; i < 11; i++)
- {
- var playerButton = __instance.MaxPlayerButtons[i];
-
- var tmp = playerButton.GetComponentInChildren();
- var newValue = Mathf.Min(byte.Parse(tmp.text) + 10,
- CrowdedModPlugin.MaxPlayers - 14 + byte.Parse(playerButton.name));
- tmp.text = newValue.ToString();
- }
-
- __instance.UpdateMaxPlayersButtons(__instance.GetTargetOptions());
- }));
- lastButtonRenderer.Destroy();
-
- for (var i = 1; i < 11; i++)
- {
- var playerButton = __instance.MaxPlayerButtons[i].GetComponent();
- var text = playerButton.GetComponentInChildren();
-
- playerButton.OnClick.RemoveAllListeners();
- playerButton.OnClick.AddListener((Action)(() =>
- {
- var maxPlayers = byte.Parse(text.text);
- var maxImp = Mathf.Min(__instance.GetTargetOptions().NumImpostors, maxPlayers / 2);
- __instance.GetTargetOptions().SetInt(Int32OptionNames.NumImpostors, maxImp);
- __instance.ImpostorButtons[1].TextMesh.text = maxImp.ToString();
- __instance.SetMaxPlayersButtons(maxPlayers);
- }));
- }
-
- foreach (var button in __instance.MaxPlayerButtons)
- {
- button.enabled = button.GetComponentInChildren().text == __instance.GetTargetOptions().MaxPlayers.ToString();
- }
+ var t = obj.Cast();
+ if (!t || t.gameObject.name is "LabelBackground" or "Title Text") continue;
+ t.localPosition += new Vector3(1, 0, 0);
}
- var secondButton = __instance.ImpostorButtons[1];
- secondButton.SpriteRenderer.enabled = false;
- secondButton.transform.FindChild("ConsoleHighlight").gameObject.Destroy();
- secondButton.PassiveButton.OnClick.RemoveAllListeners();
- secondButton.BoxCollider.size = new Vector2(0f, 0f);
-
- var secondButtonText = secondButton.TextMesh;
- secondButtonText.text = __instance.GetTargetOptions().NumImpostors.ToString();
-
- var firstButton = __instance.ImpostorButtons[0];
- firstButton.SpriteRenderer.enabled = false;
- firstButton.TextMesh.text = "-";
+ // create -5 and +5 buttons
+ _doubleMinusButton = Object.Instantiate(__instance.capacityOption.MinusBtn, __instance.capacityOption.MinusBtn.transform.parent);
+ var dmText = _doubleMinusButton.GetComponentInChildren();
+ dmText.text = "-5";
+ dmText.fontStyle = FontStyles.Normal;
+ _doubleMinusButton.transform.localPosition -= new Vector3(0.5f, 0, 0);
+ _doubleMinusButton.OnClick = new Button.ButtonClickedEvent();
+ _doubleMinusButton.OnClick.AddListener((UnityAction)(() =>
+ {
+ __instance.capacityOption.Increment = 5;
+ __instance.capacityOption.Decrease();
+ __instance.capacityOption.Increment = 1;
+ }));
- var firstPassiveButton = firstButton.PassiveButton;
- firstPassiveButton.OnClick.RemoveAllListeners();
- firstPassiveButton.OnClick.AddListener((Action)(() => {
- var newVal = Mathf.Clamp(
- byte.Parse(secondButtonText.text) - 1,
- 1,
- __instance.GetTargetOptions().MaxPlayers / 2
- );
- __instance.SetImpostorButtons(newVal);
- secondButtonText.text = newVal.ToString();
+ _doublePlusButton = Object.Instantiate(__instance.capacityOption.PlusBtn, __instance.capacityOption.PlusBtn.transform.parent);
+ var dpText = _doublePlusButton.GetComponentInChildren();
+ dpText.text = "+5";
+ dpText.fontStyle = FontStyles.Normal;
+ _doublePlusButton.transform.localPosition += new Vector3(0.5f, 0, 0);
+ _doublePlusButton.OnClick = new Button.ButtonClickedEvent();
+ _doublePlusButton.OnClick.AddListener((UnityAction)(() =>
+ {
+ __instance.capacityOption.Increment = 5;
+ __instance.capacityOption.Increase();
+ __instance.capacityOption.Increment = 1;
}));
- var thirdButton = __instance.ImpostorButtons[2];
- thirdButton.SpriteRenderer.enabled = false;
- thirdButton.TextMesh.text = "+";
+ // create min and max buttons
+ _minButton = Object.Instantiate(__instance.capacityOption.MinusBtn, __instance.capacityOption.MinusBtn.transform.parent);
+ var minText = _minButton.GetComponentInChildren();
+ minText.text = "MIN";
+ minText.fontSize = minText.fontSizeMax = 2;
+ minText.fontStyle = FontStyles.Normal;
+ minText.alignment = TextAlignmentOptions.Center;
+ _minButton.SetInteractable(true);
+ _minButton.transform.localPosition -= new Vector3(1, 0, 0);
+ _minButton.OnClick = new Button.ButtonClickedEvent();
+ _minButton.OnClick.AddListener((UnityAction)(() =>
+ {
+ __instance.capacityOption.Increment = int.MaxValue;
+ __instance.capacityOption.Decrease();
+ __instance.capacityOption.Increment = 1;
+ }));
- var thirdPassiveButton = thirdButton.PassiveButton;
- thirdPassiveButton.OnClick.RemoveAllListeners();
- thirdPassiveButton.OnClick.AddListener((Action)(() => {
- var newVal = Mathf.Clamp(
- byte.Parse(secondButtonText.text) + 1,
- 1,
- __instance.GetTargetOptions().MaxPlayers / 2
- );
- __instance.SetImpostorButtons(newVal);
- secondButtonText.text = newVal.ToString();
+ // create max button
+ _maxButton = Object.Instantiate(__instance.capacityOption.PlusBtn, __instance.capacityOption.PlusBtn.transform.parent);
+ var maxText = _maxButton.GetComponentInChildren();
+ maxText.text = "MAX";
+ maxText.fontSize = maxText.fontSizeMax = 2;
+ maxText.fontStyle = FontStyles.Normal;
+ maxText.alignment = TextAlignmentOptions.Center;
+ _maxButton.SetInteractable(true);
+ _maxButton.transform.localPosition += new Vector3(1, 0, 0);
+ _maxButton.OnClick = new Button.ButtonClickedEvent();
+ _maxButton.OnClick.AddListener((UnityAction)(() =>
+ {
+ __instance.capacityOption.Increment = int.MaxValue;
+ __instance.capacityOption.Increase();
+ __instance.capacityOption.Increment = 1;
}));
+
+ Debug.Log("Finished creating new buttons for player count picker.");
}
}
- [HarmonyPatch(typeof(CreateOptionsPicker), nameof(CreateOptionsPicker.UpdateMaxPlayersButtons))]
- public static class CreateOptionsPicker_UpdateMaxPlayersButtons
+ [HarmonyPatch(typeof(CreateGameOptions), nameof(CreateGameOptions.Show))]
+ public static class CreateGameOptions_Show
{
- public static bool Prefix(CreateOptionsPicker __instance, [HarmonyArgument(0)] IGameOptions opts)
+ public static void Prefix(CreateGameOptions __instance)
{
- if (__instance.CrewArea)
- {
- __instance.CrewArea.SetCrewSize(opts.MaxPlayers, opts.NumImpostors);
- }
+ // set new valid range
+ var newRange = new IntRange(1, CrowdedModPlugin.MaxPlayers);
+ var newFloatRange = new FloatRange(1, CrowdedModPlugin.MaxPlayers);
- var selectedAsString = opts.MaxPlayers.ToString();
- for (var i = 1; i < __instance.MaxPlayerButtons.Count - 1; i++)
- {
- __instance.MaxPlayerButtons[i].enabled = __instance.MaxPlayerButtons[i].GetComponentInChildren().text == selectedAsString;
- }
-
- return false;
+ __instance.capacitySetting.ValidRange = newRange;
+ __instance.capacityOption.ValidRange = newFloatRange;
}
}
- [HarmonyPatch(typeof(CreateOptionsPicker), nameof(CreateOptionsPicker.UpdateImpostorsButtons))]
- public static class CreateOptionsPicker_UpdateImpostorsButtons
+ [HarmonyPatch(typeof(CreateGameOptions), nameof(CreateGameOptions.ValueChanged))]
+ public static class CreateGameOptions_ValueChanged
{
- public static bool Prefix(CreateOptionsPicker __instance)
+ public static void Postfix(OptionBehaviour option)
{
- var hasMany = __instance.GetTargetOptions().HasManyImpostors();
+ var numOpt = option.Cast();
+ if (!numOpt) return;
+
+ _minButton.SetInteractable(true);
+ _maxButton.SetInteractable(true);
+ _doubleMinusButton.SetInteractable(true);
+ _doublePlusButton.SetInteractable(true);
- foreach (var button in __instance.ImpostorButtons)
+ if (Mathf.Approximately(numOpt.Value, numOpt.ValidRange.max))
{
- button.SetOptionEnabled(hasMany);
+ _maxButton.SetInteractable(false);
+ _doublePlusButton.SetInteractable(false);
+ }
+ else if (Mathf.Approximately(numOpt.Value, numOpt.ValidRange.min))
+ {
+ _minButton.SetInteractable(false);
+ _doubleMinusButton.SetInteractable(false);
}
- __instance.ImpostorText.color = hasMany ? Color.white : Palette.DisabledGrey;
-
- return false;
- }
- }
-
- [HarmonyPatch(typeof(CreateOptionsPicker), nameof(CreateOptionsPicker.Refresh))]
- public static class CreateOptionsPicker_Refresh
- {
- public static bool Prefix(CreateOptionsPicker __instance)
- {
- var options = __instance.GetTargetOptions();
-
- __instance.UpdateImpostorsButtons(options.NumImpostors);
- __instance.UpdateMaxPlayersButtons(options);
- __instance.UpdateLanguageButton((uint)options.Keywords);
- __instance.MapMenu.UpdateMapButtons(options.MapId);
- var modeName = GameModesHelpers.ModeToName[GameOptionsManager.Instance.CurrentGameOptions.GameMode];
- __instance.GameModeText.text = TranslationController.Instance.GetString(modeName);
-
- return false;
+ Debug.Log("Updated button states!");
}
}
}
\ No newline at end of file
diff --git a/src/CrowdedMod/Patches/GameStartManagerPatch.cs b/src/CrowdedMod/Patches/GameStartManagerPatch.cs
new file mode 100644
index 0000000..45a9119
--- /dev/null
+++ b/src/CrowdedMod/Patches/GameStartManagerPatch.cs
@@ -0,0 +1,30 @@
+using HarmonyLib;
+
+namespace CrowdedMod.Patches;
+
+// Taken from AleLuduMod https://github.com/townofus-pl/AleLuduMod/blob/main/AleLuduMod/Patches/GameStartManagerPatch.cs
+internal static class GameStartManagerPatch
+{
+ [HarmonyPatch(typeof(GameStartManager), nameof(GameStartManager.Update))]
+ public static class GameStartManagerUpdatePatch
+ {
+ public static void Postfix(GameStartManager __instance)
+ {
+ if (GameData.Instance == null || AmongUsClient.Instance == null || GameManager.Instance == null || GameManager.Instance.LogicOptions == null || __instance.PlayerCounter == null) return;
+
+ int playerCount = GameData.Instance.PlayerCount;
+ int minPlayers = __instance.MinPlayers;
+
+ string counterColor = playerCount switch
+ {
+ _ when playerCount < minPlayers => "",
+ _ when playerCount == minPlayers => "",
+ _ => ""
+ };
+
+ int maxPlayers = AmongUsClient.Instance.NetworkMode is NetworkModes.LocalGame ? 15 : GameManager.Instance.LogicOptions.MaxPlayers;
+
+ __instance.PlayerCounter.text = $"{counterColor}{playerCount}/{maxPlayers}";
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/CrowdedMod/Patches/GenericPatches.cs b/src/CrowdedMod/Patches/GenericPatches.cs
index 4a8802e..46507bc 100644
--- a/src/CrowdedMod/Patches/GenericPatches.cs
+++ b/src/CrowdedMod/Patches/GenericPatches.cs
@@ -71,63 +71,6 @@ public static bool Prefix(PlayerTab __instance)
}
}
- // I did not find a use of this method, but still patching for future updates
- // maxExpectedPlayers is unknown, looks like server code tbh
- [HarmonyPatch(typeof(GameOptionsData), nameof(GameOptionsData.AreInvalid))]
- public static class InvalidOptionsPatches
- {
- public static bool Prefix(GameOptionsData __instance, [HarmonyArgument(0)] int maxExpectedPlayers)
- {
- return __instance.MaxPlayers > maxExpectedPlayers ||
- __instance.NumImpostors < 1 ||
- __instance.NumImpostors + 1 > maxExpectedPlayers / 2 ||
- __instance.KillDistance is < 0 or > 2 ||
- __instance.PlayerSpeedMod is <= 0f or > 3f;
- }
- }
-
- [HarmonyPatch(typeof(GameStartManager), nameof(GameStartManager.Update))]
- public static class GameStartManagerUpdatePatch
- {
- private static string fixDummyCounterColor = string.Empty;
-
- public static void Prefix(GameStartManager __instance)
- {
- if (GameData.Instance == null || __instance.LastPlayerCount == GameData.Instance.PlayerCount)
- {
- return;
- }
-
- if (__instance.LastPlayerCount > __instance.MinPlayers)
- {
- fixDummyCounterColor = "";
- }
- else if (__instance.LastPlayerCount == __instance.MinPlayers)
- {
- fixDummyCounterColor = "";
- }
- else
- {
- fixDummyCounterColor = "";
- }
- }
-
- public static void Postfix(GameStartManager __instance)
- {
- if (string.IsNullOrEmpty(fixDummyCounterColor) ||
- GameData.Instance == null ||
- GameManager.Instance == null ||
- GameManager.Instance.LogicOptions == null)
- {
- return;
- }
-
- __instance.PlayerCounter.text =
- $"{fixDummyCounterColor}{GameData.Instance.PlayerCount}/{GameManager.Instance.LogicOptions.MaxPlayers}";
- fixDummyCounterColor = string.Empty;
- }
- }
-
[HarmonyPatch(typeof(InnerNetServer), nameof(InnerNetServer.HandleNewGameJoin))]
public static class InnerNetSerer_HandleNewGameJoin
{