Skip to content

Commit

Permalink
Maybe fixed for 2022.12.14s
Browse files Browse the repository at this point in the history
  • Loading branch information
przebor committed Dec 25, 2022
1 parent 3a6e8b4 commit 84168a9
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 28 deletions.
9 changes: 5 additions & 4 deletions src/CrowdedMod/CrowdedMod.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Version>2.7.0-corelcr</Version>
<Version>2.9.0-corelcr</Version>
<Authors>CrowdedMods, andry08</Authors>

<LangVersion>latest</LangVersion>
Expand All @@ -11,11 +11,12 @@
</PropertyGroup>
<PropertyGroup>
<GamePlatform Condition="'$(GamePlatform)' == ''">Steam</GamePlatform>
<GameVersion>2022.10.25</GameVersion>
<GameVersion>2022.12.14</GameVersion>
<AmongUs>D:\RE\Among Us\v2022.12.14s\BepInEx</AmongUs>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Reactor" Version="2.0.0" />
<PackageReference Include="BepInEx.Unity.IL2CPP" Version="6.0.0-be.662" />
<PackageReference Include="Reactor" Version="2.1.0" />
<PackageReference Include="BepInEx.Unity.IL2CPP" Version="6.0.0-be.663" />
<PackageReference Include="AmongUs.GameLibs.$(GamePlatform)" Version="$(GameVersion)" PrivateAssets="all" />

<PackageReference Include="BepInEx.AutoPlugin" Version="1.1.0" PrivateAssets="all" />
Expand Down
6 changes: 4 additions & 2 deletions src/CrowdedMod/CrowdedModPlugin.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Linq;
using AmongUs.GameOptions;
using BepInEx;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
Expand All @@ -18,8 +19,9 @@ public partial class CrowdedModPlugin : BasePlugin

public override void Load()
{
GameOptionsData.RecommendedImpostors = GameOptionsData.MaxImpostors = Enumerable.Repeat(127, 127).ToArray();
GameOptionsData.MinPlayers = Enumerable.Repeat(4, 127).ToArray();
NormalGameOptionsV07.RecommendedImpostors = NormalGameOptionsV07.MaxImpostors = Enumerable.Repeat(127, 127).ToArray();
NormalGameOptionsV07.MinPlayers = Enumerable.Repeat(4, 127).ToArray();


Harmony.PatchAll();
}
Expand Down
4 changes: 2 additions & 2 deletions src/CrowdedMod/Net/SetColorRpc.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Hazel;
using CrowdedMod;
using Hazel;
using Reactor.Networking.Attributes;
using Reactor.Networking.Rpc;

namespace CrowdedMod.Net;

[RegisterCustomRpc((uint) CustomRpcCalls.SetColor)]
Expand Down
29 changes: 10 additions & 19 deletions src/CrowdedMod/Patches/CreateGameOptionsPatches.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using AmongUs.GameOptions;
using HarmonyLib;
using Reactor.Utilities.Extensions;
using TMPro;
Expand Down Expand Up @@ -68,6 +69,11 @@ public static void Postfix(CreateOptionsPicker __instance)
playerButton.OnClick.AddListener((Action)(() =>
__instance.SetMaxPlayersButtons(byte.Parse(text.text))));
}

for (var i = 0; i < __instance.MaxPlayerButtons.Count; i++) {
__instance.MaxPlayerButtons[i].enabled =
__instance.MaxPlayerButtons[i].GetComponentInChildren<TextMeshPro>().text == __instance.GetTargetOptions().MaxPlayers.ToString();
}
}

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

var secondButtonText = secondButton.GetComponentInChildren<TextMeshPro>();
secondButtonText.text =
__instance.GetTargetOptions().NumImpostors.ToString();

var firstButtonRenderer = __instance.ImpostorButtons[0];
firstButtonRenderer.enabled = false;
Expand Down Expand Up @@ -112,11 +120,11 @@ public static void Postfix(CreateOptionsPicker __instance)
[HarmonyPatch(typeof(CreateOptionsPicker), nameof(CreateOptionsPicker.UpdateMaxPlayersButtons))]
public static class CreateOptionsPicker_UpdateMaxPlayersButtons
{
public static bool Prefix(CreateOptionsPicker __instance, [HarmonyArgument(0)] GameOptionsData opts)
public static bool Prefix(CreateOptionsPicker __instance, [HarmonyArgument(0)] IGameOptions opts)
{
if (__instance.CrewArea)
{
__instance.CrewArea.SetCrewSize(opts.MaxPlayers, opts.numImpostors);
__instance.CrewArea.SetCrewSize(opts.MaxPlayers, opts.NumImpostors);
}

var selectedAsString = opts.MaxPlayers.ToString();
Expand All @@ -137,22 +145,5 @@ public static bool Prefix()
return false;
}
}

[HarmonyPatch(typeof(GameOptionsData), nameof(GameOptionsData.GameHostOptions), MethodType.Getter)]
public static class SaveManager_get_GameHostOptions
{
public static bool Prefix(out GameOptionsData __result)
{
GameOptionsData.hostOptionsData ??= GameOptionsData.LoadGameHostOptions();

// patched because of impostor clamping
GameOptionsData.hostOptionsData.NumImpostors =
Mathf.Clamp(GameOptionsData.hostOptionsData.NumImpostors, 1, GameOptionsData.hostOptionsData.MaxPlayers - 1);
GameOptionsData.hostOptionsData.KillDistance = Mathf.Clamp(GameOptionsData.hostOptionsData.KillDistance, 0, 2);

__result = GameOptionsData.hostOptionsData;
return false;
}
}
}
}
2 changes: 1 addition & 1 deletion src/CrowdedMod/Patches/GenericPatches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public static void Postfix(GameStartManager __instance)
{
if (fixDummyCounterColor != null)
{
__instance.PlayerCounter.text = $"{fixDummyCounterColor}{GameData.Instance.PlayerCount}/{PlayerControl.GameOptions.MaxPlayers}";
__instance.PlayerCounter.text = $"{fixDummyCounterColor}{GameData.Instance.PlayerCount}/{GameManager.Instance.LogicOptions.MaxPlayers}";
fixDummyCounterColor = null;
}
}
Expand Down

0 comments on commit 84168a9

Please sign in to comment.