using UnityEngine; using BepInEx; using BepInEx.Configuration; using BepInEx.Unity.IL2CPP; using BepInEx.Logging; using HarmonyLib; using Innersloth.IO; using Il2CppInterop.Runtime.Injection; namespace BetterAmongUs; public enum ReleaseTypes : int { Release, Canary, Dev, } [BepInPlugin(PluginGuid, "BetterAmongUs", PluginVersion)] [BepInProcess("Among Us.exe")] public class Main : BasePlugin { public const ReleaseTypes ReleaseBuildType = ReleaseTypes.Canary; public const string CanaryNum = "1"; public const string PluginGuid = "com.d1gq.betteramongus"; public const string PluginVersion = "1.0.0"; public const string ReleaseDate = "07.27.2024"; // dd/mm/yyyy public const string Github = "https://github.com/D1GQ/BetterAmongUs"; public static string GetVersionText() { if (ReleaseBuildType == ReleaseTypes.Release) return $"v{BetterAmongUsVersion}"; else if (ReleaseBuildType == ReleaseTypes.Canary) return $"v{BetterAmongUsVersion} Canary {Main.CanaryNum}"; else if (Main.ReleaseBuildType == ReleaseTypes.Dev) return $"v{BetterAmongUsVersion} Dev {Main.ReleaseDate}"; } public Harmony Harmony { get; } = new Harmony(PluginGuid); public static string BetterAmongUsVersion => PluginVersion; public static string AmongUsVersion => Application.version; public static List SupportedAmongUsVersions = [ "2024.6.18", ]; public static string[] DevUser = [ "8f23c48e2", ]; public static PlayerControl[] AllPlayerControls => PlayerControl.AllPlayerControls.ToArray().Where(pc => pc != null).ToArray(); public static PlayerControl[] AllAlivePlayerControls => AllPlayerControls.ToArray().Where(pc => pc.IsAlive()).ToArray(); public static Dictionary GetRoleName = new Dictionary { { 0, "Crewmate" }, { 1, "Impostor" }, { 2, "Scientist" }, { 3, "Engineer" }, { 4, "Guardian Angel" }, { 5, "Shapeshifter" }, { 6, "Crewmate" }, { 7, "Impostor" }, { 8, "Noisemaker" }, { 9, "Phantom" }, { 10, "Tracker" } }; public static ManualLogSource Logger; public static DebugMenu debugmenu { get; set; } = null; public override void Load() { try { Logger = BepInEx.Logging.Logger.CreateLogSource(PluginGuid); Harmony.PatchAll(); BAUDataManager.SetUp(); BAUDataManager.LoadCheatData(); LoadOptions(); if (File.Exists(Path.Combine($"{Environment.CurrentDirectory}/Among Us_Data/Plugins/x86", "steam_api.dll"))) File.WriteAllText(Path.Combine(Environment.CurrentDirectory, "steam_appid.txt"), "945360"); if (File.Exists(Path.Combine(Environment.CurrentDirectory, "better-log.txt"))) File.WriteAllText(Path.Combine(Environment.CurrentDirectory, "better-previous-log.txt"), File.ReadAllText(Path.Combine(Environment.CurrentDirectory, "better-log.txt"))); File.WriteAllText(Path.Combine(Environment.CurrentDirectory, "better-log.txt"), ""); BetterAmongUs.Logger.Log("Better Among Us successfully loaded!"); // Set up debug menu ClassInjector.RegisterTypeInIl2Cpp(); ClassInjector.RegisterTypeInIl2Cpp(); debugmenu = AddComponent(); AddComponent(); string SupportedVersions = string.Empty; foreach (string text in SupportedAmongUsVersions.ToArray()) SupportedVersions += $"{text} "; BetterAmongUs.Logger.Log($"BetterAmongUs {BetterAmongUsVersion}-{ReleaseDate} - [{AmongUsVersion} --> {SupportedVersions.Substring(0, SupportedVersions.Length - 1)}]"); } catch (Exception ex) { BetterAmongUs.Logger.Error(ex.ToString()); } } public static ConfigEntry AntiCheat { get; private set; } public static ConfigEntry BetterHost { get; private set; } public static ConfigEntry BetterRoleAlgorithma { get; private set; } public static ConfigEntry LobbyPlayerInfo { get; private set; } public static ConfigEntry DisableLobbyTheme { get; private set; } public static ConfigEntry UnlockFPS { get; private set; } public static ConfigEntry ShowFPS { get; private set; } public static ConfigEntry CommandPrefix { get; set; } private void LoadOptions() { AntiCheat = Config.Bind("Better Options", "AntiCheat", true); BetterHost = Config.Bind("Better Options", "BetterHost", false); BetterRoleAlgorithma = Config.Bind("Better Options", "BetterRoleAlgorithma", true); LobbyPlayerInfo = Config.Bind("Better Options", "LobbyPlayerInfo", true); DisableLobbyTheme = Config.Bind("Better Options", "DisableLobbyTheme", true); UnlockFPS = Config.Bind("Better Options", "UnlockFPS", false); ShowFPS = Config.Bind("Better Options", "ShowFPS", false); CommandPrefix = Config.Bind("Client Options", "CommandPrefix", "/"); } public static string GetDataPathToAmongUs() => FileIO.GetRootDataPath(); public static string GetGamePathToAmongUs() => Environment.CurrentDirectory; }