Skip to content

Commit 91b872f

Browse files
committed
Updated for the latest version (2022.3.29)
1 parent c96f138 commit 91b872f

12 files changed

Lines changed: 168 additions & 340 deletions

src/CrowdedMod/CrowdedMod.csproj

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,29 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

3-
<PropertyGroup>
4-
<TargetFramework>netstandard2.1</TargetFramework>
5-
<Version>2.6.0</Version>
6-
<GameVersion>2021.5.10s</GameVersion>
7-
<Mappings>CrowdedMods/Mappings:0.5.0</Mappings>
3+
<PropertyGroup>
4+
<TargetFramework>netstandard2.1</TargetFramework>
5+
<Version>2.6.0</Version>
6+
<Authors>CrowdedMods, andry08</Authors>
7+
8+
<LangVersion>latest</LangVersion>
9+
<DebugType>embedded</DebugType>
10+
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
11+
<Nullable>enable</Nullable>
12+
</PropertyGroup>
13+
<PropertyGroup>
14+
<GamePlatform Condition="'$(GamePlatform)' == ''">Steam</GamePlatform>
15+
<GameVersion>2022.3.29</GameVersion>
16+
</PropertyGroup>
17+
<ItemGroup>
18+
<PackageReference Include="Reactor" Version="1.1.0" />
19+
<PackageReference Include="BepInEx.IL2CPP" Version="6.0.0-be.540" />
20+
<PackageReference Include="AmongUs.GameLibs.$(GamePlatform)" Version="$(GameVersion)" PrivateAssets="all" />
21+
22+
<PackageReference Include="BepInEx.AutoPlugin" Version="1.0.1" PrivateAssets="all" />
23+
<PackageReference Include="BepInEx.IL2CPP.MSBuild" Version="1.0.2" PrivateAssets="all" />
24+
</ItemGroup>
825

9-
<Authors>CrowdedMods, andry08</Authors>
10-
</PropertyGroup>
11-
<ItemGroup>
12-
<Deobfuscate Include="$(AmongUs)\BepInEx\plugins\Reactor-$(GameVersion).dll" />
13-
<PackageReference Include="Reactor.OxygenFilter.MSBuild" Version="0.3.0" />
14-
</ItemGroup>
15-
<ItemGroup>
16-
<None Remove="button.png" />
17-
</ItemGroup>
18-
<Target Name="Copy" AfterTargets="Reobfuscate">
19-
<Copy SourceFiles="$(OutputPath)reobfuscated/$(AssemblyName)-$(GameVersion).dll" DestinationFolder="$(AmongUs)/BepInEx/plugins/" Condition="'$(Configuration)' == 'Debug'" />
20-
</Target>
26+
<Target Name="Copy" AfterTargets="Build" Condition="'$(AmongUs)' != ''">
27+
<Copy SourceFiles="$(TargetPath)" DestinationFolder="$(AmongUs)/BepInEx/plugins/" UseSymboliclinksIfPossible="true" />
28+
</Target>
2129
</Project>

src/CrowdedMod/CrowdedModPlugin.cs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,30 @@
11
using System.Linq;
2+
using System.Reflection;
23
using BepInEx;
34
using BepInEx.IL2CPP;
45
using HarmonyLib;
56
using Reactor;
67

78
namespace CrowdedMod {
8-
[BepInPlugin(Id)]
9+
[BepInAutoPlugin]
910
[BepInProcess("Among Us.exe")]
1011
[BepInDependency(ReactorPlugin.Id)]
11-
public class CrowdedModPlugin : BasePlugin
12+
[BepInDependency("gg.reactor.debugger", BepInDependency.DependencyFlags.SoftDependency)] // fix debugger overwriting MinPlayers
13+
public partial class CrowdedModPlugin : BasePlugin
1214
{
13-
public const string Id = "pl.przebor.crowded";
14-
15-
public Harmony Harmony { get; } = new Harmony(Id);
15+
public Harmony Harmony { get; } = new (Id);
1616

1717
public override void Load()
1818
{
1919
GameOptionsData.RecommendedImpostors = GameOptionsData.MaxImpostors = Enumerable.Repeat(127, 127).ToArray();
2020
GameOptionsData.MinPlayers = Enumerable.Repeat(4, 127).ToArray();
21-
RegisterCustomRpcAttribute.Register(this);
22-
21+
2322
Harmony.PatchAll();
23+
#if DEBUG
24+
// Disable regionInfo watcher because it goes BRRR on multiple instances
25+
var stupidWatcher = typeof(ReactorPlugin).GetProperty("RegionInfoWatcher", BindingFlags.Instance | BindingFlags.NonPublic)?.GetValue(PluginSingleton<ReactorPlugin>.Instance);
26+
stupidWatcher!.GetType().GetMethod("Dispose")!.Invoke(stupidWatcher, new object[]{});
27+
#endif
2428
}
2529
}
2630
}

src/CrowdedMod/Extensions/MeetingHudExtensions.cs

