diff --git a/Modules/AntiCheat.cs b/Modules/AntiCheat.cs
index b05d097..f7c2436 100644
--- a/Modules/AntiCheat.cs
+++ b/Modules/AntiCheat.cs
@@ -1,10 +1,8 @@
using AmongUs.GameOptions;
+using BetterAmongUs.Patches;
using HarmonyLib;
using Hazel;
using InnerNet;
-using UnityEngine;
-using UnityEngine.Purchasing;
-using UnityEngine.Rendering;
namespace BetterAmongUs;
@@ -27,15 +25,15 @@ class AntiCheat
if (SickoData.ContainsKey(hashPuid))
{
- player.Kick(true, $"banned by Anti-Cheat!\n Reason: Known Sicko Menu User", true);
+ player.Kick(true, "{0} by Anti-Cheat!\n Reason: Known Sicko Menu User", true);
}
else if (AUMData.ContainsKey(hashPuid))
{
- player.Kick(true, $"banned by Anti-Cheat!\n Reason: Known AUM User", true);
+ player.Kick(true, "{0} by Anti-Cheat!\n Reason: Known AUM User", true);
}
else if (PlayerData.ContainsKey(hashPuid))
{
- player.Kick(true, $"banned by Anti-Cheat!\n Reason: Known Cheater", true);
+ player.Kick(true, "{0} by Anti-Cheat!\n Reason: Known Cheater", true);
}
}
}
@@ -104,7 +102,7 @@ class AntiCheat
if (player == PlayerControl.LocalPlayer || PlayerControl.LocalPlayer == null || player == null || !IsEnabled) return;
- if (callId is unchecked((byte)CustomRPC.Sicko) && Main.AntiCheat.Value)
+ if (callId is unchecked((byte)CustomRPC.Sicko) && Main.AntiCheat.Value && BetterGameSettings.DetectCheatClients.GetBool())
{
if (reader.BytesRemaining == 0)
{
@@ -122,7 +120,7 @@ class AntiCheat
return;
}
- if (callId is unchecked((byte)CustomRPC.AUM) && Main.AntiCheat.Value)
+ if (callId is unchecked((byte)CustomRPC.AUM) && Main.AntiCheat.Value && BetterGameSettings.DetectCheatClients.GetBool())
{
try
{
@@ -158,7 +156,7 @@ class AntiCheat
PlayerControl AUMPlayer = Main.AllPlayerControls.First(pc => pc.Data.PlayerName == nameString && pc.CurrentOutfit.ColorId == colorId);
- if (AUMPlayer == null || !Main.AntiCheat.Value) return;
+ if (AUMPlayer == null || !Main.AntiCheat.Value || !BetterGameSettings.DetectCheatClients.GetBool()) return;
var flag = string.IsNullOrEmpty(nameString) && string.IsNullOrEmpty(msgString);
var flag2 = AUMData.ContainsKey(Utils.GetHashPuid(AUMPlayer));
@@ -185,7 +183,7 @@ class AntiCheat
MessageReader reader = MessageReader.Get(Oldreader);
if (PlayerControl.LocalPlayer == null || player == null || player == PlayerControl.LocalPlayer || player.BetterData().IsBetterHost || reader == null || !IsEnabled || !Main.AntiCheat.Value
- || GameStates.IsBetterHostLobby && !GameStates.IsHost) return;
+ || (GameStates.IsBetterHostLobby && !GameStates.IsHost) || !BetterGameSettings.DetectInvalidRPCs.GetBool()) return;
RoleTypes? Role = player?.Data?.RoleType;
Role ??= RoleTypes.Crewmate;
@@ -230,14 +228,6 @@ class AntiCheat
{
PlayerControl target = reader.ReadNetObject();
- if (GameStates.IsHost)
- {
- BetterNotificationManager.NotifyCheat(player, $"Invalid Action RPC: {Enum.GetName((RpcCalls)callId)}");
- Logger.LogCheat($"{player.BetterData().RealName} {Enum.GetName((RpcCalls)callId)}: {GameStates.IsHost}");
-
- return;
- }
-
if (target != null)
{
if (!player.IsImpostorTeam() || !player.IsAlive() || player.IsInVanish() || target.IsImpostorTeam())
@@ -257,7 +247,7 @@ class AntiCheat
if (reader.BytesRemaining > 0)
{
uint level = reader.ReadPackedUInt32();
- if (level >= 200)
+ if (level >= BetterGameSettings.DetectedLevelAbove.GetInt())
{
BetterNotificationManager.NotifyCheat(player, $"Invalid Level: {level}");
Logger.LogCheat($"{player.BetterData().RealName} {Enum.GetName((RpcCalls)callId)}: {level >= 200}");
@@ -332,12 +322,6 @@ class AntiCheat
// Check game states when sabotaging
public static bool RpcUpdateSystemCheck(PlayerControl player, SystemTypes systemType, byte amount)
{
- if (!GameStates.IsHost || PlayerControl.LocalPlayer == null || player == null || player == PlayerControl.LocalPlayer || player.BetterData().IsBetterHost || !IsEnabled || !Main.AntiCheat.Value
- || GameStates.IsBetterHostLobby && !GameStates.IsHost) return true;
-
- // Needs fixing!
- return true;
-
byte hostNum = 128; // Only host should ever send this number
byte singleFixNum = 0;
byte minLightNum = 0;
@@ -368,9 +352,11 @@ class AntiCheat
}
}
- if (!GameStates.IsHost || PlayerControl.LocalPlayer == null || player == null || player == PlayerControl.LocalPlayer
- || player.BetterData().IsBetterHost || !IsEnabled || !Main.AntiCheat.Value
- || GameStates.IsBetterHostLobby && !GameStates.IsHost) return true;
+ if (!GameStates.IsHost || PlayerControl.LocalPlayer == null || player == null || player == PlayerControl.LocalPlayer || player.BetterData().IsBetterHost || !IsEnabled || !Main.AntiCheat.Value
+ || (GameStates.IsBetterHostLobby && !GameStates.IsHost) || !BetterGameSettings.DetectInvalidRPCs.GetBool()) return true;
+
+ if (!BetterGameSettings.ExperimentalDetectInvalidSabotage.GetBool())
+ return true;
// Single Fix: 0
// Lights: 0-1-2-3-4
@@ -507,7 +493,7 @@ class AntiCheat
}
}
- if (!IsEnabled || !Main.AntiCheat.Value || GameStates.IsBetterHostLobby && !GameStates.IsHost) return true;
+ if (!IsEnabled || !Main.AntiCheat.Value || (GameStates.IsBetterHostLobby && !GameStates.IsHost) || !BetterGameSettings.DetectInvalidRPCs.GetBool()) return true;
RoleTypes Role = player.Data.RoleType;
bool IsImpostor = player.IsImpostorTeam();
diff --git a/Modules/BetterDataManager.cs b/Modules/BetterDataManager.cs
index 63506eb..93418c6 100644
--- a/Modules/BetterDataManager.cs
+++ b/Modules/BetterDataManager.cs
@@ -1,4 +1,5 @@
-using System.Text.Json;
+using BetterAmongUs.Patches;
+using System.Text.Json;
namespace BetterAmongUs;
@@ -7,6 +8,8 @@ class BetterDataManager
private static string filePath = GetFilePath("BetterData");
public static string filePathFolder = Path.Combine(Main.GetGamePathToAmongUs(), $"Better_Data");
public static string filePathFolderSaveInfo = Path.Combine(filePathFolder, $"SaveInfo");
+ public static string filePathFolderSettings = Path.Combine(filePathFolder, $"Settings");
+ public static string SettingsFile = Path.Combine(filePathFolderSettings, "Preset.json");
public static string banPlayerListFile = Path.Combine(filePathFolderSaveInfo, "BanPlayerList.txt");
public static string banNameListFile = Path.Combine(filePathFolderSaveInfo, "BanNameList.txt");
public static string banWordListFile = Path.Combine(filePathFolderSaveInfo, "BanWordList.txt");
@@ -23,6 +26,11 @@ class BetterDataManager
Directory.CreateDirectory(filePathFolder);
}
+ if (!Directory.Exists(filePathFolderSettings))
+ {
+ Directory.CreateDirectory(filePathFolderSettings);
+ }
+
if (!Directory.Exists(filePathFolderSaveInfo))
{
Directory.CreateDirectory(filePathFolderSaveInfo);
@@ -43,6 +51,15 @@ class BetterDataManager
File.WriteAllText(banWordListFile, "// Example\nStart");
}
+ if (!File.Exists(SettingsFile))
+ {
+ var initialData = new Dictionary();
+ string json = JsonSerializer.Serialize(initialData, new JsonSerializerOptions { WriteIndented = true });
+ File.WriteAllText(SettingsFile, json);
+ }
+
+ GameSettingMenuPatch.SetupSettings(true);
+
if (!File.Exists(filePath))
{
// Initialize with predefined categories
@@ -127,6 +144,77 @@ class BetterDataManager
return string.Empty;
}
+ public static void SaveSetting(int id, string input)
+ {
+ string filePath = SettingsFile;
+
+ string json = File.ReadAllText(filePath);
+ var jsonData = JsonSerializer.Deserialize>(json) ?? new Dictionary();
+ jsonData[id.ToString()] = input;
+
+ json = JsonSerializer.Serialize(jsonData, new JsonSerializerOptions { WriteIndented = true });
+ File.WriteAllText(filePath, json);
+ }
+
+ public static bool CanLoadSetting(int id)
+ {
+ string filePath = SettingsFile;
+ string json = File.ReadAllText(filePath);
+ var jsonData = JsonSerializer.Deserialize>(json) ?? new Dictionary();
+
+ if (jsonData.ContainsKey(id.ToString()))
+ {
+ if (!string.IsNullOrEmpty(jsonData[id.ToString()]))
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ public static bool LoadBoolSetting(int id)
+ {
+ string filePath = SettingsFile;
+ string json = File.ReadAllText(filePath);
+ var jsonData = JsonSerializer.Deserialize>(json) ?? new Dictionary();
+
+ if (jsonData.ContainsKey(id.ToString()))
+ {
+ return bool.Parse(jsonData[id.ToString()]);
+ }
+
+ return false;
+ }
+
+ public static float LoadFloatSetting(int id)
+ {
+ string filePath = SettingsFile;
+ string json = File.ReadAllText(filePath);
+ var jsonData = JsonSerializer.Deserialize>(json) ?? new Dictionary();
+
+ if (jsonData.ContainsKey(id.ToString()))
+ {
+ return float.Parse(jsonData[id.ToString()]);
+ }
+
+ return -1f;
+ }
+
+ public static int LoadIntSetting(int id)
+ {
+ string filePath = SettingsFile;
+ string json = File.ReadAllText(filePath);
+ var jsonData = JsonSerializer.Deserialize>(json) ?? new Dictionary();
+
+ if (jsonData.ContainsKey(id.ToString()))
+ {
+ return int.Parse(jsonData[id.ToString()]);
+ }
+
+ return -1;
+ }
+
public static void SaveBanList(string friendCode = "", string hashPUID = "")
{
if (!string.IsNullOrEmpty(friendCode) || !string.IsNullOrEmpty(hashPUID))
@@ -157,7 +245,6 @@ class BetterDataManager
}
}
-
public static void SaveCheatData(string puid, string friendCode, string name, string category = "cheatData", string reason = "None")
{
string filePath = GetFilePath("BetterData");
diff --git a/Modules/BetterNotificationManager.cs b/Modules/BetterNotificationManager.cs
index 5a20c92..5dfc5f6 100644
--- a/Modules/BetterNotificationManager.cs
+++ b/Modules/BetterNotificationManager.cs
@@ -17,7 +17,7 @@ class BetterNotificationManager
if (BAUNotificationManagerObj != null)
{
- if (Notifying)
+ if (Notifying)
{
if (text == BAUNotificationManagerObj.transform.Find("Sizer/ChatText (TMP)").GetComponent().text)
return;
@@ -50,7 +50,7 @@ class BetterNotificationManager
if (GameStates.IsHost && kickPlayer)
{
- player.Kick(true, $"banned by Anti-Cheat!\n Reason: {reason}", true);
+ player.Kick(true, "{0} " + $"by Anti-Cheat!\n Reason: {reason}", true);
}
}
diff --git a/Modules/ClientOptionItem.cs b/Modules/ClientOptionItem.cs
index 52a1826..a64692e 100644
--- a/Modules/ClientOptionItem.cs
+++ b/Modules/ClientOptionItem.cs
@@ -84,8 +84,8 @@ public class ClientOptionItem
// ボタン生成
ToggleButton = Object.Instantiate(mouseMoveToggle, CustomBackground.transform);
- ToggleButton.transform.localPosition = new Vector3(
- // 現在のオプション数を基に位置を計算
+ ToggleButton.transform.localPosition = new Vector3(
+ // 現在のオプション数を基に位置を計算
numOptions % 2 == 0 ? -1.3f : 1.3f,
2.2f - (0.5f * (numOptions / 2)),
-6f);
diff --git a/Modules/ExtendedPlayerControl.cs b/Modules/ExtendedPlayerControl.cs
index 7ed2ece..312eee7 100644
--- a/Modules/ExtendedPlayerControl.cs
+++ b/Modules/ExtendedPlayerControl.cs
@@ -35,7 +35,7 @@ static class ExtendedPlayerControl
try
{
- return $"{player.Data.PlayerName}";
+ return $"{player.Data.PlayerName}";
}
catch
{
@@ -108,14 +108,24 @@ static class ExtendedPlayerControl
return;
}
+ if (AntiCheatBan)
+ {
+ if (BetterGameSettings.WhenCheating.GetValue() == 0)
+ {
+ return;
+ }
+
+ ban = ban && BetterGameSettings.WhenCheating.GetValue() == 2;
+ }
+
if (setReasonInfo != "")
{
- GameDataShowNotificationPatch.BetterShowNotification(player.Data, forceReasonText: setReasonInfo);
+ GameDataShowNotificationPatch.BetterShowNotification(player.Data, forceReasonText: string.Format(setReasonInfo, ban ? "banned" : "kicked"));
}
AmongUsClient.Instance.KickPlayer(player.GetClientId(), ban);
- player.BetterData().BannedByAntiCheat = AntiCheatBan && ban;
+ player.BetterData().BannedByAntiCheat = AntiCheatBan;
}
// RPCs
diff --git a/Modules/ExtendedPlayerInfo.cs b/Modules/ExtendedPlayerInfo.cs
index de66476..0864588 100644
--- a/Modules/ExtendedPlayerInfo.cs
+++ b/Modules/ExtendedPlayerInfo.cs
@@ -9,7 +9,7 @@ public static class PlayerControlDataExtension
public class ExtendedPlayerInfo
{
public NetworkedPlayerInfo? _Data { get; set; }
- public string RealName { get; set; } = string.Empty;
+ public string? RealName { get; set; }
public Dictionary LastNameSetFor { get; set; } = [];
public bool IsBetterUser { get; set; } = false;
public bool IsBetterHost { get; set; } = false;
@@ -58,6 +58,11 @@ public static class PlayerControlDataExtension
if (player.IsAlive() || player.Data.RoleType == RoleTypes.GuardianAngel)
player.BetterData().RoleInfo.DeadDisplayRole = player.Data.RoleType;
}
+
+ if (string.IsNullOrEmpty(player.BetterData().RealName))
+ {
+ player.BetterData().RealName = player.Data.PlayerName;
+ }
}
// Get BetterData from PlayerControl
@@ -104,6 +109,7 @@ public static class PlayerControlDataExtension
playerInfo[player.Data.Puid] = new ExtendedPlayerInfo
{
_Data = player.Data,
+ RealName = player.Data.PlayerName,
RoleInfo = new ExtendedRoleInfo()
};
}
diff --git a/Modules/FileChecker.cs b/Modules/FileChecker.cs
index 550263a..7ab5ce7 100644
--- a/Modules/FileChecker.cs
+++ b/Modules/FileChecker.cs
@@ -19,13 +19,13 @@ class FileChecker
// Set up if unauthorized files have been found.
public static void UpdateUnauthorizedFiles()
{
- if (Enabled == false) return;
-
if (GameStates.IsDev)
{
HasTrySpoofFriendCode = false;
}
+ if (Enabled == false) return;
+
GameObject PlayButton = GameObject.Find("Main Buttons/PlayButton");
// Disable play button
diff --git a/Modules/GameState.cs b/Modules/GameState.cs
index d2e21d3..a96c642 100644
--- a/Modules/GameState.cs
+++ b/Modules/GameState.cs
@@ -10,7 +10,7 @@ public static class GameStates
public static bool IsDev => EOSManager.Instance?.userId != null && Main.DevUser.Contains($"{Utils.GetHashPuid(EOSManager.Instance.userId.ToString())}+{EOSManager.Instance.friendCode}");
public static bool InGame => Main.AllPlayerControls.Any();
public static bool IsNormalGame => GameOptionsManager.Instance.CurrentGameOptions.GameMode is GameModes.Normal or GameModes.NormalFools;
- public static bool IsHideNSeek => GameOptionsManager.Instance.CurrentGameOptions.GameMode is GameModes.HideNSeek or GameModes.SeekFools;
+ public static bool IsHideNSeek => GameOptionsManager.Instance != null && GameOptionsManager.Instance.CurrentGameOptions.GameMode is GameModes.HideNSeek or GameModes.SeekFools;
public static bool SkeldIsActive => (MapNames)GameOptionsManager.Instance.CurrentGameOptions.MapId == MapNames.Skeld;
public static bool MiraHQIsActive => (MapNames)GameOptionsManager.Instance.CurrentGameOptions.MapId == MapNames.Mira;
public static bool PolusIsActive => (MapNames)GameOptionsManager.Instance.CurrentGameOptions.MapId == MapNames.Polus;
diff --git a/Modules/OptionItems/BetterOptionCheckboxItem.cs b/Modules/OptionItems/BetterOptionCheckboxItem.cs
new file mode 100644
index 0000000..c638ed2
--- /dev/null
+++ b/Modules/OptionItems/BetterOptionCheckboxItem.cs
@@ -0,0 +1,83 @@
+using UnityEngine;
+
+namespace BetterAmongUs;
+
+public class BetterOptionCheckboxItem : BetterOptionItem
+{
+ private ToggleOption? ThisOption;
+ private bool? IsChecked;
+
+ public BetterOptionItem Create(int id, GameOptionsMenu gameOptionsMenu, string name, bool DefaultValue = true, BetterOptionItem Parent = null)
+ {
+ Id = id;
+ Tab = gameOptionsMenu;
+ Name = name;
+ IsChecked = DefaultValue;
+
+ if (gameOptionsMenu == null)
+ {
+ Load(DefaultValue);
+ return this;
+ }
+
+ ToggleOption optionBehaviour = UnityEngine.Object.Instantiate(gameOptionsMenu.checkboxOrigin, Vector3.zero, Quaternion.identity, gameOptionsMenu.settingsContainer);
+ optionBehaviour.transform.localPosition = new Vector3(0.952f, 2f - StaticSpacingNum * SpacingNum, -2f);
+ SetUp(optionBehaviour);
+ optionBehaviour.OnValueChanged = new Action((option) => ValueChanged(id, option));
+ SpacingNum += StaticSpacingNumPlus;
+
+ // Set data
+ optionBehaviour.CheckMark.GetComponent().enabled = DefaultValue;
+ TitleText = optionBehaviour.TitleText;
+ Option = optionBehaviour;
+ ThisOption = optionBehaviour;
+
+ Load(DefaultValue);
+
+ BetterOptionItems.Add(this);
+ return this;
+ }
+
+ public void Load(bool DefaultValue)
+ {
+ if (BetterDataManager.CanLoadSetting(Id))
+ {
+ if (ThisOption == null) return;
+
+ var Bool = BetterDataManager.LoadBoolSetting(Id);
+ ThisOption.CheckMark.GetComponent().enabled = Bool;
+ IsChecked = Bool;
+ }
+ else
+ {
+ BetterDataManager.SaveSetting(Id, DefaultValue.ToString());
+ }
+ }
+
+ public override bool GetBool()
+ {
+ if (BetterDataManager.CanLoadSetting(Id))
+ {
+ return BetterDataManager.LoadBoolSetting(Id);
+ }
+ else
+ {
+ return IsChecked ??= false;
+ }
+ }
+
+ public override void SetData(OptionBehaviour optionBehaviour)
+ {
+ optionBehaviour.data = new BaseGameSetting
+ {
+ Title = StringNames.None,
+ Type = OptionTypes.Checkbox,
+ };
+ }
+
+ public override void ValueChanged(int id, OptionBehaviour optionBehaviour)
+ {
+ IsChecked = !IsChecked;
+ BetterDataManager.SaveSetting(Id, IsChecked.ToString());
+ }
+}
diff --git a/Modules/OptionItems/BetterOptionFloatItem.cs b/Modules/OptionItems/BetterOptionFloatItem.cs
new file mode 100644
index 0000000..860e4e8
--- /dev/null
+++ b/Modules/OptionItems/BetterOptionFloatItem.cs
@@ -0,0 +1,178 @@
+using UnityEngine;
+using static Il2CppSystem.Net.Http.Headers.Parser;
+
+namespace BetterAmongUs;
+
+public class BetterOptionFloatItem : BetterOptionItem
+{
+ public float CurrentValue;
+ public FloatRange floatRange = new(0f, 180f);
+ public float Increment = 2.5f;
+ private NumberOption? ThisOption;
+ private string? PostFix;
+ private string? PreFix;
+
+ public BetterOptionItem Create(int id, GameOptionsMenu gameOptionsMenu, string name, float[] values, float DefaultValue, string preFix = "", string postFix = "", BetterOptionItem Parent = null)
+ {
+ Id = id;
+ floatRange = new(values[0], values[1]);
+ Increment = values[2];
+ if (DefaultValue < floatRange.min) DefaultValue = floatRange.min;
+ if (DefaultValue > floatRange.max) DefaultValue = floatRange.max;
+ CurrentValue = DefaultValue;
+
+ if (gameOptionsMenu == null)
+ {
+ Load(DefaultValue);
+ return this;
+ }
+
+ if (values.Length is < 3 or > 3) return null;
+
+ NumberOption optionBehaviour = UnityEngine.Object.Instantiate(gameOptionsMenu.numberOptionOrigin, Vector3.zero, Quaternion.identity, gameOptionsMenu.settingsContainer);
+ optionBehaviour.transform.localPosition = new Vector3(0.952f, 2f - StaticSpacingNum * SpacingNum, -2f);
+ SetUp(optionBehaviour);
+ optionBehaviour.OnValueChanged = new Action((option) => ValueChanged(id, option));
+ SpacingNum += StaticSpacingNumPlus;
+
+ // Fix Game Crash
+ foreach (RulesCategory rulesCategory in GameManager.Instance.GameSettingsList.AllCategories)
+ {
+ optionBehaviour.data = rulesCategory.AllGameSettings.ToArray().FirstOrDefault(item => item.Type == OptionTypes.Number);
+ }
+
+ optionBehaviour.PlusBtn.OnClick.RemoveAllListeners();
+ optionBehaviour.MinusBtn.OnClick.RemoveAllListeners();
+ optionBehaviour.PlusBtn.OnClick.AddListener(new Action(() => Increase()));
+ optionBehaviour.MinusBtn.OnClick.AddListener(new Action(() => Decrease()));
+
+ // Set data
+ Tab = gameOptionsMenu;
+ Name = name;
+ TitleText = optionBehaviour.TitleText;
+ Option = optionBehaviour;
+ PostFix = postFix;
+ PreFix = preFix;
+ ThisOption = optionBehaviour;
+
+ Load(DefaultValue);
+ AdjustButtonsActiveState();
+
+ BetterOptionItems.Add(this);
+ return this;
+ }
+
+ private void AdjustButtonsActiveState()
+ {
+ if (ThisOption == null) return;
+
+ ThisOption.ValueText.text = PreFix + CurrentValue.ToString() + PostFix;
+
+ if (CurrentValue + Increment > floatRange.max)
+ {
+ ThisOption.PlusBtn.SetInteractable(false);
+ ThisOption.MinusBtn.SetInteractable(true);
+ }
+ else if (CurrentValue - Increment < floatRange.min)
+ {
+ ThisOption.PlusBtn.SetInteractable(true);
+ ThisOption.MinusBtn.SetInteractable(false);
+ }
+ else
+ {
+ ThisOption.PlusBtn.SetInteractable(true);
+ ThisOption.MinusBtn.SetInteractable(true);
+ }
+
+ BetterDataManager.SaveSetting(Id, CurrentValue.ToString());
+ }
+
+ public void Increase()
+ {
+ int times = 1;
+ if (Input.GetKey(KeyCode.LeftShift))
+ times = 5;
+ if (Input.GetKey(KeyCode.LeftControl))
+ times = 10;
+
+ if (CurrentValue + Increment * times <= floatRange.max)
+ {
+ CurrentValue += Increment * times;
+ }
+
+ AdjustButtonsActiveState();
+ }
+
+ public void Decrease()
+ {
+ int times = 1;
+ if (Input.GetKey(KeyCode.LeftShift))
+ times = 5;
+ if (Input.GetKey(KeyCode.LeftControl))
+ times = 10;
+
+ if (CurrentValue - Increment * times >= floatRange.min)
+ {
+ CurrentValue -= Increment * times;
+ }
+
+ AdjustButtonsActiveState();
+ }
+
+ public void Load(float DefaultValue)
+ {
+ if (BetterDataManager.CanLoadSetting(Id))
+ {
+ var Float = BetterDataManager.LoadFloatSetting(Id);
+
+ if (Float > floatRange.max || Float < floatRange.min)
+ {
+ Float = DefaultValue;
+ BetterDataManager.SaveSetting(Id, DefaultValue.ToString());
+ }
+
+ CurrentValue = Float;
+ }
+ else
+ {
+ BetterDataManager.SaveSetting(Id, DefaultValue.ToString());
+ }
+ }
+
+ public override float GetFloat()
+ {
+ if (BetterDataManager.CanLoadSetting(Id))
+ {
+ return BetterDataManager.LoadFloatSetting(Id);
+ }
+ else
+ {
+ return CurrentValue;
+ }
+ }
+
+ public override int GetInt()
+ {
+ if (BetterDataManager.CanLoadSetting(Id))
+ {
+ return (int)BetterDataManager.LoadFloatSetting(Id);
+ }
+ else
+ {
+ return (int)CurrentValue;
+ }
+ }
+
+ public override void SetData(OptionBehaviour optionBehaviour)
+ {
+ optionBehaviour.data = new BaseGameSetting
+ {
+ Title = StringNames.None,
+ Type = OptionTypes.Float,
+ };
+ }
+
+ public override void ValueChanged(int id, OptionBehaviour optionBehaviour)
+ {
+ }
+}
diff --git a/Modules/OptionItems/BetterOptionIntItem.cs b/Modules/OptionItems/BetterOptionIntItem.cs
new file mode 100644
index 0000000..f0a8dee
--- /dev/null
+++ b/Modules/OptionItems/BetterOptionIntItem.cs
@@ -0,0 +1,177 @@
+using UnityEngine;
+
+namespace BetterAmongUs;
+
+public class BetterOptionIntItem : BetterOptionItem
+{
+ public int CurrentValue;
+ public IntRange intRange = new(0, 180);
+ public int Increment = 1;
+ private NumberOption? ThisOption;
+ private string? PostFix;
+ private string? PreFix;
+
+ public BetterOptionItem Create(int id, GameOptionsMenu gameOptionsMenu, string name, int[] values, int DefaultValue, string preFix = "", string postFix = "", BetterOptionItem Parent = null)
+ {
+ Id = id;
+ intRange = new(values[0], values[1]);
+ Increment = values[2];
+ if (DefaultValue < intRange.min) DefaultValue = intRange.min;
+ if (DefaultValue > intRange.max) DefaultValue = intRange.max;
+ CurrentValue = DefaultValue;
+
+ if (gameOptionsMenu == null)
+ {
+ Load(DefaultValue);
+ return this;
+ }
+
+ if (values.Length is < 3 or > 3) return null;
+
+ NumberOption optionBehaviour = UnityEngine.Object.Instantiate(gameOptionsMenu.numberOptionOrigin, Vector3.zero, Quaternion.identity, gameOptionsMenu.settingsContainer);
+ optionBehaviour.transform.localPosition = new Vector3(0.952f, 2f - StaticSpacingNum * SpacingNum, -2f);
+ SetUp(optionBehaviour);
+ optionBehaviour.OnValueChanged = new Action((option) => ValueChanged(id, option));
+ SpacingNum += StaticSpacingNumPlus;
+
+ // Fix Game Crash
+ foreach (RulesCategory rulesCategory in GameManager.Instance.GameSettingsList.AllCategories)
+ {
+ optionBehaviour.data = rulesCategory.AllGameSettings.ToArray().FirstOrDefault(item => item.Type == OptionTypes.Number);
+ }
+
+ optionBehaviour.PlusBtn.OnClick.RemoveAllListeners();
+ optionBehaviour.MinusBtn.OnClick.RemoveAllListeners();
+ optionBehaviour.PlusBtn.OnClick.AddListener(new Action(() => Increase()));
+ optionBehaviour.MinusBtn.OnClick.AddListener(new Action(() => Decrease()));
+
+ // Set data
+ Tab = gameOptionsMenu;
+ Name = name;
+ TitleText = optionBehaviour.TitleText;
+ Option = optionBehaviour;
+ PostFix = postFix;
+ PreFix = preFix;
+ ThisOption = optionBehaviour;
+
+ Load(DefaultValue);
+ AdjustButtonsActiveState();
+
+ BetterOptionItems.Add(this);
+ return this;
+ }
+
+ private void AdjustButtonsActiveState()
+ {
+ if (ThisOption == null) return;
+
+ ThisOption.ValueText.text = PreFix + CurrentValue.ToString() + PostFix;
+
+ if (CurrentValue + Increment > intRange.max)
+ {
+ ThisOption.PlusBtn.SetInteractable(false);
+ ThisOption.MinusBtn.SetInteractable(true);
+ }
+ else if (CurrentValue - Increment < intRange.min)
+ {
+ ThisOption.PlusBtn.SetInteractable(true);
+ ThisOption.MinusBtn.SetInteractable(false);
+ }
+ else
+ {
+ ThisOption.PlusBtn.SetInteractable(true);
+ ThisOption.MinusBtn.SetInteractable(true);
+ }
+
+ BetterDataManager.SaveSetting(Id, CurrentValue.ToString());
+ }
+
+ public void Increase()
+ {
+ int times = 1;
+ if (Input.GetKey(KeyCode.LeftShift))
+ times = 5;
+ if (Input.GetKey(KeyCode.LeftControl))
+ times = 10;
+
+ if (CurrentValue + Increment * times <= intRange.max)
+ {
+ CurrentValue += Increment * times;
+ }
+
+ AdjustButtonsActiveState();
+ }
+
+ public void Decrease()
+ {
+ int times = 1;
+ if (Input.GetKey(KeyCode.LeftShift))
+ times = 5;
+ if (Input.GetKey(KeyCode.LeftControl))
+ times = 10;
+
+ if (CurrentValue - Increment * times >= intRange.min)
+ {
+ CurrentValue -= Increment * times;
+ }
+
+ AdjustButtonsActiveState();
+ }
+
+ public void Load(int DefaultValue)
+ {
+ if (BetterDataManager.CanLoadSetting(Id))
+ {
+ var Int = BetterDataManager.LoadIntSetting(Id);
+
+ if (Int > intRange.max || Int < intRange.min)
+ {
+ Int = DefaultValue;
+ BetterDataManager.SaveSetting(Id, DefaultValue.ToString());
+ }
+
+ CurrentValue = Int;
+ }
+ else
+ {
+ BetterDataManager.SaveSetting(Id, DefaultValue.ToString());
+ }
+ }
+
+ public override float GetFloat()
+ {
+ if (BetterDataManager.CanLoadSetting(Id))
+ {
+ return BetterDataManager.LoadIntSetting(Id);
+ }
+ else
+ {
+ return CurrentValue;
+ }
+ }
+
+ public override int GetInt()
+ {
+ if (BetterDataManager.CanLoadSetting(Id))
+ {
+ return BetterDataManager.LoadIntSetting(Id);
+ }
+ else
+ {
+ return CurrentValue;
+ }
+ }
+
+ public override void SetData(OptionBehaviour optionBehaviour)
+ {
+ optionBehaviour.data = new BaseGameSetting
+ {
+ Title = StringNames.None,
+ Type = OptionTypes.Float,
+ };
+ }
+
+ public override void ValueChanged(int id, OptionBehaviour optionBehaviour)
+ {
+ }
+}
diff --git a/Modules/OptionItems/BetterOptionItem.cs b/Modules/OptionItems/BetterOptionItem.cs
new file mode 100644
index 0000000..6b8c937
--- /dev/null
+++ b/Modules/OptionItems/BetterOptionItem.cs
@@ -0,0 +1,64 @@
+using TMPro;
+using UnityEngine;
+
+namespace BetterAmongUs;
+
+public class BetterOptionItem
+{
+ public float StaticSpacingNum => 1f;
+ public float StaticSpacingNumPlus => 0.45f;
+ public static List BetterOptionItems = [];
+ public static float SpacingNum = 0;
+
+ public int maskLayer = 20;
+ public int Id = 0;
+ public GameOptionsMenu? Tab;
+ public OptionBehaviour? Option;
+ public string? Name = "None";
+ public TextMeshPro? TitleText;
+
+ public void SetUp(OptionBehaviour optionBehaviour)
+ {
+ SetData(optionBehaviour);
+ SpriteRenderer[] componentsInChildren = optionBehaviour.GetComponentsInChildren(true);
+ for (int i = 0; i < componentsInChildren.Length; i++)
+ {
+ componentsInChildren[i].material.SetInt(PlayerMaterial.MaskLayer, maskLayer);
+ }
+ foreach (TextMeshPro textMeshPro in optionBehaviour.GetComponentsInChildren(true))
+ {
+ textMeshPro.fontMaterial.SetFloat("_StencilComp", 3f);
+ textMeshPro.fontMaterial.SetFloat("_Stencil", maskLayer);
+ }
+ }
+
+ public virtual bool GetBool()
+ {
+ throw new NotImplementedException();
+ }
+
+ public virtual float GetFloat()
+ {
+ throw new NotImplementedException();
+ }
+
+ public virtual int GetInt()
+ {
+ throw new NotImplementedException();
+ }
+
+ public virtual int GetValue()
+ {
+ throw new NotImplementedException();
+ }
+
+ public virtual void SetData(OptionBehaviour optionBehaviour)
+ {
+ throw new NotImplementedException();
+ }
+
+ public virtual void ValueChanged(int id, OptionBehaviour optionBehaviour)
+ {
+ throw new NotImplementedException();
+ }
+}
diff --git a/Modules/OptionItems/BetterOptionStringItem.cs b/Modules/OptionItems/BetterOptionStringItem.cs
new file mode 100644
index 0000000..450ea60
--- /dev/null
+++ b/Modules/OptionItems/BetterOptionStringItem.cs
@@ -0,0 +1,146 @@
+using UnityEngine;
+
+namespace BetterAmongUs;
+
+public class BetterOptionStringItem : BetterOptionItem
+{
+ public string[] Values = [];
+ public int CurrentValue;
+ private StringOption? ThisOption;
+
+ public BetterOptionItem Create(int id, GameOptionsMenu gameOptionsMenu, string name, string[] strings, int DefaultValue = 0, BetterOptionItem Parent = null)
+ {
+ Id = id;
+ Values = strings;
+ Tab = gameOptionsMenu;
+ Name = name;
+ if (DefaultValue < 0) DefaultValue = 0;
+ if (DefaultValue > Values.Length) DefaultValue = Values.Length;
+ CurrentValue = DefaultValue;
+
+ if (gameOptionsMenu == null)
+ {
+ Load(DefaultValue);
+ return this;
+ }
+
+ StringOption optionBehaviour = UnityEngine.Object.Instantiate(gameOptionsMenu.stringOptionOrigin, Vector3.zero, Quaternion.identity, gameOptionsMenu.settingsContainer);
+ optionBehaviour.transform.localPosition = new Vector3(0.952f, 2f - StaticSpacingNum * SpacingNum, -2f);
+ SetUp(optionBehaviour);
+ optionBehaviour.OnValueChanged = new Action((option) => ValueChanged(id, option));
+ SpacingNum += StaticSpacingNumPlus;
+
+ // Fix Game Crash
+ foreach (RulesCategory rulesCategory in GameManager.Instance.GameSettingsList.AllCategories)
+ {
+ optionBehaviour.data = rulesCategory.AllGameSettings.ToArray().FirstOrDefault(item => item.Type == OptionTypes.String);
+ }
+
+ optionBehaviour.PlusBtn.OnClick.RemoveAllListeners();
+ optionBehaviour.MinusBtn.OnClick.RemoveAllListeners();
+ optionBehaviour.PlusBtn.OnClick.AddListener(new Action(() => Increase()));
+ optionBehaviour.MinusBtn.OnClick.AddListener(new Action(() => Decrease()));
+
+ // Set data
+ TitleText = optionBehaviour.TitleText;
+ Option = optionBehaviour;
+ ThisOption = optionBehaviour;
+
+ Load(DefaultValue);
+ AdjustButtonsActiveState();
+
+ BetterOptionItems.Add(this);
+ return this;
+ }
+
+ private void AdjustButtonsActiveState()
+ {
+ if (ThisOption == null) return;
+
+ if (CurrentValue <= Values.Length - 1 && CurrentValue >= 0)
+ {
+ ThisOption.ValueText.text = Values[CurrentValue];
+ }
+
+ if (CurrentValue >= Values.Length - 1)
+ {
+ ThisOption.PlusBtn.SetInteractable(false);
+ ThisOption.MinusBtn.SetInteractable(true);
+ }
+ else if (CurrentValue <= 0)
+ {
+ ThisOption.PlusBtn.SetInteractable(true);
+ ThisOption.MinusBtn.SetInteractable(false);
+ }
+ else
+ {
+ ThisOption.PlusBtn.SetInteractable(true);
+ ThisOption.MinusBtn.SetInteractable(true);
+ }
+
+ BetterDataManager.SaveSetting(Id, CurrentValue.ToString());
+ }
+
+ public void Increase()
+ {
+ if (CurrentValue < Values.Length)
+ {
+ CurrentValue++;
+ AdjustButtonsActiveState();
+ }
+ }
+
+ public void Decrease()
+ {
+ if (CurrentValue > 0)
+ {
+ CurrentValue--;
+ AdjustButtonsActiveState();
+ }
+ }
+
+ public void Load(int DefaultValue)
+ {
+ if (BetterDataManager.CanLoadSetting(Id))
+ {
+ var Int = BetterDataManager.LoadIntSetting(Id);
+
+ if (Int > Values.Length - 1 || Int < 0)
+ {
+ Int = DefaultValue;
+ BetterDataManager.SaveSetting(Id, DefaultValue.ToString());
+ }
+
+ CurrentValue = Int;
+ }
+ else
+ {
+ BetterDataManager.SaveSetting(Id, DefaultValue.ToString());
+ }
+ }
+
+ public override int GetValue()
+ {
+ if (BetterDataManager.CanLoadSetting(Id))
+ {
+ return BetterDataManager.LoadIntSetting(Id);
+ }
+ else
+ {
+ return CurrentValue;
+ }
+ }
+
+ public override void SetData(OptionBehaviour optionBehaviour)
+ {
+ optionBehaviour.data = new BaseGameSetting
+ {
+ Title = StringNames.None,
+ Type = OptionTypes.String,
+ };
+ }
+
+ public override void ValueChanged(int id, OptionBehaviour optionBehaviour)
+ {
+ }
+}
diff --git a/Modules/OptionItems/NoneOption/BetterOptionDividerItem.cs b/Modules/OptionItems/NoneOption/BetterOptionDividerItem.cs
new file mode 100644
index 0000000..abdf623
--- /dev/null
+++ b/Modules/OptionItems/NoneOption/BetterOptionDividerItem.cs
@@ -0,0 +1,32 @@
+using UnityEngine;
+
+namespace BetterAmongUs;
+
+public class BetterOptionDividerItem : BetterOptionItem
+{
+ public BetterOptionItem Create(GameOptionsMenu gameOptionsMenu)
+ {
+ if (gameOptionsMenu == null)
+ {
+ return this;
+ }
+
+ SpacingNum += 0.15f;
+
+ Tab = gameOptionsMenu;
+ Name = "Divider";
+ CategoryHeaderMasked categoryHeaderMasked = UnityEngine.Object.Instantiate(gameOptionsMenu.categoryHeaderOrigin, Vector3.zero, Quaternion.identity, gameOptionsMenu.settingsContainer);
+ categoryHeaderMasked.transform.localScale = Vector3.one * 0.63f;
+ categoryHeaderMasked.transform.localPosition = new Vector3(-0.903f, 2f - StaticSpacingNum * SpacingNum, -2f);
+ UnityEngine.Object.Destroy(categoryHeaderMasked.Background.gameObject);
+ UnityEngine.Object.Destroy(categoryHeaderMasked.Title.gameObject);
+ if (categoryHeaderMasked.Divider != null)
+ {
+ categoryHeaderMasked.Divider.material.SetInt(PlayerMaterial.MaskLayer, maskLayer);
+ }
+
+ SpacingNum += 0.45f;
+
+ return this;
+ }
+}
diff --git a/Modules/OptionItems/NoneOption/BetterOptionHeaderItem.cs b/Modules/OptionItems/NoneOption/BetterOptionHeaderItem.cs
new file mode 100644
index 0000000..34cae00
--- /dev/null
+++ b/Modules/OptionItems/NoneOption/BetterOptionHeaderItem.cs
@@ -0,0 +1,34 @@
+using UnityEngine;
+
+namespace BetterAmongUs;
+
+public class BetterOptionHeaderItem : BetterOptionItem
+{
+ public BetterOptionItem Create(GameOptionsMenu gameOptionsMenu, string name)
+ {
+ if (gameOptionsMenu == null)
+ {
+ return this;
+ }
+
+ SpacingNum += 0.1f;
+
+ Tab = gameOptionsMenu;
+ Name = name;
+ CategoryHeaderMasked categoryHeaderMasked = UnityEngine.Object.Instantiate(gameOptionsMenu.categoryHeaderOrigin, Vector3.zero, Quaternion.identity, gameOptionsMenu.settingsContainer);
+ categoryHeaderMasked.transform.localScale = Vector3.one * 0.63f;
+ categoryHeaderMasked.transform.localPosition = new Vector3(-0.903f, 2f - StaticSpacingNum * SpacingNum, -2f);
+ categoryHeaderMasked.Title.text = name;
+ categoryHeaderMasked.Background.material.SetInt(PlayerMaterial.MaskLayer, maskLayer);
+ if (categoryHeaderMasked.Divider != null)
+ {
+ categoryHeaderMasked.Divider.material.SetInt(PlayerMaterial.MaskLayer, maskLayer);
+ }
+ categoryHeaderMasked.Title.fontMaterial.SetFloat("_StencilComp", 3f);
+ categoryHeaderMasked.Title.fontMaterial.SetFloat("_Stencil", maskLayer);
+
+ SpacingNum += 0.75f;
+
+ return this;
+ }
+}
diff --git a/Modules/OptionItems/NoneOption/BetterOptionTitleItem.cs b/Modules/OptionItems/NoneOption/BetterOptionTitleItem.cs
new file mode 100644
index 0000000..5c712be
--- /dev/null
+++ b/Modules/OptionItems/NoneOption/BetterOptionTitleItem.cs
@@ -0,0 +1,46 @@
+using UnityEngine;
+
+namespace BetterAmongUs;
+
+public class BetterOptionTitleItem : BetterOptionItem
+{
+ public BetterOptionItem Create(GameOptionsMenu gameOptionsMenu, string name)
+ {
+ if (gameOptionsMenu == null)
+ {
+ return this;
+ }
+
+ ToggleOption optionBehaviour = UnityEngine.Object.Instantiate(gameOptionsMenu.checkboxOrigin, Vector3.zero, Quaternion.identity, gameOptionsMenu.settingsContainer);
+ optionBehaviour.transform.localPosition = new Vector3(0.952f, 2f - StaticSpacingNum * SpacingNum, -2f);
+ SetUp(optionBehaviour);
+ SpacingNum += StaticSpacingNumPlus;
+
+ UnityEngine.Object.Destroy(optionBehaviour.CheckMark.transform.parent.gameObject);
+ UnityEngine.Object.Destroy(optionBehaviour.GetComponent());
+ optionBehaviour.TitleText.alignment = TMPro.TextAlignmentOptions.Center;
+ optionBehaviour.TitleText.outlineColor = Color.black;
+ optionBehaviour.TitleText.outlineWidth = 0.2f;
+ optionBehaviour.TitleText.transform.localPosition += new Vector3(0f, 0.05f, 0f);
+ optionBehaviour.LabelBackground.color = new Color(0.6f, 0.6f, 0.6f, 1f);
+ optionBehaviour.LabelBackground.transform.SetLocalZ(1f);
+
+ // Set data
+ Tab = gameOptionsMenu;
+ Name = $"{name}";
+ Option = optionBehaviour;
+ TitleText = optionBehaviour.TitleText;
+
+ BetterOptionItems.Add(this);
+ return this;
+ }
+
+ public override void SetData(OptionBehaviour optionBehaviour)
+ {
+ optionBehaviour.data = new BaseGameSetting
+ {
+ Title = StringNames.None,
+ Type = OptionTypes.Checkbox,
+ };
+ }
+}
diff --git a/Modules/RPC.cs b/Modules/RPC.cs
index 7353430..9642569 100644
--- a/Modules/RPC.cs
+++ b/Modules/RPC.cs
@@ -1,7 +1,6 @@
using BetterAmongUs.Patches;
using HarmonyLib;
using Hazel;
-using InnerNet;
namespace BetterAmongUs;
@@ -22,7 +21,7 @@ enum CustomRPC : int
}
[HarmonyPatch(typeof(PlayerControl), nameof(PlayerControl.HandleRpc))]
-internal class RPCHandlerPatch
+internal class PlayerControlRPCHandlerPatch
{
public static bool Prefix(PlayerControl __instance, [HarmonyArgument(0)] byte callId, [HarmonyArgument(1)] MessageReader reader)
{
@@ -58,6 +57,21 @@ internal class RPCHandlerPatch
}
}
+[HarmonyPatch(typeof(PlayerPhysics), nameof(PlayerPhysics.HandleRpc))]
+internal class PlayerPhysicsRPCHandlerPatch
+{
+ public static void Prefix(PlayerPhysics __instance, [HarmonyArgument(0)] byte callId, [HarmonyArgument(1)] MessageReader reader)
+ {
+ if (AntiCheat.CheckCancelRPC(__instance.myPlayer, callId, reader) != true)
+ {
+ Logger.LogCheat($"RPC canceled by Anti-Cheat: {Enum.GetName((RpcCalls)callId)}{Enum.GetName((CustomRPC)callId)} - {callId}");
+ }
+
+ AntiCheat.CheckRPC(__instance.myPlayer, callId, reader);
+ RPC.HandleRPC(__instance.myPlayer, callId, reader);
+ }
+}
+
[HarmonyPatch(typeof(ShipStatus), nameof(ShipStatus.UpdateSystem), typeof(SystemTypes), typeof(PlayerControl), typeof(MessageReader))]
public static class MessageReaderUpdateSystemPatch
{
@@ -211,6 +225,11 @@ internal static class RPC
switch (callId)
{
+ case (byte)RpcCalls.SetName:
+ reader.ReadUInt32();
+ var name = reader.ReadString();
+ player.BetterData().RealName = name;
+ break;
case (byte)RpcCalls.SendChat:
var text = reader.ReadString();
@@ -224,7 +243,7 @@ internal static class RPC
}
// Check banned words
- if (Main.UseBannedList.Value)
+ if (BetterGameSettings.UseBanWordList.GetBool())
{
try
{
diff --git a/Modules/Utils.cs b/Modules/Utils.cs
index 6972ff8..07c9046 100644
--- a/Modules/Utils.cs
+++ b/Modules/Utils.cs
@@ -132,6 +132,8 @@ public static class Utils
// Get name for role
public static string GetRoleName(RoleTypes role) => Main.GetRoleName[(int)role];
+ // Get color for role
+ public static string GetRoleColor(RoleTypes role) => Main.GetRoleColor[(int)role];
// Get hex color for team
public static string GetTeamHexColor(RoleTeamTypes team)
{
diff --git a/Patches/ChatPatch.cs b/Patches/ChatPatch.cs
index b471ea4..68e577d 100644
--- a/Patches/ChatPatch.cs
+++ b/Patches/ChatPatch.cs
@@ -53,8 +53,9 @@ class ChatPatch
class ChatControllerPatch
{
[HarmonyPatch(nameof(ChatController.Update))]
- [HarmonyPostfix]
- public static void Update_Postfix(ChatController __instance)
+ [HarmonyPrefix]
+ [HarmonyPriority(Priority.First)]
+ public static void Update_Prefix(ChatController __instance)
{
for (int i = 0; i < __instance.scroller.Inner.gameObject.transform.childCount; i++)
{
@@ -107,6 +108,7 @@ class ChatPatch
[HarmonyPatch(nameof(ChatController.AddChat))]
[HarmonyPrefix]
+ [HarmonyPriority(Priority.First)]
public static bool AddChat_Prefix(ChatController __instance, [HarmonyArgument(0)] PlayerControl sourcePlayer, [HarmonyArgument(1)] string chatText)
{
bool censor = false;
diff --git a/Patches/ClientOptionsPatch.cs b/Patches/ClientOptionsPatch.cs
index a7efcb3..f811f98 100644
--- a/Patches/ClientOptionsPatch.cs
+++ b/Patches/ClientOptionsPatch.cs
@@ -1,6 +1,5 @@
using HarmonyLib;
using UnityEngine;
-using static Rewired.Data.UserDataStore_PlayerPrefs.ControllerAssignmentSaveInfo;
namespace BetterAmongUs.Patches;
@@ -13,7 +12,7 @@ public static class OptionsMenuBehaviourPatch
private static ClientOptionItem BetterHost;
private static ClientOptionItem BetterRoleAlgorithma;
private static ClientOptionItem BetterNotifications;
- private static ClientOptionItem UseBannedList;
+ private static ClientOptionItem ChatInGameplay;
private static ClientOptionItem LobbyPlayerInfo;
private static ClientOptionItem DisableLobbyTheme;
private static ClientOptionItem UnlockFPS;
@@ -80,10 +79,10 @@ public static class OptionsMenuBehaviourPatch
BetterNotificationManager.Notifying = false;
}
}
-
- if (UseBannedList == null || UseBannedList.ToggleButton == null)
+
+ if (ChatInGameplay == null || ChatInGameplay.ToggleButton == null)
{
- UseBannedList = ClientOptionItem.Create("Use Ban Lists", Main.UseBannedList, __instance);
+ ChatInGameplay = ClientOptionItem.Create("Chat In Gameplay", Main.ChatInGameplay, __instance);
}
if (LobbyPlayerInfo == null || LobbyPlayerInfo.ToggleButton == null)
diff --git a/Patches/ClientPatch.cs b/Patches/ClientPatch.cs
index dc59b23..c97c6a0 100644
--- a/Patches/ClientPatch.cs
+++ b/Patches/ClientPatch.cs
@@ -77,7 +77,7 @@ public class ClientPatch
[HarmonyPrefix]
public static void KickPlayer_Prefix(ref int clientId, ref bool ban)
{
- if (ban && Main.UseBannedList.Value)
+ if (ban && BetterGameSettings.UseBanPlayerList.GetBool())
{
NetworkedPlayerInfo info = Utils.PlayerFromClientId(clientId).Data;
BetterDataManager.SaveBanList(info.FriendCode, info.Puid);
diff --git a/Patches/CommandsPatch.cs b/Patches/CommandsPatch.cs
index 5712f37..faa81dc 100644
--- a/Patches/CommandsPatch.cs
+++ b/Patches/CommandsPatch.cs
@@ -175,7 +175,7 @@ class CommandsPatch
sb.Append("\n\n");
}
Utils.AddChatPrivate(sb.ToString());
- break;
+ break;
case "whisper" or "w":
if (HandlePlayerArgument(command, subArgs) == true)
{
@@ -410,7 +410,7 @@ class CommandsPatch
RPC.SyncAllNames(force: true);
Utils.AddChatPrivate("All player names have been updated and synced!");
}
- break;
+ break;
case "suicide":
if (HandleIsHost(command) == true)
{
diff --git a/Patches/GamePlayManagerPatch.cs b/Patches/GamePlayManagerPatch.cs
index 3d8f9a8..dde1357 100644
--- a/Patches/GamePlayManagerPatch.cs
+++ b/Patches/GamePlayManagerPatch.cs
@@ -1,5 +1,4 @@
using HarmonyLib;
-using Newtonsoft.Json.Utilities;
using System.Text;
using TMPro;
using UnityEngine;
@@ -19,23 +18,6 @@ class GamePlayManager
{
AntiCheat.PauseAntiCheat();
}
-
- // Clear unused Better Data
- var keysToRemove = new List();
-
- foreach (var betterInfo in PlayerControlDataExtension.playerInfo)
- {
- if (!Main.AllPlayerControls.Any(pc => pc.Data.Puid == betterInfo.Key))
- {
- keysToRemove.Add(betterInfo.Key);
- }
- }
-
- foreach (var key in keysToRemove)
- {
- PlayerControlDataExtension.playerInfo.Remove(key);
- }
-
}
[HarmonyPatch(nameof(LobbyBehaviour.Start))]
[HarmonyPostfix]
@@ -58,6 +40,62 @@ class GamePlayManager
{
if (Main.DisableLobbyTheme.Value)
SoundManager.instance.StopSound(LobbyBehaviour.Instance.MapTheme);
+
+ // Clear unused Better Data
+ try
+ {
+ var keysToRemove = new List();
+
+ foreach (var betterInfo in PlayerControlDataExtension.playerInfo)
+ {
+ if (Main.AllPlayerControls.Any(pc => pc.Data.Puid == betterInfo.Key))
+ continue;
+
+ keysToRemove.Add(betterInfo.Key);
+ }
+
+ foreach (var key in keysToRemove)
+ {
+ PlayerControlDataExtension.playerInfo.Remove(key);
+ }
+ }
+ catch { }
+ }
+ }
+
+ [HarmonyPatch(typeof(IntroCutscene))]
+ public class IntroCutscenePatch
+ {
+ [HarmonyPatch(nameof(IntroCutscene.ShowRole))]
+ [HarmonyPostfix]
+ private static void ShowRole_Postfix(IntroCutscene __instance)
+ {
+ static Color HexToColor(string hex)
+ {
+ if (hex.StartsWith("#"))
+ {
+ hex = hex.Substring(1);
+ }
+
+ byte r = byte.Parse(hex.Substring(0, 2), System.Globalization.NumberStyles.HexNumber);
+ byte g = byte.Parse(hex.Substring(2, 2), System.Globalization.NumberStyles.HexNumber);
+ byte b = byte.Parse(hex.Substring(4, 2), System.Globalization.NumberStyles.HexNumber);
+
+ return new Color32(r, g, b, 255);
+ }
+
+ _ = new LateTask(() =>
+ {
+ Color RoleColor = HexToColor(Utils.GetRoleColor(PlayerControl.LocalPlayer.Data.RoleType));
+
+ __instance.ImpostorText.gameObject.SetActive(false);
+ __instance.TeamTitle.gameObject.SetActive(false);
+ __instance.FrontMost.gameObject.SetActive(false);
+ __instance.BackgroundBar.material.color = RoleColor;
+ __instance.YouAreText.color = RoleColor;
+ __instance.RoleText.color = RoleColor;
+ __instance.RoleBlurbText.color = RoleColor;
+ }, 0.0025f, shoudLog: false);
}
}
diff --git a/Patches/GameSettingMenuPatch.cs b/Patches/GameSettingMenuPatch.cs
new file mode 100644
index 0000000..357bd57
--- /dev/null
+++ b/Patches/GameSettingMenuPatch.cs
@@ -0,0 +1,345 @@
+using AmongUs.GameOptions;
+using HarmonyLib;
+using UnityEngine;
+
+namespace BetterAmongUs.Patches;
+
+
+class BetterGameSettings
+{
+ public static BetterOptionItem? WhenCheating;
+ public static BetterOptionItem? InvalidFriendCode;
+ public static BetterOptionItem? UseBanPlayerList;
+ public static BetterOptionItem? UseBanNameList;
+ public static BetterOptionItem? UseBanWordList;
+ public static BetterOptionItem? HideAndSeekImpNum;
+ public static BetterOptionItem? DetectedLevelAbove;
+ public static BetterOptionItem? DetectCheatClients;
+ public static BetterOptionItem? DetectInvalidRPCs;
+
+ public static BetterOptionItem? ExperimentalDetectInvalidSabotage;
+}
+
+[HarmonyPatch(typeof(GameSettingMenu))]
+static class GameSettingMenuPatch
+{
+ private static PassiveButton BetterSettingsButton;
+ public static GameOptionsMenu BetterSettingsTab;
+ private static List TitleList = [];
+
+ public static void SetupSettings(bool IsPreload = false)
+ {
+ BetterOptionItem.SpacingNum = 0;
+ BetterOptionItem.BetterOptionItems.Clear();
+ TitleList.Clear();
+
+ // Anti-Cheat Settings
+ {
+ TitleList.Add(new BetterOptionHeaderItem().Create(BetterSettingsTab, "Anti-Cheat Settings"));
+
+ if (IsPreload || GameStates.IsHost)
+ {
+ TitleList.Add(new BetterOptionTitleItem().Create(BetterSettingsTab, $"Host Only"));
+ BetterGameSettings.WhenCheating = new BetterOptionStringItem().Create(100, BetterSettingsTab, "When a player is caught cheating", ["Do Nothing", "Kick", "Ban"], 2);
+ BetterGameSettings.InvalidFriendCode = new BetterOptionCheckboxItem().Create(200, BetterSettingsTab, "Allow invalid friendCodes", true);
+ BetterGameSettings.UseBanPlayerList = new BetterOptionCheckboxItem().Create(300, BetterSettingsTab, "Use Ban Player List", true);
+ BetterGameSettings.UseBanNameList = new BetterOptionCheckboxItem().Create(400, BetterSettingsTab, "Use Ban Name List", true);
+ BetterGameSettings.UseBanWordList = new BetterOptionCheckboxItem().Create(500, BetterSettingsTab, "Use Ban Word List", true);
+ TitleList.Add(new BetterOptionDividerItem().Create(BetterSettingsTab));
+ }
+
+ TitleList.Add(new BetterOptionTitleItem().Create(BetterSettingsTab, $"Detections"));
+ BetterGameSettings.DetectedLevelAbove = new BetterOptionIntItem().Create(600, BetterSettingsTab, "Detected player level = or >", [100, 5000, 5], 200, "Lv ", "");
+ BetterGameSettings.DetectCheatClients = new BetterOptionCheckboxItem().Create(700, BetterSettingsTab, "Detect Cheat Clients", true);
+ BetterGameSettings.DetectInvalidRPCs = new BetterOptionCheckboxItem().Create(800, BetterSettingsTab, "Detect Invalid RPCs", true);
+
+ TitleList.Add(new BetterOptionDividerItem().Create(BetterSettingsTab));
+ TitleList.Add(new BetterOptionTitleItem().Create(BetterSettingsTab, $"Experimental"));
+ BetterGameSettings.ExperimentalDetectInvalidSabotage = new BetterOptionCheckboxItem().Create(100000, BetterSettingsTab, "Detect Invalid Sabotages", false);
+ }
+
+ // Gameplay Settings
+ {
+ if (IsPreload || GameStates.IsHost)
+ {
+ if (IsPreload || !GameStates.IsHideNSeek)
+ {
+ new BetterOptionHeaderItem().Create(BetterSettingsTab, "Gameplay Settings");
+ }
+ else if (IsPreload || GameStates.IsHideNSeek)
+ {
+ new BetterOptionHeaderItem().Create(BetterSettingsTab, "Hide & Seek Settings");
+
+ if (IsPreload || Main.BetterRoleAlgorithma.Value)
+ {
+ new BetterOptionTitleItem().Create(BetterSettingsTab, $"Better Role Algorithma");
+ BetterOptionItem.SpacingNum += 0.2f;
+ new BetterOptionTitleItem().Create(BetterSettingsTab, $"Imposter");
+ BetterGameSettings.HideAndSeekImpNum = new BetterOptionIntItem().Create(1000, BetterSettingsTab, "# Seekers", [1, 5, 1], 1, "", "");
+ }
+ }
+ }
+ }
+
+ /*
+ new BetterOptionCheckboxItem().Create(0, BetterSettingsTab, "CheckBox Test", true);
+ new BetterOptionStringItem().Create(1, BetterSettingsTab, "String Test", ["Test 1", "Test 2", "Test 3"]);
+ new BetterOptionFloatItem().Create(2, BetterSettingsTab, "Float Test 1", [0f, 180f, 2.5f], 0f, "");
+ new BetterOptionIntItem().Create(5, BetterSettingsTab, "Int Test", [0, 5, 1], 0, "");
+ new BetterOptionHeaderItem().Create(BetterSettingsTab, "Test Settings 2");
+ */
+
+ if (BetterSettingsTab != null)
+ BetterSettingsTab.scrollBar.SetYBoundsMax(1.25f * BetterOptionItem.SpacingNum / 2);
+ }
+
+ private static void Initialize()
+ {
+ _ = new LateTask(() =>
+ {
+ foreach (var item in BetterOptionItem.BetterOptionItems)
+ {
+ if (item != null)
+ {
+ if (item.TitleText != null)
+ {
+ item.TitleText.text = item.Name;
+ }
+ }
+ }
+ }, 0.005f, shoudLog: false);
+ }
+
+ [HarmonyPatch(nameof(GameSettingMenu.Update))]
+ [HarmonyPostfix]
+ public static void Update_Postfix(GameSettingMenu __instance)
+ {
+ if (BetterSettingsButton != null)
+ {
+ BetterSettingsButton.buttonText.SetText("Better Settings");
+
+ if (!BetterSettingsButton.selected && !BetterSettingsButton.activeSprites.active)
+ {
+ BetterSettingsButton.buttonText.color = new Color(0f, 1f, 0f, 1f);
+ }
+ else
+ {
+ BetterSettingsButton.buttonText.color = new Color(0.35f, 1f, 0.35f, 1f);
+ }
+ if (BetterSettingsButton.selected)
+ {
+ __instance.MenuDescriptionText.text = "Edit better settings for your lobby and gameplay.";
+ }
+ }
+ }
+
+ [HarmonyPatch(nameof(GameSettingMenu.Start))]
+ [HarmonyPostfix]
+ public static void Start_Postfix(GameSettingMenu __instance)
+ {
+ __instance.gameObject.transform.SetLocalY(-0.1f);
+ GameObject PanelSprite = __instance.gameObject.transform.Find("PanelSprite").gameObject;
+ if (PanelSprite != null)
+ {
+ PanelSprite.transform.SetLocalY(-0.32f);
+ PanelSprite.transform.localScale = new Vector3(PanelSprite.transform.localScale.x, 0.625f);
+ }
+
+ BetterSettingsButton = UnityEngine.Object.Instantiate(__instance.GameSettingsButton, __instance.GameSettingsButton.transform.parent);
+
+ BetterSettingsButton.name = "BetterSettings";
+ BetterSettingsButton.OnClick.RemoveAllListeners();
+ BetterSettingsButton.OnMouseOver.RemoveAllListeners();
+
+ BetterSettingsButton.activeSprites.GetComponent().color = new Color(0f, 1f, 0.35f, 1f);
+ BetterSettingsButton.inactiveSprites.GetComponent().color = new Color(0f, 1f, 0.35f, 1f);
+ BetterSettingsButton.selectedSprites.GetComponent().color = new Color(0f, 1f, 0.35f, 1f);
+
+
+ BetterSettingsButton.OnClick.AddListener(new Action(() =>
+ {
+ __instance.ChangeTab(3, false);
+ }));
+
+ BetterSettingsTab = UnityEngine.Object.Instantiate(__instance.GameSettingsTab, __instance.GameSettingsTab.transform.parent);
+ BetterSettingsTab.name = "BETTER SETTINGS TAB";
+ BetterSettingsTab.scrollBar.Inner.DestroyChildren();
+
+ __instance.GamePresetsButton.OnMouseOver.RemoveAllListeners();
+ __instance.GameSettingsButton.OnMouseOver.RemoveAllListeners();
+ __instance.RoleSettingsButton.OnMouseOver.RemoveAllListeners();
+
+
+ BetterSettingsButton.transform.position = BetterSettingsButton.transform.position - new Vector3(0f, 1.265f, 0f);
+ if (!GameStates.IsHideNSeek && GameStates.IsHost)
+ {
+ __instance.ChangeTab(1, false);
+ }
+ else if (GameStates.IsHost)
+ {
+ __instance.RoleSettingsButton.gameObject.SetActive(true);
+ __instance.RoleSettingsButton.GetComponent().enabled = false;
+ __instance.RoleSettingsButton.inactiveSprites.GetComponent().color = new(0.5f, 0.5f, 0.5f, 1f);
+ __instance.ChangeTab(1, false);
+ }
+ else
+ {
+ __instance.GamePresetsButton.GetComponent().enabled = false;
+ __instance.GameSettingsButton.GetComponent().enabled = false;
+ __instance.RoleSettingsButton.GetComponent().enabled = false;
+ __instance.GamePresetsButton.inactiveSprites.GetComponent().color = new(0.5f, 0.5f, 0.5f, 1f);
+ __instance.GameSettingsButton.inactiveSprites.GetComponent().color = new(0.5f, 0.5f, 0.5f, 1f);
+ __instance.RoleSettingsButton.inactiveSprites.GetComponent().color = new(0.5f, 0.5f, 0.5f, 1f);
+ __instance.ChangeTab(3, false);
+ }
+
+ SetupSettings();
+ }
+
+ [HarmonyPatch(nameof(GameSettingMenu.ChangeTab))]
+ [HarmonyPrefix]
+ public static void ChangeTab_Prefix(GameSettingMenu __instance, [HarmonyArgument(0)] int tabNum, [HarmonyArgument(1)] bool previewOnly)
+ {
+ if (BetterSettingsTab == null || BetterSettingsButton == null) return;
+
+ BetterSettingsTab.gameObject.SetActive(false);
+ BetterSettingsButton.SelectButton(false);
+
+ if ((previewOnly && Controller.currentTouchType == Controller.TouchType.Joystick) || !previewOnly)
+ {
+ switch (tabNum)
+ {
+ case 3:
+ BetterSettingsTab.gameObject.SetActive(true);
+ break;
+ }
+ }
+ }
+
+ [HarmonyPatch(nameof(GameSettingMenu.ChangeTab))]
+ [HarmonyPostfix]
+ public static void ChangeTab_Postfix(GameSettingMenu __instance, [HarmonyArgument(0)] int tabNum)
+ {
+ if (BetterSettingsTab == null || BetterSettingsButton == null) return;
+
+ BetterSettingsButton.buttonText.color = new Color(0f, 1f, 0f, 1f);
+
+ switch (tabNum)
+ {
+ case 3:
+ BetterSettingsButton.SelectButton(true);
+ Initialize();
+ break;
+ }
+ }
+}
+
+[HarmonyPatch(typeof(GameOptionsMenu))]
+static class GameOptionsMenuPatch
+{
+ [HarmonyPatch(nameof(GameOptionsMenu.CreateSettings))]
+ [HarmonyPrefix]
+ public static bool CreateSettings_Prefix(GameOptionsMenu __instance)
+ {
+ if (__instance == GameSettingMenuPatch.BetterSettingsTab)
+ {
+ return false;
+ }
+
+ return true;
+ }
+}
+
+[HarmonyPatch(typeof(OptionsConsole))]
+static class OptionsConsolePatch
+{
+ [HarmonyPatch(nameof(OptionsConsole.CanUse))]
+ [HarmonyPrefix]
+ public static void CanUse_Prefix(OptionsConsole __instance)
+ {
+ __instance.HostOnly = false;
+ }
+}
+
+// Allow settings bypass
+[HarmonyPatch(typeof(NumberOption))]
+static class NumberOptionPatch
+{
+ [HarmonyPatch(nameof(NumberOption.Increase))]
+ [HarmonyPrefix]
+ public static bool Increase_Prefix(NumberOption __instance)
+ {
+ int times = 1;
+ if (Input.GetKey(KeyCode.LeftShift))
+ times = 5;
+ if (Input.GetKey(KeyCode.LeftControl))
+ times = 10;
+
+ __instance.Value += __instance.Increment * times;
+ __instance.UpdateValue();
+ return false;
+ }
+
+ [HarmonyPatch(nameof(NumberOption.Decrease))]
+ [HarmonyPrefix]
+ public static bool Decrease_Prefix(NumberOption __instance)
+ {
+ int times = 1;
+ if (Input.GetKey(KeyCode.LeftShift))
+ times = 5;
+ if (Input.GetKey(KeyCode.LeftControl))
+ times = 10;
+
+ __instance.Value -= __instance.Increment * times;
+ __instance.UpdateValue();
+ return false;
+ }
+
+ [HarmonyPatch(nameof(NumberOption.UpdateValue))]
+ [HarmonyPrefix]
+ public static bool UpdateValue_Prefix(NumberOption __instance)
+ {
+ if (__instance.floatOptionName != FloatOptionNames.Invalid)
+ {
+ GameOptionsManager.Instance.CurrentGameOptions.SetFloat(__instance.floatOptionName, __instance.GetFloat());
+ return false;
+ }
+ if (__instance.intOptionName != Int32OptionNames.Invalid)
+ {
+ GameOptionsManager.Instance.CurrentGameOptions.SetInt(__instance.intOptionName, __instance.GetInt());
+ return false;
+ }
+ return false;
+ }
+
+ [HarmonyPatch(nameof(NumberOption.FixedUpdate))]
+ [HarmonyPrefix]
+ public static bool FixedUpdate_Prefix(NumberOption __instance)
+ {
+ try
+ {
+ if (__instance.MinusBtn != null && __instance.PlusBtn != null)
+ {
+ __instance.MinusBtn.SetInteractable(true);
+ __instance.PlusBtn.SetInteractable(true);
+ }
+
+ if (__instance.oldValue != __instance.Value)
+ {
+ __instance.oldValue = __instance.Value;
+
+ if (__instance.Value > __instance.ValidRange.max || __instance.Value < __instance.ValidRange.min)
+ {
+ __instance.ValueText.text = $"{__instance.data.GetValueString(__instance.Value)}";
+ }
+ else
+ {
+ __instance.ValueText.text = __instance.data.GetValueString(__instance.Value);
+ }
+ }
+ }
+ catch { }
+
+ return false;
+ }
+}
\ No newline at end of file
diff --git a/Patches/HudManagerPatch.cs b/Patches/HudManagerPatch.cs
index f470522..50aea35 100644
--- a/Patches/HudManagerPatch.cs
+++ b/Patches/HudManagerPatch.cs
@@ -53,8 +53,29 @@ public class HudManagerPatch
if (gameStart != null)
gameStart.transform.SetLocalY(-2.8f);
- if (GameStates.InGame && __instance?.Chat?.gameObject.active != true)
- __instance.Chat.gameObject.SetActive(true);
+
+ // Set chat
+ if (GameStates.InGame)
+ {
+ if (!Main.ChatInGameplay.Value)
+ {
+ if (!PlayerControl.LocalPlayer.IsAlive())
+ {
+ __instance.Chat.gameObject.SetActive(true);
+ }
+ else if (GameStates.IsInGamePlay && !(GameStates.IsMeeting || GameStates.IsExilling))
+ {
+ __instance.Chat.gameObject.SetActive(false);
+ }
+ }
+ else
+ {
+ if (__instance?.Chat?.gameObject.active == false)
+ {
+ __instance.Chat.gameObject.SetActive(true);
+ }
+ }
+ }
}
catch { }
}
diff --git a/Patches/MainMenuPatch.cs b/Patches/MainMenuPatch.cs
index d9d1e11..c54a34e 100644
--- a/Patches/MainMenuPatch.cs
+++ b/Patches/MainMenuPatch.cs
@@ -99,7 +99,7 @@ internal class MainMenuPatch
bool Flag = __instance?.screenTint?.GetComponent() != null
&& !__instance.screenTint.GetComponent().enabled;
- foreach (var item in buttonsObj)
+ foreach (var item in buttonsObj)
{
item.SetActive(Flag);
}
diff --git a/Patches/MeetingHudPatch.cs b/Patches/MeetingHudPatch.cs
index b9a80f2..7ca3320 100644
--- a/Patches/MeetingHudPatch.cs
+++ b/Patches/MeetingHudPatch.cs
@@ -99,7 +99,7 @@ class MeetingHudUpdatePatch
case DisconnectReasons.Hacking:
DisconnectText = "Banned By Server";
break;
- default:
+ default:
DisconnectText = "Disconnected";
break;
}
diff --git a/Patches/ModManagerPatch.cs b/Patches/ModManagerPatch.cs
index 868d020..9d452c4 100644
--- a/Patches/ModManagerPatch.cs
+++ b/Patches/ModManagerPatch.cs
@@ -10,7 +10,10 @@ public class ModManagerPatch
[HarmonyPostfix]
public static void LateUpdate_Postfix(ModManager __instance)
{
- __instance.ShowModStamp();
+ if (SplashIntroPatch.IsReallyDoneLoading)
+ {
+ __instance.ShowModStamp();
+ }
if (__instance.ModStamp.gameObject.active == true)
__instance.ModStamp.GetComponent().sprite = Utils.LoadSprite("BetterAmongUs.Resources.Images.BetterAmongUs-Mod.png", 250f);
diff --git a/Patches/PlayerControlPatch.cs b/Patches/PlayerControlPatch.cs
index 313ad15..dbf63fb 100644
--- a/Patches/PlayerControlPatch.cs
+++ b/Patches/PlayerControlPatch.cs
@@ -1,9 +1,6 @@
using AmongUs.Data;
-using AmongUs.GameOptions;
using HarmonyLib;
-using Hazel;
using Il2CppSystem.Linq;
-using InnerNet;
using LibCpp2IL;
using System.Text;
using System.Text.RegularExpressions;
@@ -115,6 +112,14 @@ class PlayerControlPatch
{
friendCode = "No Friend Code";
friendCodeColor = "#ff0000";
+
+ if (GameStates.IsHost)
+ {
+ if (BetterGameSettings.InvalidFriendCode.GetBool())
+ {
+ player.Kick(true, "{0} by Anti-Cheat!\n Reason: Invalid Friend Code", true);
+ }
+ }
}
if (DataManager.Settings.Gameplay.StreamerMode == true)
{
diff --git a/Patches/PlayerJoinAndLeftPatch.cs b/Patches/PlayerJoinAndLeftPatch.cs
index 8784f25..17e9a4e 100644
--- a/Patches/PlayerJoinAndLeftPatch.cs
+++ b/Patches/PlayerJoinAndLeftPatch.cs
@@ -56,7 +56,7 @@ public static class OnPlayerJoinedPatch
client.Character.RpcSendHostChat(HudManagerPatch.WelcomeMessage, sendToBetterUser: false);
// Auto ban player on ban list
- if (Main.UseBannedList.Value)
+ if (BetterGameSettings.UseBanPlayerList.GetBool())
{
if (player != null)
{
@@ -77,34 +77,37 @@ public static class OnPlayerJoinedPatch
}
}
catch { }
-
- try
- {
- // Normalize and remove spaces and special characters from names
- Func normalizeName = name => new string(name.Where(c => char.IsLetterOrDigit(c)).ToArray()).ToLower();
-
- // Read all banned names into a HashSet with normalized names
- HashSet bannedNames = new HashSet(
- File.ReadLines(BetterDataManager.banNameListFile)
- .Select(normalizeName)
- .Where(name => !string.IsNullOrWhiteSpace(name))
- );
-
- string normalizedPlayerName = normalizeName(player.Data.PlayerName);
-
- // Check if any banned name is a prefix of the player's normalized name
- bool isNameBanned = bannedNames.Any(bannedName =>
- normalizedPlayerName.StartsWith(bannedName)
- );
-
- if (!string.IsNullOrEmpty(normalizedPlayerName) && isNameBanned)
- {
- player.Kick(false, $"has been kicked due to their name being on the ban name list!");
- }
- }
- catch { }
}
}
+
+ if (BetterGameSettings.UseBanNameList.GetBool())
+ {
+ try
+ {
+ // Normalize and remove spaces and special characters from names
+ Func normalizeName = name => new string(name.Where(c => char.IsLetterOrDigit(c)).ToArray()).ToLower();
+
+ // Read all banned names into a HashSet with normalized names
+ HashSet bannedNames = new HashSet(
+ File.ReadLines(BetterDataManager.banNameListFile)
+ .Select(normalizeName)
+ .Where(name => !string.IsNullOrWhiteSpace(name))
+ );
+
+ string normalizedPlayerName = normalizeName(player.Data.PlayerName);
+
+ // Check if any banned name is a prefix of the player's normalized name
+ bool isNameBanned = bannedNames.Any(bannedName =>
+ normalizedPlayerName.StartsWith(bannedName)
+ );
+
+ if (!string.IsNullOrEmpty(normalizedPlayerName) && isNameBanned)
+ {
+ player.Kick(false, $"has been kicked due to their name being on the ban name list!");
+ }
+ }
+ catch { }
+ }
}
}, 2.5f, "OnPlayerJoinedPatch", false);
}
diff --git a/Patches/RoleManagerPatch.cs b/Patches/RoleManagerPatch.cs
index fde5685..eb4ad5f 100644
--- a/Patches/RoleManagerPatch.cs
+++ b/Patches/RoleManagerPatch.cs
@@ -268,7 +268,7 @@ public class RoleManagerPatch
foreach (var addplayer in Main.AllPlayerControls.Where(pc => !ImpostorMultiplier.ContainsKey(Utils.GetHashPuid(pc))))
ImpostorMultiplier[Utils.GetHashPuid(addplayer)] = 0;
- int NumImpostors = 1;
+ int NumImpostors = BetterGameSettings.HideAndSeekImpNum.GetInt();
int NumPlayers = Main.AllPlayerControls.Length;
diff --git a/Patches/SplashIntroPatch.cs b/Patches/SplashIntroPatch.cs
new file mode 100644
index 0000000..2e1482c
--- /dev/null
+++ b/Patches/SplashIntroPatch.cs
@@ -0,0 +1,77 @@
+using HarmonyLib;
+using UnityEngine;
+
+namespace BetterAmongUs.Patches;
+
+class SplashIntroPatch
+{
+ public static bool BetterIntro = false;
+ public static bool IsReallyDoneLoading = false;
+ private static float ShowTime = 0f;
+ private static GameObject BetterLogo;
+
+ [HarmonyPatch(typeof(SplashManager))]
+ class SplashManagerPatch
+ {
+ [HarmonyPatch(nameof(SplashManager.Start))]
+ [HarmonyPrefix]
+ public static void Start_Prefix(SplashManager __instance)
+ {
+ __instance.logoAnimFinish.transform.Find("BlackOverlay").transform.SetLocalY(100f);
+ }
+
+ [HarmonyPatch(nameof(SplashManager.Update))]
+ [HarmonyPrefix]
+ public static bool Update_Prefix(SplashManager __instance)
+ {
+ ShowTime += Time.deltaTime;
+
+ if (ShowTime > 6f && BetterIntro)
+ {
+ UnityEngine.Object.Destroy(__instance.logoAnimFinish.GetComponent());
+ }
+
+ if (Input.GetKeyDown(KeyCode.Mouse0) || Input.GetKeyDown(KeyCode.Mouse1))
+ {
+ if (ShowTime > 1.5f)
+ {
+ __instance.StopAllCoroutines();
+ UnityEngine.Object.Destroy(__instance.logoAnimFinish.gameObject);
+ __instance.sceneChanger.AllowFinishLoadingScene();
+ __instance.startedSceneLoad = true;
+ __instance.loadingObject.SetActive(true);
+ IsReallyDoneLoading = true;
+ }
+ }
+
+ if (__instance.doneLoadingRefdata && !__instance.startedSceneLoad && Time.time - __instance.startTime > __instance.minimumSecondsBeforeSceneChange)
+ {
+ if (!BetterIntro)
+ {
+ __instance.startTime = Time.time;
+ __instance.logoAnimFinish.gameObject.SetActive(false);
+ __instance.logoAnimFinish.gameObject.SetActive(true);
+ GameObject InnerLogo = __instance.logoAnimFinish.transform.Find("LogoRoot/ISLogo").gameObject;
+ BetterLogo = UnityEngine.Object.Instantiate(InnerLogo, InnerLogo.transform.parent);
+ GameObject.Destroy(InnerLogo);
+ BetterLogo.name = "BetterLogo";
+ BetterLogo.GetComponent().sprite = Utils.LoadSprite("BetterAmongUs.Resources.Images.BetterAmongUs-Logo.png", 150f);
+ __instance.logoAnimFinish.transform.Find("BlackOverlay").transform.SetLocalY(0f);
+ }
+
+ __instance.startedSceneLoad = BetterIntro;
+ BetterIntro = true;
+
+ if (__instance.startedSceneLoad && BetterIntro)
+ {
+ __instance.sceneChanger.AllowFinishLoadingScene();
+ __instance.startedSceneLoad = true;
+ __instance.loadingObject.SetActive(true);
+ IsReallyDoneLoading = true;
+ }
+ }
+
+ return false;
+ }
+ }
+}
\ No newline at end of file
diff --git a/Patches/VersionShowerPatch.cs b/Patches/VersionShowerPatch.cs
index f952dfb..f3a489e 100644
--- a/Patches/VersionShowerPatch.cs
+++ b/Patches/VersionShowerPatch.cs
@@ -9,6 +9,6 @@ public class VersionShowerPatch
[HarmonyPostfix]
public static void Postfix(VersionShower __instance)
{
- __instance.text.text = $"♻BetterAmongUs♻ {Main.GetVersionText()} - " + __instance.text.text;
+ __instance.text.text = $"♻BetterAmongUs♻ {Main.GetVersionText()} - " + __instance.text.text;
}
}
diff --git a/main.cs b/main.cs
index 811c706..bbd2247 100644
--- a/main.cs
+++ b/main.cs
@@ -24,11 +24,11 @@ public class Main : BasePlugin
{
public const ReleaseTypes ReleaseBuildType = ReleaseTypes.Release;
public const string CanaryNum = "0";
- public const string HotfixNum = "2";
- public const bool IsHotFix = true;
+ public const string HotfixNum = "0";
+ public const bool IsHotFix = false;
public const string PluginGuid = "com.d1gq.betteramongus";
- public const string PluginVersion = "1.0.4";
- public const string ReleaseDate = "08.20.2024"; // mm/dd/yyyy
+ public const string PluginVersion = "1.1.0";
+ public const string ReleaseDate = "08.24.2024"; // mm/dd/yyyy
public const string Github = "https://github.com/D1GQ/BetterAmongUs-Public";
public const string Discord = "https://discord.gg/vjYrXpzNAn";
@@ -99,7 +99,7 @@ public class Main : BasePlugin
public static PlayerControl[] AllAlivePlayerControls => AllPlayerControls.ToArray().Where(pc => pc.IsAlive()).ToArray();
- public static Dictionary GetRoleName = new Dictionary
+ public static Dictionary GetRoleName => new Dictionary
{
{ 0, "Crewmate" },
{ 1, "Impostor" },
@@ -114,6 +114,21 @@ public class Main : BasePlugin
{ 10, "Tracker" }
};
+ public static Dictionary GetRoleColor => new Dictionary
+ {
+ { 0, "#8cffff" },
+ { 1, "#f00202" },
+ { 2, "#00d9d9" },
+ { 3, "#8f8f8f" },
+ { 4, "#8cffff" },
+ { 5, "#f06102" },
+ { 6, "#8cffff" },
+ { 7, "#f00202" },
+ { 8, "#fc7c7c" },
+ { 9, "#d100b9" },
+ { 10, "#59f002" }
+ };
+
public static ManualLogSource Logger;
public static DebugMenu debugmenu { get; set; } = null;
@@ -161,7 +176,7 @@ public class Main : BasePlugin
public static ConfigEntry BetterHost { get; private set; }
public static ConfigEntry BetterRoleAlgorithma { get; private set; }
public static ConfigEntry BetterNotifications { get; private set; }
- public static ConfigEntry UseBannedList { get; private set; }
+ public static ConfigEntry ChatInGameplay { get; private set; }
public static ConfigEntry LobbyPlayerInfo { get; private set; }
public static ConfigEntry DisableLobbyTheme { get; private set; }
public static ConfigEntry UnlockFPS { get; private set; }
@@ -173,7 +188,7 @@ public class Main : BasePlugin
BetterHost = Config.Bind("Better Options", "BetterHost", false);
BetterRoleAlgorithma = Config.Bind("Better Options", "BetterRoleAlgorithma", true);
BetterNotifications = Config.Bind("Better Options", "BetterNotifications", true);
- UseBannedList = Config.Bind("Better Options", "UseBannedList", true);
+ ChatInGameplay = Config.Bind("Better Options", "ChatInGameplay", true);
LobbyPlayerInfo = Config.Bind("Better Options", "LobbyPlayerInfo", true);
DisableLobbyTheme = Config.Bind("Better Options", "DisableLobbyTheme", true);
UnlockFPS = Config.Bind("Better Options", "UnlockFPS", false);