mirror of
https://github.com/D1GQ/BetterAmongUs.git
synced 2026-10-28 19:44:00 +00:00
add BAUModdedSupport to add the ability for other plugins to disable features
This commit is contained in:
1 parent
1546027de8
commit
ea5c1c618f
25 files changed
+325
-75
No files matched your search
+26
-18
@@ -126,24 +126,7 @@ internal class BAUPlugin : BasePlugin
|
||||
|
||||
SetupConsole();
|
||||
RegisterAllMonoBehavioursInAssembly();
|
||||
|
||||
GithubAPI.Connect();
|
||||
BetterDataManager.Init();
|
||||
LoadOptions();
|
||||
Translator.Init();
|
||||
Harmony.PatchAll();
|
||||
GameSettingsPatch.SetupSettings(true);
|
||||
InstanceAttribute.RegisterAll();
|
||||
OutfitData.Init();
|
||||
|
||||
if (File.Exists(Path.Combine(BetterDataManager.filePathFolder, "better-log.txt")))
|
||||
File.WriteAllText(Path.Combine(BetterDataManager.filePathFolder, "better-previous-log.txt"), File.ReadAllText(Path.Combine(BetterDataManager.filePathFolder, "better-log.txt")));
|
||||
|
||||
File.WriteAllText(Path.Combine(BetterDataManager.filePathFolder, "better-log.txt"), "");
|
||||
Logger_.Log("Better Among Us successfully loaded!");
|
||||
|
||||
string SupportedVersions = string.Join(" ", SupportedAmongUsVersions);
|
||||
Logger_.Log($"BetterAmongUs {BetterAmongUsVersion}-{ModInfo.BuildDate} - [{AppVersion} --> {SupportedVersions}] {Utils.GetPlatformName(PlatformData.Platform)}");
|
||||
IL2CPPChainloader.Instance.Finished += OnChainloaderFinished;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -151,6 +134,31 @@ internal class BAUPlugin : BasePlugin
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Runs when the BepInEx Chainloader has finished.
|
||||
/// </summary>
|
||||
private void OnChainloaderFinished()
|
||||
{
|
||||
BAUModdedSupport.Initialize();
|
||||
GithubAPI.Connect();
|
||||
BetterDataManager.Initialize();
|
||||
LoadOptions();
|
||||
Translator.Initialize();
|
||||
Harmony.PatchAll();
|
||||
GameSettingsPatch.SetupSettings(true);
|
||||
InstanceAttribute.RegisterAll();
|
||||
OutfitData.Initialize();
|
||||
|
||||
if (File.Exists(Path.Combine(BetterDataManager.filePathFolder, "better-log.txt")))
|
||||
File.WriteAllText(Path.Combine(BetterDataManager.filePathFolder, "better-previous-log.txt"), File.ReadAllText(Path.Combine(BetterDataManager.filePathFolder, "better-log.txt")));
|
||||
|
||||
File.WriteAllText(Path.Combine(BetterDataManager.filePathFolder, "better-log.txt"), "");
|
||||
Logger_.Log("Better Among Us successfully loaded!");
|
||||
|
||||
string SupportedVersions = string.Join(" ", SupportedAmongUsVersions);
|
||||
Logger_.Log($"BetterAmongUs {BetterAmongUsVersion}-{ModInfo.BuildDate} - [{AppVersion} --> {SupportedVersions}] {Utils.GetPlatformName(PlatformData.Platform)}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets up the console window for logging.
|
||||
/// </summary>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using BetterAmongUs.Attributes;
|
||||
using BetterAmongUs.Enums;
|
||||
using BetterAmongUs.Patches.Gameplay.UI.Chat;
|
||||
|
||||
namespace BetterAmongUs.Commands;
|
||||
|
||||
@@ -24,7 +25,7 @@ internal sealed class AllCommandsCommand : BaseCommand
|
||||
{
|
||||
if (i < allNormalCommands.Length)
|
||||
{
|
||||
list += $"\n{mid}<color=#e0b700><b>{BAUPlugin.CommandPrefix.Value}{allNormalCommands[i].Name}</b></color> <size=65%><color=#735e00>{allNormalCommands[i].Description}.</color></size>";
|
||||
list += $"\n{mid}<color=#e0b700><b>{ChatCommandsPatch.CommandPrefix}{allNormalCommands[i].Name}</b></color> <size=65%><color=#735e00>{allNormalCommands[i].Description}.</color></size>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using BetterAmongUs.Commands.Arguments;
|
||||
using BetterAmongUs.Attributes;
|
||||
using BetterAmongUs.Attributes;
|
||||
using BetterAmongUs.Commands.Arguments;
|
||||
using BetterAmongUs.Modules;
|
||||
|
||||
namespace BetterAmongUs.Commands;
|
||||
|
||||
@@ -16,10 +17,12 @@ internal sealed class SetPrefixCommand : BaseCommand
|
||||
}
|
||||
private StringArgument? prefixArgument { get; }
|
||||
|
||||
internal override bool ShowCommand() => !BAUModdedSupport.HasFlag(BAUModdedSupport.Force_BAU_Command_Prefix);
|
||||
|
||||
internal override void Run()
|
||||
{
|
||||
var oldPrefix = BAUPlugin.CommandPrefix.Value;
|
||||
var prefix = prefixArgument.Arg.ToCharArray().First().ToString();
|
||||
var prefix = prefixArgument.Arg.ToCharArray()?.First().ToString();
|
||||
if (!string.IsNullOrEmpty(prefix))
|
||||
{
|
||||
BAUPlugin.CommandPrefix.Value = prefix;
|
||||
|
||||
@@ -96,7 +96,7 @@ internal static class BetterDataManager
|
||||
/// <summary>
|
||||
/// Initializes the data manager, loading files and ensuring required directories exist.
|
||||
/// </summary>
|
||||
internal static void Init()
|
||||
internal static void Initialize()
|
||||
{
|
||||
BetterDataFile.Init();
|
||||
BetterGameSettingsFile.Init();
|
||||
|
||||
@@ -51,7 +51,7 @@ internal sealed class OutfitData
|
||||
/// <summary>
|
||||
/// Initializes the outfit data system and sets up change listeners.
|
||||
/// </summary>
|
||||
internal static void Init()
|
||||
internal static void Initialize()
|
||||
{
|
||||
FindPreset();
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using UnityEngine;
|
||||
using BetterAmongUs.Modules;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BetterAmongUs.Helpers;
|
||||
|
||||
@@ -111,6 +112,8 @@ internal static class ObjectHelper
|
||||
/// <param name="avoidGoName">Names of GameObjects to skip when applying colors.</param>
|
||||
internal static void SetUIColors(this GameObject go, Color? color = null, Func<SpriteRenderer, bool>? check = null, params string[] avoidGoName)
|
||||
{
|
||||
if (BAUModdedSupport.HasFlag(BAUModdedSupport.Disable_Theme)) return;
|
||||
|
||||
var sprites = go.GetComponentsInChildren<SpriteRenderer>(true);
|
||||
foreach (var sprite in sprites)
|
||||
{
|
||||
@@ -127,6 +130,8 @@ internal static class ObjectHelper
|
||||
/// <param name="color">The color to blend (defaults to green if null).</param>
|
||||
internal static void AddColor(SpriteRenderer sprite, Color? color = null)
|
||||
{
|
||||
if (BAUModdedSupport.HasFlag(BAUModdedSupport.Disable_Theme)) return;
|
||||
|
||||
color ??= Color.green;
|
||||
sprite.color = (sprite.color * 0.6f) + ((Color)color * 0.5f);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using BepInEx.Unity.IL2CPP.Utils;
|
||||
using BetterAmongUs.Helpers;
|
||||
using BetterAmongUs.Modules;
|
||||
using BetterAmongUs.Network.Loaders;
|
||||
using Il2CppInterop.Runtime.Attributes;
|
||||
using System.Collections;
|
||||
@@ -41,6 +42,8 @@ internal sealed class UpdateManager : MonoBehaviour
|
||||
/// </summary>
|
||||
internal void OnMainMenu()
|
||||
{
|
||||
if (BAUModdedSupport.HasFlag(BAUModdedSupport.Disable_ModUpdate)) return;
|
||||
|
||||
var doNotPress = FindObjectOfType<DoNotPressButton>(true);
|
||||
if (doNotPress != null)
|
||||
{
|
||||
|
||||
@@ -71,7 +71,7 @@ internal static class BetterAntiCheat
|
||||
[HarmonyPostfix]
|
||||
internal static void Deserialize_Postfix(PlatformSpecificData __instance)
|
||||
{
|
||||
if (!BAUPlugin.AntiCheat.Value || !GameState.IsVanillaServer) return;
|
||||
if (!BAUPlugin.AntiCheat.Value || BAUModdedSupport.HasFlag(BAUModdedSupport.Disable_Anticheat) || !GameState.IsVanillaServer) return;
|
||||
|
||||
if (GameState.IsLobby)
|
||||
{
|
||||
@@ -149,7 +149,7 @@ internal static class BetterAntiCheat
|
||||
internal static void CheckRPC(PlayerControl player, byte callId, MessageReader oldReader)
|
||||
{
|
||||
if (player == null || player?.Data == null) return;
|
||||
if (!IsEnabled || !BAUPlugin.AntiCheat.Value || !BetterGameSettings.DetectInvalidRPCs.GetBool()) return;
|
||||
if (!IsEnabled || !BAUPlugin.AntiCheat.Value || BAUModdedSupport.HasFlag(BAUModdedSupport.Disable_Anticheat) || !BetterGameSettings.DetectInvalidRPCs.GetBool()) return;
|
||||
if (player.IsLocalPlayer() && player.IsHost()) return;
|
||||
|
||||
MessageReader reader = MessageReader.Get(oldReader);
|
||||
@@ -169,7 +169,7 @@ internal static class BetterAntiCheat
|
||||
try
|
||||
{
|
||||
if (player == null || player?.Data == null) return true;
|
||||
if (!IsEnabled || !BAUPlugin.AntiCheat.Value || !BetterGameSettings.DetectInvalidRPCs.GetBool()) return true;
|
||||
if (!IsEnabled || !BAUPlugin.AntiCheat.Value || BAUModdedSupport.HasFlag(BAUModdedSupport.Disable_Anticheat) || !BetterGameSettings.DetectInvalidRPCs.GetBool()) return true;
|
||||
if (player.IsLocalPlayer() && player.IsHost()) return true;
|
||||
|
||||
MessageReader reader = MessageReader.Get(oldReader);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using BetterAmongUs.Attributes;
|
||||
using BetterAmongUs.Data;
|
||||
using BetterAmongUs.Enums;
|
||||
using BetterAmongUs.Helpers;
|
||||
using BetterAmongUs.Attributes;
|
||||
using BetterAmongUs.Managers;
|
||||
using BetterAmongUs.Mono;
|
||||
using BetterAmongUs.Patches.Gameplay.UI.Settings;
|
||||
@@ -30,7 +30,7 @@ internal sealed class AUMChatHandler : RPCHandler
|
||||
|
||||
Logger_.Log($"{sender.Data.PlayerName} -> {msgString}", "AUMChatLog");
|
||||
|
||||
if (!BAUPlugin.AntiCheat.Value || !BetterGameSettings.DetectCheatClients.GetBool()) return;
|
||||
if (!BAUPlugin.AntiCheat.Value || BAUModdedSupport.HasFlag(BAUModdedSupport.Disable_Anticheat) || !BetterGameSettings.DetectCheatClients.GetBool()) return;
|
||||
|
||||
var flag = string.IsNullOrEmpty(nameString) && string.IsNullOrEmpty(msgString);
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using BetterAmongUs.Attributes;
|
||||
using BetterAmongUs.Data;
|
||||
using BetterAmongUs.Enums;
|
||||
using BetterAmongUs.Helpers;
|
||||
using BetterAmongUs.Attributes;
|
||||
using BetterAmongUs.Managers;
|
||||
using BetterAmongUs.Mono;
|
||||
using BetterAmongUs.Patches.Gameplay.UI.Settings;
|
||||
@@ -17,7 +17,7 @@ internal sealed class AUMHandler : RPCHandler
|
||||
|
||||
internal override void HandleCheatRpcCheck(PlayerControl? sender, MessageReader reader)
|
||||
{
|
||||
if (BAUPlugin.AntiCheat.Value && BetterGameSettings.DetectCheatClients.GetBool())
|
||||
if (BAUPlugin.AntiCheat.Value && !BAUModdedSupport.HasFlag(BAUModdedSupport.Disable_Anticheat) && BetterGameSettings.DetectCheatClients.GetBool())
|
||||
{
|
||||
var aumid = reader.ReadByte();
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using BetterAmongUs.Attributes;
|
||||
using BetterAmongUs.Data;
|
||||
using BetterAmongUs.Enums;
|
||||
using BetterAmongUs.Helpers;
|
||||
using BetterAmongUs.Attributes;
|
||||
using BetterAmongUs.Managers;
|
||||
using BetterAmongUs.Mono;
|
||||
using BetterAmongUs.Patches.Gameplay.UI.Settings;
|
||||
@@ -17,7 +17,7 @@ internal sealed class KillNetworkChatHandler : RPCHandler
|
||||
|
||||
internal override void HandleCheatRpcCheck(PlayerControl? sender, MessageReader reader)
|
||||
{
|
||||
if (!BAUPlugin.AntiCheat.Value || !BetterGameSettings.DetectCheatClients.GetBool()) return;
|
||||
if (!BAUPlugin.AntiCheat.Value || BAUModdedSupport.HasFlag(BAUModdedSupport.Disable_Anticheat) || !BetterGameSettings.DetectCheatClients.GetBool()) return;
|
||||
|
||||
if (!BetterDataManager.BetterDataFile.KNData.Any(info => info.CheckPlayerData(sender.Data)))
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using BetterAmongUs.Attributes;
|
||||
using BetterAmongUs.Data;
|
||||
using BetterAmongUs.Enums;
|
||||
using BetterAmongUs.Helpers;
|
||||
using BetterAmongUs.Attributes;
|
||||
using BetterAmongUs.Managers;
|
||||
using BetterAmongUs.Mono;
|
||||
using BetterAmongUs.Patches.Gameplay.UI.Settings;
|
||||
@@ -17,7 +17,7 @@ internal sealed class KillNetworkHandler : RPCHandler
|
||||
|
||||
internal override void HandleCheatRpcCheck(PlayerControl? sender, MessageReader reader)
|
||||
{
|
||||
if (BAUPlugin.AntiCheat.Value && BetterGameSettings.DetectCheatClients.GetBool())
|
||||
if (BAUPlugin.AntiCheat.Value && !BAUModdedSupport.HasFlag(BAUModdedSupport.Disable_Anticheat) && BetterGameSettings.DetectCheatClients.GetBool())
|
||||
{
|
||||
if (!BetterDataManager.BetterDataFile.KNData.Any(info => info.CheckPlayerData(sender.Data)))
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using BetterAmongUs.Attributes;
|
||||
using BetterAmongUs.Data;
|
||||
using BetterAmongUs.Enums;
|
||||
using BetterAmongUs.Helpers;
|
||||
using BetterAmongUs.Attributes;
|
||||
using BetterAmongUs.Managers;
|
||||
using BetterAmongUs.Mono;
|
||||
using BetterAmongUs.Patches.Gameplay.UI.Settings;
|
||||
@@ -17,7 +17,7 @@ internal sealed class SickoHandler : RPCHandler
|
||||
|
||||
internal override void HandleCheatRpcCheck(PlayerControl? sender, MessageReader reader)
|
||||
{
|
||||
if (BAUPlugin.AntiCheat.Value && BetterGameSettings.DetectCheatClients.GetBool())
|
||||
if (BAUPlugin.AntiCheat.Value && !BAUModdedSupport.HasFlag(BAUModdedSupport.Disable_Anticheat) && BetterGameSettings.DetectCheatClients.GetBool())
|
||||
{
|
||||
if (reader.BytesRemaining == 0 && !BetterDataManager.BetterDataFile.SickoData.Any(info => info.CheckPlayerData(sender.Data)))
|
||||
{
|
||||
|
||||
@@ -0,0 +1,176 @@
|
||||
#pragma warning disable CA2211
|
||||
|
||||
using BepInEx;
|
||||
using BepInEx.Unity.IL2CPP;
|
||||
using BetterAmongUs.Helpers;
|
||||
using System.Reflection;
|
||||
|
||||
namespace BetterAmongUs.Modules;
|
||||
|
||||
/// <summary>
|
||||
/// Provides modded support functionality for BetterAmongUs by allowing other mods to declare flags
|
||||
/// that control various features and behaviors of BetterAmongUs.
|
||||
/// </summary>
|
||||
public static class BAUModdedSupport
|
||||
{
|
||||
// ============================================
|
||||
// Client Features - General
|
||||
// ============================================
|
||||
|
||||
/// <summary>
|
||||
/// Flag to disable the anticheat system. When set by another mod, BetterAmongUs will disable its anticheat features.
|
||||
/// </summary>
|
||||
public static string Disable_Anticheat = "client.disable.anticheat";
|
||||
|
||||
/// <summary>
|
||||
/// Flag to disable the Better Ping Tracker feature. When set by another mod, BetterAmongUs will not patch out the normal ping tracker.
|
||||
/// </summary>
|
||||
public static string Disable_BetterPingTracker = "client.disable.betterpingtracker";
|
||||
|
||||
/// <summary>
|
||||
/// Flag to disable the Private Lobby feature. When set by another mod, BetterAmongUs will disable private only lobbies.
|
||||
/// </summary>
|
||||
public static string Disable_PrivateLobby = "client.disable.privatelobby";
|
||||
|
||||
/// <summary>
|
||||
/// Flag to disable theme. When set by another mod, BetterAmongUs will disable its theming features.
|
||||
/// </summary>
|
||||
public static string Disable_Theme = "client.disable.theme";
|
||||
|
||||
/// <summary>
|
||||
/// Flag to disable custom mod stamp sprite. When set by another mod, BetterAmongUs will disable its custom mod stamp sprite.
|
||||
/// </summary>
|
||||
public static string Disable_CustomModStamp = "client.disable.custommodstamp";
|
||||
|
||||
// ============================================
|
||||
// Client Features - Command System
|
||||
// ============================================
|
||||
|
||||
/// <summary>
|
||||
/// Flag to disable command system. When set by another mod, BetterAmongUs will disable its command features.
|
||||
/// </summary>
|
||||
public static string Disable_AllCommands = "command.disable.allcommands";
|
||||
|
||||
/// <summary>
|
||||
/// Flag prefix to disable specific commands. The full flag should be "client.disable=COMMAND_NAME".
|
||||
/// When set by another mod, BetterAmongUs will disable the specified command.
|
||||
/// </summary>
|
||||
public static string Disable_Command = "command.disable=";
|
||||
|
||||
/// <summary>
|
||||
/// Flag prefix for forcing the command prefix for BAU to be "bau:"
|
||||
/// </summary>
|
||||
public static string Force_BAU_Command_Prefix = "command.force.bau.prefix";
|
||||
|
||||
// ============================================
|
||||
// Client Features - Game Settings
|
||||
// ============================================
|
||||
|
||||
/// <summary>
|
||||
/// Flag to disable game settings modifications. When set by another mod, BetterAmongUs will not modify game settings.
|
||||
/// </summary>
|
||||
public static string Disable_AllGameSettings = "gamesetting.disable.allgamesettings";
|
||||
|
||||
/// <summary>
|
||||
/// Flag prefix to disable specific game setting. The full flag should be "client.disable=TRANSLATION_NAME".
|
||||
/// When set by another mod, BetterAmongUs will disable the specified game setting and uses default value.
|
||||
/// </summary>
|
||||
public static string Disable_GameSetting = "gamesetting.disable=";
|
||||
|
||||
// ============================================
|
||||
// Lobby Features
|
||||
// ============================================
|
||||
|
||||
/// <summary>
|
||||
/// Flag to disable cancel starting game. When set by another mod, BetterAmongUs will not patch start game button.
|
||||
/// </summary>
|
||||
public static string Disable_CancelStartingGame = "lobby.disable.cancelstartinggame";
|
||||
|
||||
// ============================================
|
||||
// Main Menu Features
|
||||
// ============================================
|
||||
|
||||
/// <summary>
|
||||
/// Flag to disable mod update button. When set by another mod, BetterAmongUs will not show update button in the main menu.
|
||||
/// </summary>
|
||||
public static string Disable_ModUpdate = "mainmenu.disable.modupdate";
|
||||
|
||||
/// <summary>
|
||||
/// Flag to disable the BetterAmongUs logo in the main menu. When set by another mod, BetterAmongUs will hide its logo.
|
||||
/// </summary>
|
||||
public static string Disable_BAULogo = "mainmenu.disable.baulogo";
|
||||
|
||||
private static readonly HashSet<string> _flags = [];
|
||||
private static bool _initialized = false;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the modded support system.
|
||||
/// </summary>
|
||||
internal static void Initialize()
|
||||
{
|
||||
if (_initialized) return;
|
||||
_initialized = true;
|
||||
foreach (var pluginInfo in IL2CPPChainloader.Instance.Plugins.Values)
|
||||
{
|
||||
TryGetFlags((BasePlugin)pluginInfo.Instance);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to extract BAUFlags from a loaded plugin's fields.
|
||||
/// This method is called automatically when a new plugin is loaded.
|
||||
/// </summary>
|
||||
/// <param name="plugin">The plugin instance that was loaded.</param>
|
||||
private static void TryGetFlags(BasePlugin plugin)
|
||||
{
|
||||
foreach (var field in plugin.GetType().GetFields())
|
||||
{
|
||||
if (field.Name == "BAUFlags")
|
||||
{
|
||||
var value = field.IsStatic
|
||||
? field.GetValue(null)
|
||||
: field.GetValue(plugin);
|
||||
|
||||
IEnumerable<string>? strings = null;
|
||||
if (value is string[] strArray)
|
||||
{
|
||||
strings = strArray;
|
||||
}
|
||||
else if (value is List<string> strList)
|
||||
{
|
||||
strings = strList;
|
||||
}
|
||||
|
||||
if (strings == null) return;
|
||||
|
||||
foreach (var flag in strings)
|
||||
{
|
||||
if (!_flags.Contains(flag))
|
||||
{
|
||||
Logger_.Log($"Loaded '{flag}' flag from {plugin.GetType().GetCustomAttribute<BepInPlugin>().Name}", "BAUModdedSupport");
|
||||
AddFlag(flag);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Manually adds a flag to the internal flag collection.
|
||||
/// </summary>
|
||||
/// <param name="flag">The flag string to add to the collection.</param>
|
||||
internal static void AddFlag(string flag)
|
||||
{
|
||||
_flags.Add(flag);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if a specific flag has been declared by any loaded mod.
|
||||
/// </summary>
|
||||
/// <param name="flag">The flag to check for presence in the collected flags.</param>
|
||||
/// <returns>True if the flag is present, false otherwise.</returns>
|
||||
internal static bool HasFlag(string flag)
|
||||
{
|
||||
return _flags.Contains(flag);
|
||||
}
|
||||
}
|
||||
@@ -30,7 +30,7 @@ internal abstract class OptionItem
|
||||
internal virtual bool Show => ShowCondition.Invoke();
|
||||
internal virtual bool ShowChildren => Show;
|
||||
internal Func<bool>? ShowCondition = () => { return true; };
|
||||
internal bool Hide => !Show || GetParents().Any(opt => !opt.ShowChildren);
|
||||
internal bool Hide => !Show || GetParents().Any(opt => !opt.ShowChildren) || BAUModdedSupport.HasFlag(BAUModdedSupport.Disable_GameSetting + Translation);
|
||||
internal static OptionItem? GetOptionById(int id) => AllTBROptions.FirstOrDefault(opt => opt._id == id);
|
||||
internal virtual void UpdateVisuals(bool updateTabVisuals = true) { }
|
||||
internal abstract string ValueAsString();
|
||||
@@ -430,7 +430,15 @@ internal abstract class OptionItem<T> : OptionItem
|
||||
private bool HasLoadValue { get; set; }
|
||||
protected T? Value { get; set; } = default;
|
||||
protected T? DefaultValue { get; set; } = default;
|
||||
internal virtual T? GetValue() => Value;
|
||||
internal virtual T? GetValue()
|
||||
{
|
||||
if (BAUModdedSupport.HasFlag(BAUModdedSupport.Disable_GameSetting + Translation))
|
||||
{
|
||||
return DefaultValue;
|
||||
}
|
||||
|
||||
return Value;
|
||||
}
|
||||
internal virtual T? GetDefaultValue() => DefaultValue;
|
||||
internal override string ValueAsString() => Value?.ToString() ?? string.Empty;
|
||||
internal override void SetToDefault()
|
||||
|
||||
@@ -18,7 +18,7 @@ internal static class Translator
|
||||
/// <summary>
|
||||
/// Initializes the translator by loading all language files from embedded resources.
|
||||
/// </summary>
|
||||
internal static void Init()
|
||||
internal static void Initialize()
|
||||
{
|
||||
Logger_.Log("Loading language files...", "Translator");
|
||||
LoadLanguages();
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using BetterAmongUs.Helpers;
|
||||
using BetterAmongUs.Managers;
|
||||
using BetterAmongUs.Modules;
|
||||
using HarmonyLib;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -24,11 +25,6 @@ internal static class MainMenuManagerPatch
|
||||
},
|
||||
"Icon", "Background");
|
||||
}
|
||||
|
||||
/*
|
||||
bool Flag = __instance?.screenTint?.GetComponent<SpriteRenderer>() != null
|
||||
&& !__instance.screenTint.GetComponent<SpriteRenderer>().enabled;
|
||||
*/
|
||||
}
|
||||
|
||||
// Replace AU logo with BAU logo
|
||||
@@ -36,12 +32,15 @@ internal static class MainMenuManagerPatch
|
||||
[HarmonyPostfix]
|
||||
private static void MainMenuManager_Start_Postfix(MainMenuManager __instance)
|
||||
{
|
||||
GameObject logo = GameObject.Find("LeftPanel/Sizer/LOGO-AU");
|
||||
GameObject sizer = logo.transform.parent.gameObject;
|
||||
sizer.transform.localPosition = new Vector3(sizer.transform.localPosition.x, sizer.transform.localPosition.y - 0.035f, sizer.transform.localPosition.z);
|
||||
sizer.transform.position = new Vector3(sizer.transform.position.x, sizer.transform.position.y, -0.5f);
|
||||
logo.transform.localScale = new Vector3(0.003f, 0.0025f, 0f);
|
||||
logo.GetComponent<SpriteRenderer>().sprite = Utils.LoadSprite("BetterAmongUs.Resources.Images.BetterAmongUs-Logo.png", 1f);
|
||||
if (!BAUModdedSupport.HasFlag(BAUModdedSupport.Disable_BAULogo))
|
||||
{
|
||||
GameObject logo = GameObject.Find("LeftPanel/Sizer/LOGO-AU");
|
||||
GameObject sizer = logo.transform.parent.gameObject;
|
||||
sizer.transform.localPosition = new Vector3(sizer.transform.localPosition.x, sizer.transform.localPosition.y - 0.035f, sizer.transform.localPosition.z);
|
||||
sizer.transform.position = new Vector3(sizer.transform.position.x, sizer.transform.position.y, -0.5f);
|
||||
logo.transform.localScale = new Vector3(0.003f, 0.0025f, 0f);
|
||||
logo.GetComponent<SpriteRenderer>().sprite = Utils.LoadSprite("BetterAmongUs.Resources.Images.BetterAmongUs-Logo.png", 1f);
|
||||
}
|
||||
|
||||
__instance.transform.Find("MainUI/AspectScaler/BackgroundTexture")?.gameObject?.SetSpriteColors(sprite => ObjectHelper.AddColor(sprite));
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using BetterAmongUs.Helpers;
|
||||
using BetterAmongUs.Managers;
|
||||
using BetterAmongUs.Modules;
|
||||
using BetterAmongUs.Modules.AntiCheat;
|
||||
using HarmonyLib;
|
||||
using UnityEngine;
|
||||
@@ -9,6 +10,8 @@ namespace BetterAmongUs.Patches.Client.Managers;
|
||||
[HarmonyPatch]
|
||||
internal static class ModManagerPatch
|
||||
{
|
||||
private static SpriteRenderer? modStamp;
|
||||
|
||||
[HarmonyPatch(typeof(ModManager), nameof(ModManager.LateUpdate))]
|
||||
[HarmonyPostfix]
|
||||
private static void LateUpdate_Postfix(ModManager __instance)
|
||||
@@ -19,7 +22,19 @@ internal static class ModManagerPatch
|
||||
}
|
||||
|
||||
if (__instance.ModStamp.gameObject.active == true)
|
||||
__instance.ModStamp.GetComponent<SpriteRenderer>().sprite = Utils.LoadSprite("BetterAmongUs.Resources.Images.BetterAmongUs-Mod.png", 250f);
|
||||
{
|
||||
if (modStamp == null)
|
||||
{
|
||||
modStamp = __instance.ModStamp.GetComponent<SpriteRenderer>();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!BAUModdedSupport.HasFlag(BAUModdedSupport.Disable_CustomModStamp))
|
||||
{
|
||||
modStamp.sprite = Utils.LoadSprite("BetterAmongUs.Resources.Images.BetterAmongUs-Mod.png", 250f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BetterAntiCheat.Update();
|
||||
LateTask.UpdateAll(Time.deltaTime);
|
||||
|
||||
@@ -17,6 +17,12 @@ internal static class PrivateLobbyPatch
|
||||
[HarmonyPostfix]
|
||||
private static void CreateGameOptions_Show_Postfix(CreateGameOptions __instance)
|
||||
{
|
||||
if (BAUModdedSupport.HasFlag(BAUModdedSupport.Disable_PrivateLobby))
|
||||
{
|
||||
BAUPlugin.PrivateOnlyLobby.Value = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (toggle != null) return;
|
||||
buttons.Clear();
|
||||
|
||||
|
||||
@@ -55,8 +55,11 @@ internal static class LobbyPatch
|
||||
__instance.ClientViewButton?.gameObject?.SetUIColors("Icon");
|
||||
__instance.HostViewButton?.gameObject?.SetUIColors("Icon");
|
||||
|
||||
__instance.StartButton?.transform?.SetParent(__instance.HostInfoPanel?.transform);
|
||||
__instance.StartButtonClient?.transform?.SetParent(__instance.HostInfoPanel?.transform);
|
||||
if (!BAUModdedSupport.HasFlag(BAUModdedSupport.Disable_BetterPingTracker))
|
||||
{
|
||||
__instance.StartButton?.transform?.SetParent(__instance.HostInfoPanel?.transform);
|
||||
__instance.StartButtonClient?.transform?.SetParent(__instance.HostInfoPanel?.transform);
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(GameStartManager), nameof(GameStartManager.Update))]
|
||||
@@ -75,6 +78,8 @@ internal static class LobbyPatch
|
||||
[HarmonyPostfix]
|
||||
private static void GameStartManager_Update_Postfix(GameStartManager __instance)
|
||||
{
|
||||
if (BAUModdedSupport.HasFlag(BAUModdedSupport.Disable_CancelStartingGame)) return;
|
||||
|
||||
if (!GameState.IsHost)
|
||||
{
|
||||
__instance.StartButton.gameObject.SetActive(false);
|
||||
@@ -97,6 +102,8 @@ internal static class LobbyPatch
|
||||
[HarmonyPrefix]
|
||||
private static bool GameStartManager_BeginGame_Prefix(GameStartManager __instance)
|
||||
{
|
||||
if (BAUModdedSupport.HasFlag(BAUModdedSupport.Disable_CancelStartingGame)) return true;
|
||||
|
||||
if (__instance.startState == GameStartManager.StartingStates.Countdown)
|
||||
{
|
||||
SoundManager.instance.StopSound(__instance.gameStartSound);
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace BetterAmongUs.Patches.Gameplay.UI.Chat;
|
||||
internal static class ChatCommandsPatch
|
||||
{
|
||||
private static bool _enabled = true;
|
||||
internal static string CommandPrefix => BAUPlugin.CommandPrefix.Value;
|
||||
internal static string CommandPrefix => BAUModdedSupport.HasFlag(BAUModdedSupport.Force_BAU_Command_Prefix) ? "bau:" : BAUPlugin.CommandPrefix.Value;
|
||||
|
||||
// Run code for specific commands
|
||||
private static void HandleCommand()
|
||||
@@ -32,7 +32,7 @@ internal static class ChatCommandsPatch
|
||||
[HarmonyPrefix]
|
||||
private static bool ChatController_SendChat_Prefix(ChatController __instance)
|
||||
{
|
||||
if (!_enabled)
|
||||
if (!_enabled || BAUModdedSupport.HasFlag(BAUModdedSupport.Disable_AllCommands))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -111,7 +111,7 @@ internal static class ChatCommandsPatch
|
||||
[HarmonyPostfix]
|
||||
private static void ChatController_Update_Postfix(ChatController __instance)
|
||||
{
|
||||
if (!_enabled)
|
||||
if (!_enabled || BAUModdedSupport.HasFlag(BAUModdedSupport.Disable_AllCommands))
|
||||
{
|
||||
ClearCommandDisplay();
|
||||
return;
|
||||
@@ -124,7 +124,7 @@ internal static class ChatCommandsPatch
|
||||
|
||||
if (text.Length > 0 && text.StartsWith(CommandPrefix))
|
||||
{
|
||||
typedCommand = text.Length > 1 ? text[1..] : string.Empty;
|
||||
typedCommand = text.Length > CommandPrefix.Length ? text[CommandPrefix.Length..] : string.Empty;
|
||||
string[] typedParts = typedCommand.Split(' ');
|
||||
|
||||
closestCommand = GetClosestCommand(typedParts[0]);
|
||||
@@ -150,8 +150,8 @@ internal static class ChatCommandsPatch
|
||||
private static void ClearCommandDisplay()
|
||||
{
|
||||
isTypedOut = false;
|
||||
commandText.GetComponent<TextMeshPro>().text = string.Empty;
|
||||
commandInfo.GetComponent<TextMeshPro>().text = string.Empty;
|
||||
commandText.text = string.Empty;
|
||||
commandInfo.text = string.Empty;
|
||||
}
|
||||
|
||||
private static void HandleValidSuggestion(ChatController __instance, string[] typedParts)
|
||||
@@ -193,10 +193,7 @@ internal static class ChatCommandsPatch
|
||||
{
|
||||
for (int i = 1; i < typedParts.Length && i <= closestCommand.Arguments.Length; i++)
|
||||
{
|
||||
if (closestCommand.Arguments[i - 1] != null)
|
||||
{
|
||||
closestCommand.Arguments[i - 1].Arg = typedParts[i];
|
||||
}
|
||||
closestCommand.Arguments[i - 1]?.Arg = typedParts[i];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -213,20 +210,23 @@ internal static class ChatCommandsPatch
|
||||
internal static BaseCommand? GetClosestCommand(string typedCommand)
|
||||
{
|
||||
var directNormalMatch = BaseCommand.allCommands
|
||||
.FirstOrDefault(c => c.Type == CommandType.Normal
|
||||
&& c.Names.Any(name => string.Equals(name, typedCommand, StringComparison.OrdinalIgnoreCase))
|
||||
&& c.ShowCommand());
|
||||
.FirstOrDefault(c => FilterCommand(c, CommandType.Normal) &&
|
||||
c.Names.Any(name => string.Equals(name, typedCommand, StringComparison.OrdinalIgnoreCase)));
|
||||
if (directNormalMatch != null)
|
||||
return directNormalMatch;
|
||||
|
||||
var closestNormalCommand = BaseCommand.allCommands
|
||||
.OrderBy(c => c.Name)
|
||||
.FirstOrDefault(c => c.Type == CommandType.Normal
|
||||
&& c.Names.Any(name => name.StartsWith(typedCommand, StringComparison.OrdinalIgnoreCase))
|
||||
&& c.ShowCommand());
|
||||
.FirstOrDefault(c => FilterCommand(c, CommandType.Normal) &&
|
||||
c.Names.Any(name => name.StartsWith(typedCommand, StringComparison.OrdinalIgnoreCase)));
|
||||
if (closestNormalCommand != null)
|
||||
return closestNormalCommand;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static bool FilterCommand(BaseCommand command, CommandType commandType)
|
||||
{
|
||||
return command.Type == commandType && command.ShowCommand() && !BAUModdedSupport.HasFlag(BAUModdedSupport.Disable_Command + command.Name);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using HarmonyLib;
|
||||
using BetterAmongUs.Modules;
|
||||
using HarmonyLib;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BetterAmongUs.Patches.Gameplay.UI.Chat;
|
||||
@@ -10,6 +11,8 @@ internal static class ChatNotificationPatch
|
||||
[HarmonyPostfix]
|
||||
private static void ChatNotification_SetUp_Postfix(ChatNotification __instance)
|
||||
{
|
||||
if (BAUModdedSupport.HasFlag(BAUModdedSupport.Disable_BetterPingTracker)) return;
|
||||
|
||||
__instance.GetComponent<AspectPosition>().DistanceFromEdge = new Vector3(-2.8f, 0.3f, -40f);
|
||||
__instance.transform.localScale = new Vector3(0.45f, 0.42f, 1f);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using BetterAmongUs.Mono;
|
||||
using BetterAmongUs.Modules;
|
||||
using BetterAmongUs.Mono;
|
||||
using HarmonyLib;
|
||||
|
||||
namespace BetterAmongUs.Patches.Gameplay.UI;
|
||||
@@ -10,6 +11,8 @@ internal static class PingTrackerPatch
|
||||
[HarmonyPrefix]
|
||||
private static bool PingTracker_Update_Prefix(PingTracker __instance)
|
||||
{
|
||||
if (BAUModdedSupport.HasFlag(BAUModdedSupport.Disable_BetterPingTracker)) return true;
|
||||
|
||||
var betterPingTracker = __instance.gameObject.AddComponent<BetterPingTracker>();
|
||||
betterPingTracker.SetUp(__instance.text, __instance.aspectPosition);
|
||||
__instance.enabled = false;
|
||||
|
||||
@@ -127,6 +127,8 @@ internal static class GameSettingsPatch
|
||||
[HarmonyPostfix]
|
||||
private static void GameSettingMenu_Start_Postfix(GameSettingMenu __instance)
|
||||
{
|
||||
if (BAUModdedSupport.HasFlag(BAUModdedSupport.Disable_AllGameSettings)) return;
|
||||
|
||||
SetupSettings();
|
||||
|
||||
__instance.gameObject.transform.SetLocalY(-0.1f);
|
||||
@@ -170,6 +172,8 @@ internal static class GameSettingsPatch
|
||||
[HarmonyPrefix]
|
||||
private static void GameSettingMenu_ChangeTab_Prefix(GameSettingMenu __instance, [HarmonyArgument(0)] int tabNum, [HarmonyArgument(1)] bool previewOnly)
|
||||
{
|
||||
if (BAUModdedSupport.HasFlag(BAUModdedSupport.Disable_AllGameSettings)) return;
|
||||
|
||||
if (BetterSettingsTab == null) return;
|
||||
|
||||
BetterSettingsTab.AUTab?.gameObject?.SetActive(false);
|
||||
@@ -192,7 +196,9 @@ internal static class GameSettingsPatch
|
||||
[HarmonyPrefix]
|
||||
private static bool GameOptionsMenu_CreateSettings_Prefix(GameOptionsMenu __instance)
|
||||
{
|
||||
if (__instance == GameSettingsPatch.BetterSettingsTab.AUTab)
|
||||
if (BAUModdedSupport.HasFlag(BAUModdedSupport.Disable_AllGameSettings)) return true;
|
||||
|
||||
if (__instance == BetterSettingsTab.AUTab)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -204,6 +210,8 @@ internal static class GameSettingsPatch
|
||||
[HarmonyPrefix]
|
||||
private static void OptionsConsole_CanUse_Prefix(OptionsConsole __instance)
|
||||
{
|
||||
if (BAUModdedSupport.HasFlag(BAUModdedSupport.Disable_AllGameSettings)) return;
|
||||
|
||||
__instance.HostOnly = false;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using HarmonyLib;
|
||||
using BetterAmongUs.Modules;
|
||||
using HarmonyLib;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BetterAmongUs.Patches.Gameplay.UI.Settings;
|
||||
@@ -10,6 +11,8 @@ internal static class NumberOptionPatch
|
||||
[HarmonyPrefix]
|
||||
private static bool NumberOption_Increase_Prefix(NumberOption __instance)
|
||||
{
|
||||
if (BAUModdedSupport.HasFlag(BAUModdedSupport.Disable_AllGameSettings)) return true;
|
||||
|
||||
int times = 1;
|
||||
if (Input.GetKey(KeyCode.LeftShift))
|
||||
times = 5;
|
||||
@@ -34,6 +37,8 @@ internal static class NumberOptionPatch
|
||||
[HarmonyPrefix]
|
||||
private static bool NumberOption_Decrease_Prefix(NumberOption __instance)
|
||||
{
|
||||
if (BAUModdedSupport.HasFlag(BAUModdedSupport.Disable_AllGameSettings)) return true;
|
||||
|
||||
int times = 1;
|
||||
if (Input.GetKey(KeyCode.LeftShift))
|
||||
times = 5;
|
||||
|
||||
Reference in new issue
Block a user