11using System ;
2+ using AmongUs . GameOptions ;
23using HarmonyLib ;
34using Reactor . Utilities . Extensions ;
45using 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}
0 commit comments