Disable sabotaging locally as host

This commit is contained in:
D1GQ committed 2026-03-24 23:06:46 -05:00
1 parent fcc57f9a9b
commit a172f97696
2 files changed
+37 -21

No files matched your search

-21
View File
@@ -489,27 +489,6 @@ internal static class NetworkManager
[HarmonyPatch]
internal static class MessageReaderUpdateSystemPatch
{
[HarmonyPatch(typeof(ShipStatus), nameof(ShipStatus.UpdateSystem), typeof(SystemTypes), typeof(PlayerControl), typeof(byte))]
[HarmonyPrefix]
internal static bool ShipStatus_UpdateSystemLocal_Prefix(SystemTypes systemType, PlayerControl player, byte amount)
{
if (!GameState.IsFreePlay) return true;
MessageWriter messageWriter = MessageWriter.Get(0);
messageWriter.Write(amount);
MessageReader messageReader = MessageReader.Get(messageWriter.ToByteArray(false));
messageWriter.Recycle();
if (BetterAntiCheat.RpcUpdateSystemCheck(player, systemType, messageReader) != true)
{
messageReader.Recycle();
return false;
}
messageReader.Recycle();
return true;
}
[HarmonyPatch(typeof(ShipStatus), nameof(ShipStatus.UpdateSystem), typeof(SystemTypes), typeof(PlayerControl), typeof(MessageReader))]
[HarmonyPrefix]
internal static bool ShipStatus_UpdateSystem_Prefix(SystemTypes systemType, PlayerControl player, MessageReader msgReader)
@@ -0,0 +1,37 @@
using BetterAmongUs.Helpers;
using BetterAmongUs.Modules;
using BetterAmongUs.Patches.Gameplay.UI.Settings;
using HarmonyLib;
namespace BetterAmongUs.Patches.Gameplay.Ship;
[HarmonyPatch]
internal static class DisableSabotagePatch
{
[HarmonyPatch(typeof(MapRoom), nameof(MapRoom.SabotageReactor))]
[HarmonyPatch(typeof(MapRoom), nameof(MapRoom.SabotageHeli))]
[HarmonyPatch(typeof(MapRoom), nameof(MapRoom.SabotageComms))]
[HarmonyPatch(typeof(MapRoom), nameof(MapRoom.SabotageOxygen))]
[HarmonyPatch(typeof(MapRoom), nameof(MapRoom.SabotageLights))]
[HarmonyPatch(typeof(MapRoom), nameof(MapRoom.SabotageSeismic))]
[HarmonyPatch(typeof(MapRoom), nameof(MapRoom.SabotageMushroomMixup))]
[HarmonyPrefix]
internal static bool MapRoom_Sabotage_Prefix()
{
if (GameState.IsHost)
{
if (BetterGameSettings.DisableSabotages.GetBool())
return false;
if (BetterGameSettings.DisableSabotagesForDead.GetBool())
{
if (!PlayerControl.LocalPlayer.IsAlive())
{
return false;
}
}
}
return true;
}
}