mirror of
https://github.com/D1GQ/BetterAmongUs.git
synced 2026-10-20 01:46:19 +00:00
68 lines
2.0 KiB
C#
68 lines
2.0 KiB
C#
using AmongUs.Data;
|
|
using Discord;
|
|
using HarmonyLib;
|
|
|
|
namespace BetterAmongUs.Patches;
|
|
|
|
|
|
[HarmonyPatch(typeof(ActivityManager), nameof(ActivityManager.UpdateActivity))]
|
|
public class DiscordRPC
|
|
{
|
|
private static string lobbycode = "";
|
|
private static string region = "";
|
|
|
|
public static void Prefix([HarmonyArgument(0)] Activity activity)
|
|
{
|
|
if (activity == null) return;
|
|
|
|
string details = $"BAU v{Main.PluginVersion}";
|
|
activity.Details = details;
|
|
|
|
if (activity.State == "In Menus") return;
|
|
|
|
try
|
|
{
|
|
if (!DataManager.Settings.Gameplay.StreamerMode)
|
|
{
|
|
UpdateRegionAndLobbyCode();
|
|
if (!string.IsNullOrEmpty(lobbycode) && !string.IsNullOrEmpty(region))
|
|
{
|
|
if (GameStates.IsNormalGame)
|
|
details = $"BAU - {lobbycode} ({region})";
|
|
else if (GameStates.IsHideNSeek)
|
|
details = $"BAU Hide & Seek - {lobbycode} ({region})";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (GameStates.IsHideNSeek)
|
|
details = $"BAU v{Main.PluginVersion} - Hide & Seek";
|
|
}
|
|
}
|
|
catch
|
|
{
|
|
}
|
|
|
|
activity.Details = details;
|
|
}
|
|
|
|
private static void UpdateRegionAndLobbyCode()
|
|
{
|
|
if (GameStates.IsLobby)
|
|
{
|
|
lobbycode = GameStartManager.Instance.GameRoomNameCode.text;
|
|
region = ServerManager.Instance.CurrentRegion.Name;
|
|
region = region switch
|
|
{
|
|
"North America" => "NA",
|
|
"Europe" => "EU",
|
|
"Asia" => "AS",
|
|
_ when region.Contains("MNA") => "MNA",
|
|
_ when region.Contains("MEU") => "MEU",
|
|
_ when region.Contains("MAS") => "MAS",
|
|
_ => region
|
|
};
|
|
}
|
|
}
|
|
}
|