mirror of
https://github.com/D1GQ/BetterAmongUs.git
synced 2026-10-19 15:51:52 +00:00
9 files changed
+100
-51
No files matched your search
@@ -1,4 +1,5 @@
|
||||
using Hazel;
|
||||
using AmongUs.InnerNet.GameDataMessages;
|
||||
using Hazel;
|
||||
using InnerNet;
|
||||
using System.Globalization;
|
||||
|
||||
@@ -6,6 +7,25 @@ namespace BetterAmongUs.Helpers;
|
||||
|
||||
static class InnerNetClientHelper
|
||||
{
|
||||
internal static void BroadcastRpc(this BaseRpcMessage rpcMessage, bool reliable = true)
|
||||
{
|
||||
if (rpcMessage.TryCast<IGameDataMessage>(out var data))
|
||||
{
|
||||
if (reliable)
|
||||
AmongUsClient.Instance.reliableMessageQueue.Enqueue(data);
|
||||
else
|
||||
AmongUsClient.Instance.unreliableMessageQueue.Enqueue(data);
|
||||
}
|
||||
}
|
||||
|
||||
internal static void BroadcastData(this BaseGameDataMessage rpcMessage)
|
||||
{
|
||||
if (rpcMessage.TryCast<IGameDataMessage>(out var data))
|
||||
{
|
||||
AmongUsClient.Instance.reliableMessageQueue.Enqueue(data);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes an array of boolean values to a MessageWriter in a packed format to save space.
|
||||
/// Each byte stores up to 8 boolean values as bits.
|
||||
|
||||
+2
-2
@@ -60,9 +60,9 @@ internal static class Utils
|
||||
var data = PlayerControl.LocalPlayer?.Data;
|
||||
if (data == null) return;
|
||||
ChatBubble pooledBubble = chat.GetPooledBubble();
|
||||
string MsgName = $"<color=#ffffff><b>(<color=#00ff44>{Translator.GetString("SystemMessage")}</color>)</b>";
|
||||
string MsgName = $"<color=#ffffff><b>(<color=#00ff44>{Translator.GetString("SystemMessage")}</color>)</b>" + ChatPatch.CommandPostfixName;
|
||||
if (overrideName != "")
|
||||
MsgName = overrideName;
|
||||
MsgName = overrideName + ChatPatch.CommandPostfixName;
|
||||
try
|
||||
{
|
||||
pooledBubble.transform.SetParent(chat.scroller.Inner);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using BetterAmongUs.Modules;
|
||||
using BetterAmongUs.Helpers;
|
||||
using BetterAmongUs.Modules;
|
||||
using BetterAmongUs.Patches;
|
||||
using HarmonyLib;
|
||||
|
||||
@@ -7,8 +8,36 @@ namespace BetterAmongUs.Managers;
|
||||
[HarmonyPatch]
|
||||
internal static class PrivateOnlyLobbyManager
|
||||
{
|
||||
internal static void SyncNames()
|
||||
private static void SyncNamesAsHost()
|
||||
{
|
||||
if (!GameState.IsHost || !GameState.IsPrivateOnlyLobby || !GameState.InGame) return;
|
||||
|
||||
foreach (var target in PlayerControl.AllPlayerControls)
|
||||
{
|
||||
if (target.IsHost() || target.BetterData().IsBetterUser) continue;
|
||||
|
||||
foreach (var player in PlayerControl.AllPlayerControls)
|
||||
{
|
||||
if (GameState.IsMeeting)
|
||||
{
|
||||
SetNameMeeting(player, target);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetNameGameplay(player, target);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void SetNameGameplay(PlayerControl player, PlayerControl target)
|
||||
{
|
||||
player.RpcSetNamePrivate("", target);
|
||||
}
|
||||
|
||||
private static void SetNameMeeting(PlayerControl player, PlayerControl target)
|
||||
{
|
||||
player.RpcSetNamePrivate("", target);
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(PlayerControl))]
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
using BetterAmongUs.Items.Attributes;
|
||||
using Hazel;
|
||||
using InnerNet;
|
||||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BetterAmongUs.Modules.AntiCheat;
|
||||
@@ -20,13 +19,6 @@ internal enum HandlerFlag
|
||||
internal abstract class RPCHandler
|
||||
{
|
||||
internal static readonly RPCHandler?[] allHandlers = [.. RegisterRPCHandlerAttribute.Instances];
|
||||
|
||||
internal static RPCHandler?[] GetAllHandlerInstances() => Assembly.GetExecutingAssembly()
|
||||
.GetTypes()
|
||||
.Where(t => t.IsSubclassOf(typeof(RPCHandler)) && !t.IsAbstract)
|
||||
.Select(t => (RPCHandler?)Activator.CreateInstance(t))
|
||||
.ToArray();
|
||||
|
||||
internal InnerNetClient innerNetClient => AmongUsClient.Instance;
|
||||
internal virtual byte CallId => byte.MaxValue;
|
||||
internal virtual byte GameDataTag => byte.MaxValue;
|
||||
|
||||
+2
-17
@@ -33,22 +33,6 @@ enum HandleGameDataTags : byte
|
||||
|
||||
internal static class RPC
|
||||
{
|
||||
internal static void RpcSyncSettings()
|
||||
{
|
||||
if (!AmongUsClient.Instance.AmHost)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var player in Main.AllPlayerControls.Where(pc => !pc.IsLocalPlayer()))
|
||||
{
|
||||
var optionsByteArray = GameOptionsManager.Instance.gameOptionsFactory.ToBytes(GameOptionsManager.Instance.CurrentGameOptions, false);
|
||||
MessageWriter messageWriter = AmongUsClient.Instance.StartRpcImmediately(player.NetId, (byte)RpcCalls.SyncSettings, SendOption.None, player.GetClientId());
|
||||
messageWriter.WriteBytesAndSize(optionsByteArray);
|
||||
AmongUsClient.Instance.FinishRpcImmediately(messageWriter);
|
||||
}
|
||||
}
|
||||
|
||||
internal static void RpcSetNamePrivate(PlayerControl player, string name, PlayerControl target)
|
||||
{
|
||||
if (!GameState.IsHost || !GameState.IsVanillaServer)
|
||||
@@ -65,7 +49,8 @@ internal static class RPC
|
||||
internal static void RpcExile(PlayerControl player)
|
||||
{
|
||||
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(player.NetId, (byte)RpcCalls.Exiled, SendOption.Reliable, -1);
|
||||
AmongUsClient.Instance.FinishRpcImmediately(writer);
|
||||
AmongUsClient.Instance.FinishRpcImmediately(writer);
|
||||
|
||||
player.Exiled();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
using AmongUs.Data;
|
||||
using AmongUs.Data.Player;
|
||||
using Assets.InnerNet;
|
||||
using BepInEx.Unity.IL2CPP.Utils.Collections;
|
||||
using BetterAmongUs.Helpers;
|
||||
using HarmonyLib;
|
||||
using Il2CppInterop.Runtime.InteropTypes.Arrays;
|
||||
using System.Collections;
|
||||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -128,20 +126,11 @@ internal class ModNews
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(AnnouncementPopUp), nameof(AnnouncementPopUp.Init)), HarmonyPostfix]
|
||||
internal static void Initialize(ref Il2CppSystem.Collections.IEnumerator __result)
|
||||
{
|
||||
static IEnumerator FetchBlacklist()
|
||||
{
|
||||
ProcessModNewsFiles();
|
||||
yield return null;
|
||||
}
|
||||
__result = Effects.Sequence(FetchBlacklist().WrapToIl2Cpp(), __result);
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(PlayerAnnouncementData), nameof(PlayerAnnouncementData.SetAnnouncements)), HarmonyPrefix]
|
||||
internal static bool SetModAnnouncements(PlayerAnnouncementData __instance, [HarmonyArgument(0)] ref Il2CppReferenceArray<Announcement> aRange)
|
||||
{
|
||||
ProcessModNewsFiles();
|
||||
|
||||
AllModNews.Sort((a1, a2) => DateTime.Compare(DateTime.Parse(a2.Date), DateTime.Parse(a1.Date)));
|
||||
|
||||
List<Announcement> finalAllNews = new List<Announcement>();
|
||||
|
||||
+36
-2
@@ -9,18 +9,52 @@ using UnityEngine;
|
||||
|
||||
namespace BetterAmongUs.Patches;
|
||||
|
||||
// History and dark mode from: https://github.com/0xDrMoe/TownofHost-Enhanced
|
||||
|
||||
class ChatPatch
|
||||
{
|
||||
internal static List<string> ChatHistory = [];
|
||||
internal static int CurrentHistorySelection = -1;
|
||||
|
||||
internal const string CommandPostfixName = "<size=0%>IsCommand</size>";
|
||||
|
||||
internal static void ClearChat()
|
||||
{
|
||||
if (!HudManager.InstanceExists) return;
|
||||
|
||||
HudManager.Instance.Chat.chatBubblePool.ReclaimAll();
|
||||
}
|
||||
|
||||
internal static void ClearPlayerChats()
|
||||
{
|
||||
if (!HudManager.InstanceExists) return;
|
||||
|
||||
foreach (var obj in HudManager.Instance.Chat.chatBubblePool.activeChildren.ToArray())
|
||||
{
|
||||
var chatBubble = obj.GetComponent<ChatBubble>();
|
||||
if (chatBubble != null)
|
||||
{
|
||||
if (chatBubble.NameText.text.EndsWith(CommandPostfixName)) continue;
|
||||
HudManager.Instance.Chat.chatBubblePool.Reclaim(chatBubble);
|
||||
}
|
||||
}
|
||||
HudManager.Instance.Chat.AlignAllBubbles();
|
||||
}
|
||||
|
||||
internal static void ClearCommands()
|
||||
{
|
||||
if (!HudManager.InstanceExists) return;
|
||||
|
||||
foreach (var obj in HudManager.Instance.Chat.chatBubblePool.activeChildren.ToArray())
|
||||
{
|
||||
var chatBubble = obj.GetComponent<ChatBubble>();
|
||||
if (chatBubble != null)
|
||||
{
|
||||
if (!chatBubble.NameText.text.EndsWith(CommandPostfixName)) continue;
|
||||
HudManager.Instance.Chat.chatBubblePool.Reclaim(chatBubble);
|
||||
}
|
||||
}
|
||||
HudManager.Instance.Chat.AlignAllBubbles();
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(ChatController))]
|
||||
internal class ChatControllerPatch
|
||||
{
|
||||
|
||||
@@ -221,7 +221,7 @@ class MeetingHudPatch
|
||||
|
||||
if (Main.ChatInGameplay.Value && !GameState.IsFreePlay && PlayerControl.LocalPlayer.IsAlive())
|
||||
{
|
||||
ChatPatch.ClearChat();
|
||||
ChatPatch.ClearPlayerChats();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -28,13 +28,13 @@ internal enum ReleaseTypes : int
|
||||
[BepInProcess("Among Us.exe")]
|
||||
internal class Main : BasePlugin
|
||||
{
|
||||
internal static readonly ReleaseTypes ReleaseBuildType = ReleaseTypes.Release;
|
||||
internal const string BetaNum = "0";
|
||||
internal static readonly ReleaseTypes ReleaseBuildType = ReleaseTypes.Beta;
|
||||
internal const string BetaNum = "1";
|
||||
internal const string HotfixNum = "0";
|
||||
internal const bool IsHotFix = false;
|
||||
internal const string PluginGuid = "com.ten.betteramongus";
|
||||
internal const string PluginVersion = "1.2.0";
|
||||
internal const string ReleaseDate = "07.09.2025"; // mm/dd/yyyy
|
||||
internal const string ReleaseDate = "07.14.2025"; // mm/dd/yyyy
|
||||
internal const string Github = "https://github.com/EnhancedNetwork/BetterAmongUs-Public";
|
||||
internal const string Discord = "https://discord.gg/ten";
|
||||
internal static UserData MyData = UserData.AllUsers.First();
|
||||
@@ -65,10 +65,10 @@ internal class Main : BasePlugin
|
||||
text = $"v{BetterAmongUsVersion}";
|
||||
break;
|
||||
case ReleaseTypes.Beta:
|
||||
text = $"v{BetterAmongUsVersion}{newLineText}Beta {Main.BetaNum}";
|
||||
text = $"v{BetterAmongUsVersion}{newLineText}Beta {BetaNum}";
|
||||
break;
|
||||
case ReleaseTypes.Dev:
|
||||
text = $"v{BetterAmongUsVersion}{newLineText}Dev {Main.ReleaseDate}";
|
||||
text = $"v{BetterAmongUsVersion}{newLineText}Dev {ReleaseDate}";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
Reference in new issue
Block a user