Skip to content

Commit 84168a9

Browse files
committed
Maybe fixed for 2022.12.14s
1 parent 3a6e8b4 commit 84168a9

5 files changed

Lines changed: 22 additions & 28 deletions

File tree

src/CrowdedMod/CrowdedMod.csproj

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<TargetFramework>net6.0</TargetFramework>
5-
<Version>2.7.0-corelcr</Version>
5+
<Version>2.9.0-corelcr</Version>
66
<Authors>CrowdedMods, andry08</Authors>
77

88
<LangVersion>latest</LangVersion>
@@ -11,11 +11,12 @@
1111
</PropertyGroup>
1212
<PropertyGroup>
1313
<GamePlatform Condition="'$(GamePlatform)' == ''">Steam</GamePlatform>
14-
<GameVersion>2022.10.25</GameVersion>
14+
<GameVersion>2022.12.14</GameVersion>
15+
<AmongUs>D:\RE\Among Us\v2022.12.14s\BepInEx</AmongUs>
1516
</PropertyGroup>
1617
<ItemGroup>
17-
<PackageReference Include="Reactor" Version="2.0.0" />
18-
<PackageReference Include="BepInEx.Unity.IL2CPP" Version="6.0.0-be.662" />
18+
<PackageReference Include="Reactor" Version="2.1.0" />
19+
<PackageReference Include="BepInEx.Unity.IL2CPP" Version="6.0.0-be.663" />
1920
<PackageReference Include="AmongUs.GameLibs.$(GamePlatform)" Version="$(GameVersion)" PrivateAssets="all" />
2021

2122
<PackageReference Include="BepInEx.AutoPlugin" Version="1.1.0" PrivateAssets="all" />

src/CrowdedMod/CrowdedModPlugin.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.Linq;
2+
using AmongUs.GameOptions;
23
using BepInEx;
34
using BepInEx.Unity.IL2CPP;
45
using HarmonyLib;
@@ -18,8 +19,9 @@ public partial class CrowdedModPlugin : BasePlugin
1819

1920
public override void Load()
2021
{
21-
GameOptionsData.RecommendedImpostors = GameOptionsData.MaxImpostors = Enumerable.Repeat(127, 127).ToArray();
22-
GameOptionsData.MinPlayers = Enumerable.Repeat(4, 127).ToArray();
22+
NormalGameOptionsV07.RecommendedImpostors = NormalGameOptionsV07.MaxImpostors = Enumerable.Repeat(127, 127).ToArray();
23+
NormalGameOptionsV07.MinPlayers = Enumerable.Repeat(4, 127).ToArray();
24+
2325

2426
Harmony.PatchAll();
2527
}

src/CrowdedMod/Net/SetColorRpc.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
using Hazel;
1+
using CrowdedMod;
2+
using Hazel;
23
using Reactor.Networking.Attributes;
34
using Reactor.Networking.Rpc;
4-
55
namespace CrowdedMod.Net;
66

77
[RegisterCustomRpc((uint) CustomRpcCalls.SetColor)]

src/CrowdedMod/Patches/CreateGameOptionsPatches.cs

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using AmongUs.GameOptions;
23
using HarmonyLib;
34
using Reactor.Utilities.Extensions;
45
using TMPro;
@@ -68,6 +69,11 @@ public static void Postfix(CreateOptionsPicker __instance)
6869
playerButton.OnClick.AddListener((Action)(() =>
6970
__instance.SetMaxPlayersButtons(byte.Parse(text.text))));
7071
}
72+
73+
for (var i = 0; i < __instance.MaxPlayerButtons.Count; i++) {
74+
__instance.MaxPlayerButtons[i].enabled =
75+
__instance.MaxPlayerButtons[i].GetComponentInChildren<TextMeshPro>().text == __instance.GetTargetOptions().MaxPlayers.ToString();
76+
}
7177
}
7278

7379
{
@@ -79,6 +85,8 @@ public static void Postfix(CreateOptionsPicker __instance)
7985
secondButton.GetComponent<BoxCollider2D>().Destroy();
8086

8187
var secondButtonText = secondButton.GetComponentInChildren<TextMeshPro>();
88+
secondButtonText.text =
89+
__instance.GetTargetOptions().NumImpostors.ToString();
8290

8391
var firstButtonRenderer = __instance.ImpostorButtons[0];
8492
firstButtonRenderer.enabled = false;
@@ -112,11 +120,11 @@ public static void Postfix(CreateOptionsPicker __instance)
112120
[HarmonyPatch(typeof(CreateOptionsPicker), nameof(CreateOptionsPicker.UpdateMaxPlayersButtons))]
113121
public static class CreateOptionsPicker_UpdateMaxPlayersButtons
114122
{
115-
public static bool Prefix(CreateOptionsPicker __instance, [HarmonyArgument(0)] GameOptionsData opts)
123+
public static bool Prefix(CreateOptionsPicker __instance, [HarmonyArgument(0)] IGameOptions opts)
116124
{
117125
if (__instance.CrewArea)
118126
{
119-
__instance.CrewArea.SetCrewSize(opts.MaxPlayers, opts.numImpostors);
127+
__instance.CrewArea.SetCrewSize(opts.MaxPlayers, opts.NumImpostors);
120128
}
121129

122130
var selectedAsString = opts.MaxPlayers.ToString();
@@ -137,22 +145,5 @@ public static bool Prefix()
137145
return false;
138146
}
139147
}
140-
141-
[HarmonyPatch(typeof(GameOptionsData), nameof(GameOptionsData.GameHostOptions), MethodType.Getter)]
142-
public static class SaveManager_get_GameHostOptions
143-
{
144-
public static bool Prefix(out GameOptionsData __result)
145-
{
146-
GameOptionsData.hostOptionsData ??= GameOptionsData.LoadGameHostOptions();
147-
148-
// patched because of impostor clamping
149-
GameOptionsData.hostOptionsData.NumImpostors =
150-
Mathf.Clamp(GameOptionsData.hostOptionsData.NumImpostors, 1, GameOptionsData.hostOptionsData.MaxPlayers - 1);
151-
GameOptionsData.hostOptionsData.KillDistance = Mathf.Clamp(GameOptionsData.hostOptionsData.KillDistance, 0, 2);
152-
153-
__result = GameOptionsData.hostOptionsData;
154-
return false;
155-
}
156-
}
157148
}
158149
}

src/CrowdedMod/Patches/GenericPatches.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public static void Postfix(GameStartManager __instance)
6868
{
6969
if (fixDummyCounterColor != null)
7070
{
71-
__instance.PlayerCounter.text = $"{fixDummyCounterColor}{GameData.Instance.PlayerCount}/{PlayerControl.GameOptions.MaxPlayers}";
71+
__instance.PlayerCounter.text = $"{fixDummyCounterColor}{GameData.Instance.PlayerCount}/{GameManager.Instance.LogicOptions.MaxPlayers}";
7272
fixDummyCounterColor = null;
7373
}
7474
}

0 commit comments

Comments
 (0)