Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to 2024.6.18 #55

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions src/CrowdedMod/Components/MeetingHudPagingBehaviour.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using Il2CppInterop.Runtime.Attributes;
using Reactor.Utilities.Attributes;
using System;
using System.Collections.Generic;
using System.Linq;
using Il2CppInterop.Runtime.Attributes;
using Reactor.Utilities.Attributes;
using UnityEngine;

namespace CrowdedMod.Components;
Expand Down Expand Up @@ -36,8 +36,10 @@ public override void OnPageChanged()
{
var i = 0;

foreach (var button in Targets) {
if (i >= PageIndex * MaxPerPage && i < (PageIndex + 1) * MaxPerPage) {
foreach (var button in Targets)
{
if (i >= PageIndex * MaxPerPage && i < (PageIndex + 1) * MaxPerPage)
{
button.gameObject.SetActive(true);

var relativeIndex = i % MaxPerPage;
Expand All @@ -50,7 +52,9 @@ public override void OnPageChanged()
meetingHud.VoteButtonOffsets.y * row,
buttonTransform.localPosition.z
);
} else {
}
else
{
button.gameObject.SetActive(false);
}
i++;
Expand Down
13 changes: 8 additions & 5 deletions src/CrowdedMod/Components/ShapeShifterPagingBehaviour.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System;
using Il2CppInterop.Runtime.Attributes;
using Reactor.Utilities.Attributes;
using System;
using System.Collections.Generic;
using System.Linq;
using Il2CppInterop.Runtime.Attributes;
using Reactor.Utilities.Attributes;
using TMPro;
using UnityEngine;

Expand Down Expand Up @@ -40,7 +40,8 @@ public override void OnPageChanged()

foreach (var panel in Targets)
{
if (i >= PageIndex * MaxPerPage && i < (PageIndex + 1) * MaxPerPage) {
if (i >= PageIndex * MaxPerPage && i < (PageIndex + 1) * MaxPerPage)
{
panel.gameObject.SetActive(true);

var relativeIndex = i % MaxPerPage;
Expand All @@ -52,7 +53,9 @@ public override void OnPageChanged()
shapeshifterMinigame.YStart + shapeshifterMinigame.YOffset * row,
buttonTransform.localPosition.z
);
} else {
}
else
{
panel.gameObject.SetActive(false);
}

Expand Down
6 changes: 3 additions & 3 deletions src/CrowdedMod/Components/VitalsPagingBehaviour.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
using Il2CppInterop.Runtime.Attributes;
using Reactor.Utilities.Attributes;
using System;
using System.Collections.Generic;
using System.Linq;
using Il2CppInterop.Runtime.Attributes;
using TMPro;
using Reactor.Utilities.Attributes;
using UnityEngine;

namespace CrowdedMod.Components;

[RegisterInIl2Cpp]
public class VitalsPagingBehaviour : AbstractPagingBehaviour
{
public VitalsPagingBehaviour(IntPtr ptr) : base(ptr) {}
public VitalsPagingBehaviour(IntPtr ptr) : base(ptr) { }

public VitalsMinigame vitalsMinigame = null!;

Expand Down
2 changes: 1 addition & 1 deletion src/CrowdedMod/CrowdedMod.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</PropertyGroup>
<PropertyGroup>
<GamePlatform Condition="'$(GamePlatform)' == ''">Steam</GamePlatform>
<GameVersion>2023.3.28</GameVersion>
<GameVersion>2024.6.18</GameVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Reactor" Version="2.1.0" />
Expand Down
10 changes: 5 additions & 5 deletions src/CrowdedMod/CrowdedModPlugin.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using System.Linq;
using AmongUs.GameOptions;
using AmongUs.GameOptions;
using BepInEx;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Reactor;
using Reactor.Networking;
using Reactor.Networking.Attributes;
using System.Linq;

namespace CrowdedMod;

Expand All @@ -19,12 +19,12 @@ public partial class CrowdedModPlugin : BasePlugin
public const int MaxPlayers = 127;
public const int MaxImpostors = 127 / 2;

private Harmony Harmony { get; } = new (Id);
private Harmony Harmony { get; } = new(Id);

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

Harmony.PatchAll();
}
Expand Down
2 changes: 1 addition & 1 deletion src/CrowdedMod/Net/SetColorRpc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using Reactor.Networking.Rpc;
namespace CrowdedMod.Net;

[RegisterCustomRpc((uint) CustomRpcCalls.SetColor)]
[RegisterCustomRpc((uint)CustomRpcCalls.SetColor)]
public class SetColorRpc : PlayerCustomRpc<CrowdedModPlugin, byte>
{
public SetColorRpc(CrowdedModPlugin plugin, uint id) : base(plugin, id)
Expand Down
13 changes: 8 additions & 5 deletions src/CrowdedMod/Patches/CreateGameOptionsPatches.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using AmongUs.GameOptions;
using AmongUs.GameOptions;
using HarmonyLib;
using Reactor.Utilities.Extensions;
using System;
using TMPro;
using UnityEngine;

Expand Down Expand Up @@ -98,7 +98,8 @@ public static void Postfix(CreateOptionsPicker __instance)

var firstPassiveButton = firstButton.PassiveButton;
firstPassiveButton.OnClick.RemoveAllListeners();
firstPassiveButton.OnClick.AddListener((Action)(() => {
firstPassiveButton.OnClick.AddListener((Action)(() =>
{
var newVal = Mathf.Clamp(
byte.Parse(secondButtonText.text) - 1,
1,
Expand All @@ -114,7 +115,8 @@ public static void Postfix(CreateOptionsPicker __instance)

var thirdPassiveButton = thirdButton.PassiveButton;
thirdPassiveButton.OnClick.RemoveAllListeners();
thirdPassiveButton.OnClick.AddListener((Action)(() => {
thirdPassiveButton.OnClick.AddListener((Action)(() =>
{
var newVal = Mathf.Clamp(
byte.Parse(secondButtonText.text) + 1,
1,
Expand Down Expand Up @@ -155,4 +157,5 @@ public static bool Prefix()
return false;
}
}
}
}

52 changes: 25 additions & 27 deletions src/CrowdedMod/Patches/GenericPatches.cs
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
using System.Linq;
using AmongUs.GameOptions;
using CrowdedMod.Net;
using HarmonyLib;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Reactor.Networking.Rpc;
using UnityEngine;
using System.Linq;

namespace CrowdedMod.Patches;

internal static class GenericPatches {
internal static class GenericPatches
{
[HarmonyPatch(typeof(PlayerControl), nameof(PlayerControl.CmdCheckColor))]
public static class PlayerControlCmdCheckColorPatch {
public static bool Prefix(PlayerControl __instance, [HarmonyArgument(0)] byte colorId) {
public static class PlayerControlCmdCheckColorPatch
{
public static bool Prefix(PlayerControl __instance, [HarmonyArgument(0)] byte colorId)
{
Rpc<SetColorRpc>.Instance.Send(__instance, colorId);
return false;
}
}

[HarmonyPatch(typeof(PlayerTab), nameof(PlayerTab.Update))]
public static class PlayerTabIsSelectedItemEquippedPatch {
public static class PlayerTabIsSelectedItemEquippedPatch
{
public static void Postfix(PlayerTab __instance)
{
__instance.currentColorIsEquipped = false;
Expand All @@ -33,7 +35,7 @@ public static bool Prefix(PlayerTab __instance)
__instance.AvailableColors.Clear();
for (var i = 0; i < Palette.PlayerColors.Count; i++)
{
if(!PlayerControl.LocalPlayer || PlayerControl.LocalPlayer.CurrentOutfit.ColorId != i)
if (!PlayerControl.LocalPlayer || PlayerControl.LocalPlayer.CurrentOutfit.ColorId != i)
{
__instance.AvailableColors.Add(i);
}
Expand Down Expand Up @@ -72,7 +74,8 @@ public static void Prefix(GameStartManager __instance)
if (__instance.LastPlayerCount > __instance.MinPlayers)
{
fixDummyCounterColor = "<color=#00FF00FF>";
} else if (__instance.LastPlayerCount == __instance.MinPlayers)
}
else if (__instance.LastPlayerCount == __instance.MinPlayers)
{
fixDummyCounterColor = "<color=#FFFF00FF>";
}
Expand All @@ -88,7 +91,7 @@ public static void Postfix(GameStartManager __instance)
{
return;
}

__instance.PlayerCounter.text = $"{fixDummyCounterColor}{GameData.Instance.PlayerCount}/{GameManager.Instance.LogicOptions.MaxPlayers}";
fixDummyCounterColor = null;
}
Expand All @@ -103,15 +106,6 @@ public static void Postfix(PingTracker __instance)
}
}

[HarmonyPatch(typeof(GameSettingMenu), nameof(GameSettingMenu.OnEnable))]
public static class GameSettingMenu_OnEnable // Credits to https://github.com/Galster-dev/GameSettingsUnlocker
{
public static void Prefix(ref GameSettingMenu __instance)
{
__instance.HideForOnline = new Il2CppReferenceArray<Transform>(0);
}
}

// Will be patched with signatures later when BepInEx reveals it
// [HarmonyPatch(typeof(InnerNetServer), nameof(InnerNetServer.HandleNewGameJoin))]
// public static class InnerNetSerer_HandleNewGameJoin
Expand Down Expand Up @@ -159,15 +153,19 @@ public static void Prefix(ref GameSettingMenu __instance)
// }
// }

[HarmonyPatch(typeof(GameOptionsMenu), nameof(GameOptionsMenu.Start))]
public static class GameOptionsMenu_Start
[HarmonyPatch(typeof(GameOptionsMenu), nameof(GameOptionsMenu.Initialize))]
public static class GameOptionsMenu_Initialize
{
public static void Postfix(ref GameOptionsMenu __instance)
public static void Postfix(GameOptionsMenu __instance)
{
__instance.GetComponentsInChildren<NumberOption>()
.First(o => o.Title == StringNames.GameNumImpostors)
// ReSharper disable once PossibleLossOfFraction
.ValidRange = new FloatRange(1, CrowdedModPlugin.MaxImpostors);
var numberOptions = __instance.GetComponentsInChildren<NumberOption>();

var impostorsOption = numberOptions.FirstOrDefault(o => o.Title == StringNames.GameNumImpostors);
if (impostorsOption != null)
{
impostorsOption.ValidRange = new FloatRange(1, CrowdedModPlugin.MaxImpostors);
}

}
}
}
}
4 changes: 2 additions & 2 deletions src/CrowdedMod/Patches/PagingPatches.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using HarmonyLib;
using CrowdedMod.Components;
using CrowdedMod.Components;
using HarmonyLib;

namespace CrowdedMod.Patches;

Expand Down
Loading