From a6c3220892854f7322758edce280523c0f31289e Mon Sep 17 00:00:00 2001
From: Ape <155788660+ApeMV@users.noreply.github.com>
Date: Sun, 1 Feb 2026 15:59:29 +0100
Subject: [PATCH] Starlight compatibility, small fixes
---
AmongUsRevamped.cs | 3 +++
AmongUsRevamped.csproj | 15 +++++++-------
Modules/BanManager.cs | 34 +++++++++++++++++++++++++++-----
Modules/Hotkeys.cs | 19 ++++++++++--------
Modules/Utils.cs | 27 ++++++++-----------------
Modules/Zoom.cs | 8 ++++----
Patches/ChatPatches.cs | 22 +++++++++++++++++++++
Patches/DleksPatch.cs | 23 +++++++++------------
Patches/GameOptionsMenuPatch.cs | 7 ++++++-
Patches/GameStartManagerPatch.cs | 5 ++++-
Patches/JoinAndLeavePatches.cs | 2 +-
11 files changed, 105 insertions(+), 60 deletions(-)
diff --git a/AmongUsRevamped.cs b/AmongUsRevamped.cs
index 34f167d..d6442e4 100644
--- a/AmongUsRevamped.cs
+++ b/AmongUsRevamped.cs
@@ -11,6 +11,9 @@ using UnityEngine;
namespace AmongUsRevamped;
+// dotnet build -c release
+// dotnet build -c android
+
[BepInAutoPlugin]
[BepInProcess("Among Us.exe")]
public partial class Main : BasePlugin
diff --git a/AmongUsRevamped.csproj b/AmongUsRevamped.csproj
index aee2564..b1dd16a 100644
--- a/AmongUsRevamped.csproj
+++ b/AmongUsRevamped.csproj
@@ -1,19 +1,20 @@
- net6.0
+ net8.0
+ net6.0
latest
embedded
-
- 1.0.0
- dev
The ultimate Host-Only mod without Modded Protocol
apemv
true
+ Release;Android
-
-
+
+
+
+
@@ -21,7 +22,7 @@
-
+
diff --git a/Modules/BanManager.cs b/Modules/BanManager.cs
index 65943ee..dd6aefa 100644
--- a/Modules/BanManager.cs
+++ b/Modules/BanManager.cs
@@ -5,22 +5,30 @@ using System.Security.Cryptography;
using System.Text;
using System.Text.RegularExpressions;
using System.Reflection;
+using UnityEngine;
// https://github.com/EnhancedNetwork/TownofHost-Enhanced/blob/main/Modules/BanManager.cs
namespace AmongUsRevamped;
public static class BanManager
{
+ public static readonly string DataPath =
+#if ANDROID
+ Application.persistentDataPath;
+#else
+ ".";
+#endif
+
public static string RemoveHtmlTags(this string str) => Regex.Replace(str, "<[^>]*?>", "");
- private static readonly string DenyNameListPath = "./AUR-DATA/DenyNameList.txt";
- private static string BanListPath = "./AUR-DATA/BanList.txt";
- private static string ModeratorListPath = "./AUR-DATA/ModeratorList.txt";
+ private static readonly string DenyNameListPath = $"{DataPath}/AUR-DATA/DenyNameList.txt";
+ private static string BanListPath = $"{DataPath}/AUR-DATA/BanList.txt";
+ private static string ModeratorListPath = $"{DataPath}/AUR-DATA/ModeratorList.txt";
public static List TempBanWhiteList = [];
public static void Init()
{
try
{
- Directory.CreateDirectory("AUR-DATA");
+ if (!Directory.Exists($"{DataPath}/AUR-DATA")) Directory.CreateDirectory($"{DataPath}/AUR-DATA");
if (!File.Exists(DenyNameListPath))
{
@@ -120,8 +128,9 @@ public static class BanManager
try
{
- Directory.CreateDirectory("AUR-DATA");
+ if (!Directory.Exists($"{DataPath}/AUR-DATA")) Directory.CreateDirectory($"{DataPath}/AUR-DATA");
if (!File.Exists(BanListPath)) File.Create(BanListPath).Close();
+
using StreamReader sr = new(BanListPath);
string line;
while ((line = sr.ReadLine()) != null)
@@ -141,6 +150,21 @@ public static class BanManager
}
return false;
}
+ public static bool IsPlayerInDenyName(ClientData client, string name)
+ {
+ if (name == "" || !AmongUsClient.Instance.AmHost || !Options.ApplyDenyNameList.GetBool()) return false;
+
+ var deniedNames = File.ReadAllLines(DenyNameListPath);
+
+ if (deniedNames.Where(code => !string.IsNullOrWhiteSpace(code)).Any(code => name.Contains(code, StringComparison.OrdinalIgnoreCase)))
+ {
+ AmongUsClient.Instance.KickPlayer(client.Id, false);
+ Logger.Info($" {name} was kicked because their name was in DenyNameList.txt", "Kick");
+ Logger.SendInGame($" {name} was kicked because their name was in DenyNameList.txt");
+ return true;
+ }
+ else return false;
+ }
}
[HarmonyPatch(typeof(BanMenu), nameof(BanMenu.Select))]
diff --git a/Modules/Hotkeys.cs b/Modules/Hotkeys.cs
index 11f511d..fa58ae5 100644
--- a/Modules/Hotkeys.cs
+++ b/Modules/Hotkeys.cs
@@ -5,16 +5,23 @@ using UnityEngine;
namespace AmongUsRevamped;
+#if !ANDROID
[HarmonyPatch(typeof(ControllerManager), nameof(ControllerManager.Update))]
internal class Hotkeys
{
public static void Postfix()
{
- // I don't know which psychopath would use right keys, but I know someday, someone will complain
bool Shift = Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift);
bool Ctrl = Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl);
bool Enter = Input.GetKeyDown(KeyCode.Return);
+ if ((!AmongUsClient.Instance.IsGameStarted || !Utils.IsOnlineGame) && Utils.CanMove && PlayerControl.LocalPlayer.Collider != null)
+ {
+ PlayerControl.LocalPlayer.Collider.enabled = !Ctrl;
+ }
+
+ if (!AmongUsClient.Instance.AmHost) return;
+
if (Input.GetKey(KeyCode.L) && Shift && Enter)
{
MessageWriter writer = AmongUsClient.Instance.StartEndGame();
@@ -34,16 +41,11 @@ internal class Hotkeys
}
}
- if (Shift && GameStartManager.InstanceExists && GameStartManager.Instance.startState == GameStartManager.StartingStates.Countdown && !HudManager.Instance.Chat.IsOpenOrOpening)
+ if (Shift && GameStartManager.InstanceExists && GameStartManager.Instance != null && GameStartManager.Instance.startState == GameStartManager.StartingStates.Countdown && !HudManager.Instance.Chat.IsOpenOrOpening)
{
GameStartManager.Instance.countDownTimer = 0;
}
- if ((!AmongUsClient.Instance.IsGameStarted || !Utils.IsOnlineGame) && Utils.CanMove && PlayerControl.LocalPlayer.Collider != null)
- {
- PlayerControl.LocalPlayer.Collider.enabled = !Ctrl;
- }
-
if (Input.GetKeyDown(KeyCode.C) && GameStartManager.InstanceExists && GameStartManager.Instance != null && GameStartManager.Instance.startState == GameStartManager.StartingStates.Countdown && !HudManager.Instance.Chat.IsOpenOrOpening && Utils.IsLobby)
{
Logger.Info("Resetted start countdown", "KeyCommand");
@@ -51,4 +53,5 @@ internal class Hotkeys
Logger.SendInGame("Starting countdown canceled");
}
}
-}
\ No newline at end of file
+}
+#endif
\ No newline at end of file
diff --git a/Modules/Utils.cs b/Modules/Utils.cs
index 43e97d0..b3397ac 100644
--- a/Modules/Utils.cs
+++ b/Modules/Utils.cs
@@ -52,28 +52,11 @@ public static class Utils
{
if (friendCode == "") return false;
- var friendCodesFilePath = @"./AUR-DATA/ModeratorList.txt";
+ var friendCodesFilePath = @$"{BanManager.DataPath}/AUR-DATA/ModeratorList.txt";
var friendCodes = File.ReadAllLines(friendCodesFilePath);
return friendCodes.Any(code => code.Contains(friendCode));
}
- public static bool IsPlayerInDenyName(ClientData client, string name)
- {
- if (name == "" || !AmongUsClient.Instance.AmHost || !Options.ApplyDenyNameList.GetBool()) return false;
-
- var denyNameFilePath = @"./AUR-DATA/DenyNameList.txt";
- var deniedNames = File.ReadAllLines(denyNameFilePath);
-
- if (deniedNames.Where(code => !string.IsNullOrWhiteSpace(code)).Any(code => name.Contains(code, StringComparison.OrdinalIgnoreCase)))
- {
- AmongUsClient.Instance.KickPlayer(client.Id, false);
- Logger.Info($" {name} was kicked because their name was in DenyNameList.txt", "Kick");
- Logger.SendInGame($" {name} was kicked because their name was in DenyNameList.txt");
- return true;
- }
- else return false;
- }
-
public static string GetTabName(TabGroup tab)
{
switch (tab)
@@ -394,8 +377,12 @@ public static class Utils
public static void DumpLog()
{
- string f = $"{Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory)}/AUR-logs/";
string t = DateTime.Now.ToString("yyyy-MM-dd_HH.mm.ss");
+#if ANDROID
+ var f = $"{BanManager.DataPath}/AUR-Logs/{t}";
+#else
+ string f = $"{Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory)}/AUR-logs/";
+#endif
string filename = $"{f}AUR-{Main.ModVersion}-{t}.log";
if (!Directory.Exists(f)) Directory.CreateDirectory(f);
FileInfo file = new(@$"{Environment.CurrentDirectory}/BepInEx/LogOutput.log");
@@ -404,8 +391,10 @@ public static class Utils
if (PlayerControl.LocalPlayer != null)
{
HudManager.Instance.Chat.AddChat(PlayerControl.LocalPlayer, $"/Dump command activated\n\nFile: AUR-{Main.ModVersion}-{t}");
+#if !ANDROID
ProcessStartInfo psi = new("Explorer.exe") { Arguments = "/e,/select," + @filename.Replace("/", "\\") };
Process.Start(psi);
+#endif
}
}
diff --git a/Modules/Zoom.cs b/Modules/Zoom.cs
index 05cd9ea..b6f60ed 100644
--- a/Modules/Zoom.cs
+++ b/Modules/Zoom.cs
@@ -4,6 +4,7 @@ using UnityEngine;
namespace AmongUsRevamped;
// https://github.com/Yumenopai/TownOfHost_Y
+#if !ANDROID
[HarmonyPatch(typeof(HudManager), nameof(HudManager.Update))]
public static class Zoom
{
@@ -16,9 +17,7 @@ public static class Zoom
public static void Postfix()
{
- bool canZoom =
- (Utils.IsShip && !Utils.IsMeeting && Utils.CanMove && PlayerControl.LocalPlayer.Data.IsDead)
- || (Utils.IsLobby && Utils.CanMove);
+ bool canZoom = (Utils.IsShip && !Utils.IsMeeting && Utils.CanMove && PlayerControl.LocalPlayer.Data.IsDead) || (Utils.IsLobby && Utils.CanMove);
if (!canZoom)
{
@@ -100,4 +99,5 @@ public static class Flag
{
OneTimeList.Remove(type);
}
-}
\ No newline at end of file
+}
+#endif
\ No newline at end of file
diff --git a/Patches/ChatPatches.cs b/Patches/ChatPatches.cs
index dd7e4be..7a611c0 100644
--- a/Patches/ChatPatches.cs
+++ b/Patches/ChatPatches.cs
@@ -82,6 +82,28 @@ internal static class SendChatPatch
return false;
}
+ if (text == "/eg" || text == "/endgame")
+ {
+ __instance.freeChatField.textArea.Clear();
+ __instance.freeChatField.textArea.SetText(string.Empty);
+
+ if (!Utils.InGame) return false;
+ MessageWriter writer = AmongUsClient.Instance.StartEndGame();
+ writer.Write((byte)GameOverReason.ImpostorDisconnect);
+ AmongUsClient.Instance.FinishEndGame(writer);
+ return false;
+ }
+
+ if (text == "/em" || text == "/endmeeting")
+ {
+ __instance.freeChatField.textArea.Clear();
+ __instance.freeChatField.textArea.SetText(string.Empty);
+
+ if ( !Utils.InGame || !Utils.IsMeeting) return false;
+ MeetingHud.Instance.RpcClose();
+ return false;
+ }
+
if (__instance.timeSinceLastMessage < 3f || OnGameJoinedPatch.WaitingForChat) return false;
if (text == "/l" || text == "/lastgame" || text == "/win" || text == "/winner")
diff --git a/Patches/DleksPatch.cs b/Patches/DleksPatch.cs
index 033afea..29b1ada 100644
--- a/Patches/DleksPatch.cs
+++ b/Patches/DleksPatch.cs
@@ -21,6 +21,7 @@ public static class AmongUsDateTime_UtcNow
class CreateOptionsPickerPatch
{
public static bool SetDleks = false;
+ public static bool SetDleks2;
private static MapSelectButton DleksButton;
[HarmonyPatch]
public static class GameOptionsMapPickerPatch
@@ -30,9 +31,12 @@ class CreateOptionsPickerPatch
public static void Postfix_Initialize(CreateGameMapPicker __instance)
{
if (SceneManager.GetActiveScene().name == "FindAGame") return;
+ if (SetDleks2 && SceneManager.GetActiveScene().name == "MainMenu") return;
+ new LateTask(() =>
+ {
+ SetDleks2 = true;
int DleksPos = 3;
-
MapSelectButton[] AllMapButton = __instance.transform.GetComponentsInChildren();
if (AllMapButton != null)
@@ -95,6 +99,8 @@ class CreateOptionsPickerPatch
}
}
}
+
+ }, 0.2f, "ApplyDleks");
}
[HarmonyPatch(typeof(GameOptionsMapPicker), nameof(GameOptionsMapPicker.FixedUpdate))]
@@ -105,17 +111,7 @@ class CreateOptionsPickerPatch
if (__instance.MapName == null) return false;
- if (DleksButton != null)
- {
- if (__instance.selectedMapId == 3)
- {
- SetDleks = true;
- }
- else
- {
- SetDleks = false;
- }
- }
+ if (DleksButton != null) SetDleks = __instance.selectedMapId == 3;
if (__instance.selectedMapId == 3)
{
@@ -203,8 +199,7 @@ class CreateOptionsPickerPatch
Vector3 position1 = two.transform.position;
Vector3 position2 = one.transform.position;
transform1.position = position1;
- Vector3 vector3 = position2;
- transform2.position = vector3;
+ transform2.position = position2;
}
}
}
\ No newline at end of file
diff --git a/Patches/GameOptionsMenuPatch.cs b/Patches/GameOptionsMenuPatch.cs
index d4d5760..069107f 100644
--- a/Patches/GameOptionsMenuPatch.cs
+++ b/Patches/GameOptionsMenuPatch.cs
@@ -1,7 +1,12 @@
using System;
-using Il2CppSystem.Collections.Generic;
using UnityEngine;
+#if ANDROID
+using System.Collections.Generic;
+#else
+using Il2CppSystem.Collections.Generic;
+#endif
+
using Object = UnityEngine.Object;
// https://github.com/Yumenopai/TownOfHost_Y/blob/main/Patches/GameOptionsPatch.cs
diff --git a/Patches/GameStartManagerPatch.cs b/Patches/GameStartManagerPatch.cs
index f4c387f..23dacac 100644
--- a/Patches/GameStartManagerPatch.cs
+++ b/Patches/GameStartManagerPatch.cs
@@ -44,7 +44,10 @@ public static class GameStartManagerUpdatePatch
{
string warningMessage = "";
- if (!AmongUsClient.Instance.AmHost || __instance.GameStartText == null) return;
+ if (__instance == null || MeetingHud.Instance != null) return;
+ if (AmongUsClient.Instance == null || !AmongUsClient.Instance.AmHost) return;
+
+ if (__instance.StartButton == null || __instance.GameStartText == null) return;
if (GameStartManagerStartPatch.warningText != null)
{
diff --git a/Patches/JoinAndLeavePatches.cs b/Patches/JoinAndLeavePatches.cs
index ded07e9..c057749 100644
--- a/Patches/JoinAndLeavePatches.cs
+++ b/Patches/JoinAndLeavePatches.cs
@@ -80,7 +80,7 @@ class OnPlayerJoinedPatch
{
BanManager.CheckBanPlayer(Client);
- Utils.IsPlayerInDenyName(Client, Client.PlayerName);
+ BanManager.IsPlayerInDenyName(Client, Client.PlayerName);
if (Utils.IsPlayerModerator(Client.FriendCode) && Options.ApplyModeratorList.GetBool())
{