This commit is contained in:
D1GQ committed 2025-10-19 07:43:37 -05:00
1 parent 287c6d4c2d
commit 653a6f383f
8 files changed
+124 -98

No files matched your search

-75
View File
@@ -331,79 +331,4 @@ internal class ClientPatch
}
}
}
// Set text color
[HarmonyPatch(typeof(CosmeticsLayer))]
internal class CosmeticsLayerPatch
{
[HarmonyPatch(nameof(CosmeticsLayer.GetColorBlindText))]
[HarmonyPrefix]
internal static bool GetColorBlindText_Prefix(CosmeticsLayer __instance, ref string __result)
{
if (__instance.bodyMatProperties.ColorId > Palette.PlayerColors.Length) return true;
string colorName = Palette.GetColorName(__instance.bodyMatProperties.ColorId);
if (!string.IsNullOrEmpty(colorName))
{
__result = (char.ToUpperInvariant(colorName[0]) + colorName.Substring(1).ToLowerInvariant()).ToColor(Palette.PlayerColors[__instance.bodyMatProperties.ColorId]);
}
else
{
__result = string.Empty;
}
return false;
}
}
// Clean up menu
[HarmonyPatch(typeof(RegionMenu))]
internal class RegionMenuPatch
{
[HarmonyPatch(nameof(RegionMenu.OnEnable))]
[HarmonyPostfix]
internal static void AdjustButtonPositions_Postfix(RegionMenu __instance)
{
const int maxColumns = 4;
int buttonsPerColumn = 6;
float buttonSpacing = 0.6f;
float buttonSpacingSide = 2.25f;
List<UiElement> buttons = __instance.controllerSelectable.ToArray().ToList();
int columnCount = (buttons.Count + buttonsPerColumn - 1) / buttonsPerColumn;
while (columnCount > maxColumns)
{
buttonsPerColumn++;
columnCount = (buttons.Count + buttonsPerColumn - 1) / buttonsPerColumn;
}
float totalWidth = (columnCount - 1) * buttonSpacingSide;
float totalHeight = (buttonsPerColumn - 1) * buttonSpacing;
Vector3 startPosition = new Vector3(-totalWidth / 2, totalHeight / 2, 0f);
for (int i = 0; i < buttons.Count; i++)
{
int col = i / buttonsPerColumn;
int row = i % buttonsPerColumn;
buttons[i].transform.localPosition = startPosition + new Vector3(col * buttonSpacingSide, -row * buttonSpacing, 0f);
}
}
}
// fix report name on anti cheat ban
[HarmonyPatch(typeof(ReportReasonScreen))]
class ReportReasonScreenPatch
{
[HarmonyPatch(nameof(ReportReasonScreen.Show))]
[HarmonyPrefix]
internal static void Show_Prefix(ref string playerName)
{
if (Utils.IsHtmlText(playerName))
{
string extractedText = playerName.Split(new[] { "<color=#ffea00>", "</color>" }, StringSplitOptions.None)[1];
playerName = extractedText;
}
}
}
}
@@ -0,0 +1,29 @@
using BetterAmongUs.Helpers;
using HarmonyLib;
namespace BetterAmongUs.Patches.Gameplay.Player;
// Set text color
[HarmonyPatch(typeof(CosmeticsLayer))]
internal class CosmeticsLayerPatch
{
[HarmonyPatch(nameof(CosmeticsLayer.GetColorBlindText))]
[HarmonyPrefix]
internal static bool GetColorBlindText_Prefix(CosmeticsLayer __instance, ref string __result)
{
if (__instance.bodyMatProperties.ColorId > Palette.PlayerColors.Length) return true;
string colorName = Palette.GetColorName(__instance.bodyMatProperties.ColorId);
if (!string.IsNullOrEmpty(colorName))
{
__result = (char.ToUpperInvariant(colorName[0]) + colorName.Substring(1).ToLowerInvariant()).ToColor(Palette.PlayerColors[__instance.bodyMatProperties.ColorId]);
}
else
{
__result = string.Empty;
}
return false;
}
}
@@ -3,7 +3,7 @@ using BetterAmongUs.Managers;
using BetterAmongUs.Modules;
using HarmonyLib;
namespace BetterAmongUs.Patches.Gameplay;
namespace BetterAmongUs.Patches.Gameplay.Systems;
[HarmonyPatch(typeof(VoteBanSystem))]
internal static class VoteBanSystemPatch
+40
View File
@@ -0,0 +1,40 @@
using HarmonyLib;
using UnityEngine;
namespace BetterAmongUs.Patches.Gameplay.UI;
[HarmonyPatch(typeof(RegionMenu))]
internal class RegionMenuPatch
{
[HarmonyPatch(nameof(RegionMenu.OnEnable))]
[HarmonyPostfix]
internal static void AdjustButtonPositions_Postfix(RegionMenu __instance)
{
const int maxColumns = 4;
int buttonsPerColumn = 6;
float buttonSpacing = 0.6f;
float buttonSpacingSide = 2.25f;
List<UiElement> buttons = __instance.controllerSelectable.ToArray().ToList();
int columnCount = (buttons.Count + buttonsPerColumn - 1) / buttonsPerColumn;
while (columnCount > maxColumns)
{
buttonsPerColumn++;
columnCount = (buttons.Count + buttonsPerColumn - 1) / buttonsPerColumn;
}
float totalWidth = (columnCount - 1) * buttonSpacingSide;
float totalHeight = (buttonsPerColumn - 1) * buttonSpacing;
Vector3 startPosition = new Vector3(-totalWidth / 2, totalHeight / 2, 0f);
for (int i = 0; i < buttons.Count; i++)
{
int col = i / buttonsPerColumn;
int row = i % buttonsPerColumn;
buttons[i].transform.localPosition = startPosition + new Vector3(col * buttonSpacingSide, -row * buttonSpacing, 0f);
}
}
}
@@ -0,0 +1,19 @@
using BetterAmongUs.Helpers;
using HarmonyLib;
namespace BetterAmongUs.Patches.Gameplay.UI;
[HarmonyPatch(typeof(ReportReasonScreen))]
class ReportReasonScreenPatch
{
[HarmonyPatch(nameof(ReportReasonScreen.Show))]
[HarmonyPrefix]
internal static void Show_Prefix(ref string playerName)
{
if (Utils.IsHtmlText(playerName))
{
string extractedText = playerName.Split(["<color=#ffea00>", "</color>"], StringSplitOptions.None)[1];
playerName = extractedText;
}
}
}
@@ -10,30 +10,30 @@ namespace BetterAmongUs.Patches.Gameplay.UI.Settings;
class BetterGameSettings
{
internal static OptionItem? WhenCheating;
internal static OptionItem? InvalidFriendCode;
internal static OptionItem? UseBanPlayerList;
internal static OptionItem? UseBanNameList;
internal static OptionItem? UseBanWordList;
internal static OptionItem? UseBanWordListOnlyLobby;
internal static OptionItem? HideAndSeekImpNum;
internal static OptionItem? DetectedLevelAbove;
internal static OptionItem? DetectCheatClients;
internal static OptionItem? DetectInvalidRPCs;
internal static OptionItem? RoleRandomizer;
internal static OptionItem? DesyncRoles;
internal static OptionItem? CancelInvalidSabotage;
internal static OptionItem? CensorDetectionReason;
internal static OptionItem? RemovePetOnDeath;
internal static OptionItem? DisableSabotages;
internal static OptionStringItem? WhenCheating;
internal static OptionCheckboxItem? InvalidFriendCode;
internal static OptionCheckboxItem? UseBanPlayerList;
internal static OptionCheckboxItem? UseBanNameList;
internal static OptionCheckboxItem? UseBanWordList;
internal static OptionCheckboxItem? UseBanWordListOnlyLobby;
internal static OptionIntItem? HideAndSeekImpNum;
internal static OptionIntItem? DetectedLevelAbove;
internal static OptionCheckboxItem? DetectCheatClients;
internal static OptionCheckboxItem? DetectInvalidRPCs;
internal static OptionStringItem? RoleRandomizer;
internal static OptionCheckboxItem? DesyncRoles;
internal static OptionCheckboxItem? CancelInvalidSabotage;
internal static OptionCheckboxItem? CensorDetectionReason;
internal static OptionCheckboxItem? RemovePetOnDeath;
internal static OptionCheckboxItem? DisableSabotages;
}
class BetterGameSettingsTemp
{
internal static OptionItem? HideAndSeekImp2;
internal static OptionItem? HideAndSeekImp3;
internal static OptionItem? HideAndSeekImp4;
internal static OptionItem? HideAndSeekImp5;
internal static OptionPlayerItem? HideAndSeekImp2;
internal static OptionPlayerItem? HideAndSeekImp3;
internal static OptionPlayerItem? HideAndSeekImp4;
internal static OptionPlayerItem? HideAndSeekImp5;
}
[HarmonyPatch(typeof(GameSettingMenu))]
@@ -102,13 +102,25 @@ static class GameSettingMenuPatch
BetterGameSettings.HideAndSeekImpNum = OptionIntItem.Create(1000, BetterSettingsTab, "BetterSetting.Setting.HideAndSeekImpNum", (1, 5, 1), 1);
BetterGameSettingsTemp.HideAndSeekImp2 = OptionPlayerItem.Create(0, BetterSettingsTab, "BetterSetting.TempSetting.HideAndSeekImpNum", BetterGameSettings.HideAndSeekImpNum);
BetterGameSettingsTemp.HideAndSeekImp2.ShowCondition = () => BetterGameSettings.HideAndSeekImpNum.GetValue() >= 2;
BetterGameSettingsTemp.HideAndSeekImp3 = OptionPlayerItem.Create(1, BetterSettingsTab, "BetterSetting.TempSetting.HideAndSeekImpNum", BetterGameSettings.HideAndSeekImpNum);
BetterGameSettingsTemp.HideAndSeekImp3.ShowCondition = () => BetterGameSettings.HideAndSeekImpNum.GetValue() >= 3 &&
BetterGameSettingsTemp.HideAndSeekImp2.GetValue() != -1;
BetterGameSettingsTemp.HideAndSeekImp4 = OptionPlayerItem.Create(2, BetterSettingsTab, "BetterSetting.TempSetting.HideAndSeekImpNum", BetterGameSettings.HideAndSeekImpNum);
BetterGameSettingsTemp.HideAndSeekImp4.ShowCondition = () => BetterGameSettings.HideAndSeekImpNum.GetValue() >= 4 &&
BetterGameSettingsTemp.HideAndSeekImp2.GetValue() != -1 &&
BetterGameSettingsTemp.HideAndSeekImp3.GetValue() != -1;
BetterGameSettingsTemp.HideAndSeekImp5 = OptionPlayerItem.Create(3, BetterSettingsTab, "BetterSetting.TempSetting.HideAndSeekImpNum", BetterGameSettings.HideAndSeekImpNum);
BetterGameSettingsTemp.HideAndSeekImp5.ShowCondition = () => BetterGameSettings.HideAndSeekImpNum.GetValue() >= 5 &&
BetterGameSettingsTemp.HideAndSeekImp2.GetValue() != -1 &&
BetterGameSettingsTemp.HideAndSeekImp3.GetValue() != -1 &&
BetterGameSettingsTemp.HideAndSeekImp4.GetValue() != -1;
}
}
}
BetterSettingsTab.UpdateVisuals();
/*
new BetterOptionCheckboxItem().Create(10000, BetterSettingsTab, "CheckBox Test", true);
new BetterOptionStringItem().Create(10001, BetterSettingsTab, "String Test", ["Test 1", "Test 2", "Test 3"], 0);
+1
View File
@@ -126,6 +126,7 @@ class GamePlayManager
Logger.LogHeader($"Game Has Started - {Enum.GetName(typeof(MapNames), GameState.GetActiveMapId)}/{GameState.GetActiveMapId}", "GamePlayManager");
}
}
[HarmonyPatch(typeof(EndGameManager))]
internal class EndGameManagerPatch
{
+2 -2
View File
@@ -144,7 +144,7 @@ internal class RoleManagerPatch
// Desync role to other clients to prevent revealing the true role
if (BetterGameSettings.DesyncRoles.GetBool())
{
if (IsImpostorRole(role) && role is not RoleTypes.Phantom)
if (IsImpostorRole(role) && role is not RoleTypes.Phantom or RoleTypes.Viper)
{
List<MessageWriter> messageWriter = AmongUsClient.Instance.StartRpcDesync(player.NetId, (byte)RpcCalls.SetRole, SendOption.None, player.GetClientId(), clientCheck);
messageWriter.ForEach(mW => mW.Write((ushort)RoleTypes.Impostor));
@@ -201,7 +201,7 @@ internal class RoleManagerPatch
// Desync role to other clients to prevent revealing the true role
if (BetterGameSettings.DesyncRoles.GetBool())
{
if (kvp.Key is not RoleTypes.Phantom)
if (kvp.Key is not RoleTypes.Phantom or RoleTypes.Viper)
{
List<MessageWriter> messageWriter = AmongUsClient.Instance.StartRpcDesync(pc.NetId, (byte)RpcCalls.SetRole, SendOption.None, pc.GetClientId(), clientCheck);
messageWriter.ForEach(mW => mW.Write((ushort)RoleTypes.Impostor));