Lines changed: 0 additions & 75 deletions
This file was deleted.

src/CrowdedMod/Net/CustomRpcCalls.cs

Lines changed: 0 additions & 8 deletions
This file was deleted.

src/CrowdedMod/Net/SetColorRpc.cs

Lines changed: 0 additions & 25 deletions
This file was deleted.

src/CrowdedMod/Net/VotingCompleteRpc.cs

Lines changed: 0 additions & 55 deletions
This file was deleted.

src/CrowdedMod/Patches/CreateGameOptionsPatches.cs

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,33 @@
1-
using System.Collections.Generic;
1+
using System;
22
using System.Linq;
33
using HarmonyLib;
44
using TMPro;
5+
using UnhollowerBaseLib;
56
using UnityEngine;
67
using UnityEngine.Events;
8+
using Object = UnityEngine.Object;
79

810
namespace CrowdedMod.Patches
911
{
1012
internal static class CreateGameOptionsPatches
1113
{
12-
[HarmonyPatch(typeof(CreateOptionsPicker), nameof(CreateOptionsPicker.Start))]
14+
[HarmonyPatch(typeof(CreateOptionsPicker), nameof(CreateOptionsPicker.Awake))]
1315
public static class CreateOptionsPicker_Start // Credits to XtraCube (mostly)
1416
{
1517
public const byte maxPlayers = 127;
1618

17-
public static void Postfix(CreateOptionsPicker __instance)
19+
public static unsafe void Postfix(CreateOptionsPicker __instance)
1820
{
1921
if (__instance.mode != SettingsMode.Host) return;
20-
var offset = __instance.MaxPlayerButtons[1].transform.position.x - __instance.MaxPlayerButtons[0].transform.position.x;
22+
23+
// thank you dnf and that person in BepInEx discord
24+
// ReSharper disable once CollectionNeverUpdated.Local
25+
var theHackyHackButtons = new Il2CppReferenceArray<SpriteRenderer>(*(IntPtr*)__instance.MaxPlayerButtons._items.Pointer);
26+
var offset = theHackyHackButtons[1].transform.position.x - theHackyHackButtons[0].transform.position.x;
2127

2228
#region MaxPlayers stuff
2329

24-
List<SpriteRenderer> playerButtons = __instance.MaxPlayerButtons.ToList();
30+
var playerButtons = __instance.MaxPlayerButtons.ToArray().ToList(); // cringe but works
2531

2632
SpriteRenderer plusButton = Object.Instantiate(playerButtons.Last(), playerButtons.Last().transform.parent);
2733
plusButton.GetComponentInChildren<TextMeshPro>().text = "+";
@@ -33,12 +39,12 @@ public static void Postfix(CreateOptionsPicker __instance)
3339

3440
void plusListener()
3541
{
36-
byte curHighest = byte.Parse(playerButtons[__instance.MaxPlayerButtons.Length - 2].name);
37-
int delta = Mathf.Clamp(curHighest + 7, curHighest, maxPlayers) - curHighest;
42+
byte curHighest = byte.Parse(playerButtons[__instance.MaxPlayerButtons.Count - 2].name);
43+
int delta = Mathf.Clamp(curHighest + 12, curHighest, maxPlayers) - curHighest;
3844
if (delta == 0) return; // fast skip
39-
for (byte i = 1; i < 8; i++)
45+
for (byte i = 1; i < 13; i++)
4046
{
41-
SpriteRenderer button = __instance.MaxPlayerButtons[i];
47+
SpriteRenderer button = theHackyHackButtons[i];
4248
button.name =
4349
button.GetComponentInChildren<TextMeshPro>().text =
4450
(byte.Parse(button.name) + delta).ToString();
@@ -57,11 +63,11 @@ void plusListener()
5763
void minusListener()
5864
{
5965
byte curLowest = byte.Parse(playerButtons[1].name);
60-
int delta = curLowest - Mathf.Clamp(curLowest - 7, 4, curLowest);
66+
int delta = curLowest - Mathf.Clamp(curLowest - 12, 4, curLowest);
6167
if (delta == 0) return; // fast skip
62-
for (byte i = 1; i < 8; i++)
68+
for (byte i = 1; i < 13; i++)
6369
{
64-
SpriteRenderer button = __instance.MaxPlayerButtons[i];
70+
SpriteRenderer button = theHackyHackButtons[i];
6571
button.name =
6672
button.GetComponentInChildren<TextMeshPro>().text =
6773
(byte.Parse(button.name) - delta).ToString();
@@ -90,7 +96,8 @@ void defaultListener()
9096

9197
playerButtons.Insert(0, minusButton);
9298
playerButtons.Add(plusButton);
93-
__instance.MaxPlayerButtons = playerButtons.ToArray();
99+
__instance.MaxPlayerButtons.Clear();
100+
playerButtons.ForEach(b => __instance.MaxPlayerButtons.Add(b));
94101

95102
#endregion
96103

0 commit comments

Comments
 (0)