Files
AmongUsRevamped/HNSRevamped.cs
T

88 lines
2.9 KiB
C#

global using HarmonyLib;
global using System.Collections.Generic;
global using System.Linq;
using AmongUs.GameOptions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Unity.IL2CPP;
using System;
using UnityEngine;
namespace HNSRevamped;
[BepInAutoPlugin]
[BepInProcess("Among Us.exe")]
public partial class Main : BasePlugin
{
public Harmony Harmony { get; } = new(Id);
public static BepInEx.Logging.ManualLogSource Logger;
public static BasePlugin Instance;
public static ConfigEntry<bool> GM { get; private set; }
public static ConfigEntry<bool> UnlockFps { get; private set; }
public static ConfigEntry<bool> ShowFps { get; private set; }
public static ConfigEntry<bool> AutoStart { get; private set; }
public static ConfigEntry<bool> DarkTheme { get; private set; }
public static ConfigEntry<bool> LobbyMusic { get; private set; }
public static ConfigEntry<bool> NoKcdMode { get; private set; }
public static NormalGameOptionsV10 NormalOptions => GameOptionsManager.Instance != null ? GameOptionsManager.Instance.currentNormalGameOptions : null;
public static bool HasArgumentException;
public static string CredentialsText;
public const string ModVersion = "v0.2.0";
public static PlayerControl[] AllPlayerControls
{
get
{
int count = PlayerControl.AllPlayerControls.Count;
var result = new PlayerControl[count];
var i = 0;
foreach (PlayerControl pc in PlayerControl.AllPlayerControls)
{
if (pc == null || pc.PlayerId >= 254) continue;
result[i++] = pc;
}
if (i == 0) return [];
Array.Resize(ref result, i);
return result;
}
}
public override void Load()
{
var handler = HNSRevamped.Logger.Handler("GitVersion");
Logger = BepInEx.Logging.Logger.CreateLogSource("HNSRevamped");
HNSRevamped.Logger.Enable();
Instance = this;
AutoStart = Config.Bind("Client Options", "Auto Start", false);
GM = Config.Bind("Client Options", "GM", false);
UnlockFps = Config.Bind("Client Options", "Unlock FPS", false);
ShowFps = Config.Bind("Client Options", "Show FPS", false);
AutoStart = Config.Bind("Client Options", "Auto Start", false);
DarkTheme = Config.Bind("Client Options", "Dark Theme", true);
LobbyMusic = Config.Bind("Client Options", "Lobby Music", false);
NoKcdMode = Config.Bind("Client Options", "0Kcd Mode", false);
BanManager.Init();
Harmony.PatchAll();
}
[HarmonyPatch(typeof(ModManager), nameof(ModManager.LateUpdate))]
class ModManagerLateUpdatePatch
{
public static void Prefix(ModManager __instance)
{
__instance.ShowModStamp();
LateTask.Update(Time.deltaTime);
}
}
}