From 0efbce9fb4353ed1f3cd18e33d890e67bc6f33dc Mon Sep 17 00:00:00 2001 From: Eno <43026685+EnoPM@users.noreply.github.com> Date: Mon, 6 Nov 2023 02:22:19 +0100 Subject: [PATCH] Among Us v2023.10.24 support --- BetterPolus/BetterPolus.csproj | 2 +- BetterPolus/BetterPolusPlugin.cs | 10 +++--- .../Patches/ReactorSystemTypePatches.cs | 36 +++++++++++++++---- BetterPolus/Patches/ShipStatusPatches.cs | 4 +-- README.md | 7 ++++ 5 files changed, 45 insertions(+), 14 deletions(-) diff --git a/BetterPolus/BetterPolus.csproj b/BetterPolus/BetterPolus.csproj index 24ad338..de6bc65 100644 --- a/BetterPolus/BetterPolus.csproj +++ b/BetterPolus/BetterPolus.csproj @@ -10,7 +10,7 @@ - + all diff --git a/BetterPolus/BetterPolusPlugin.cs b/BetterPolus/BetterPolusPlugin.cs index 10b134e..4ccac05 100644 --- a/BetterPolus/BetterPolusPlugin.cs +++ b/BetterPolus/BetterPolusPlugin.cs @@ -12,21 +12,21 @@ public class BetterPolusPlugin : BasePlugin { private const string Id = "ch.brybry.betterpolus"; private const string Name = "BetterPolus Mod"; - public const string Version = "1.2.1"; + public const string Version = "1.2.2"; - public Harmony Harmony { get; } = new Harmony(Id); - public static ManualLogSource log; + private Harmony Harmony { get; } = new(Id); + public static ManualLogSource Logger { get; private set; } public static ConfigEntry Enabled { get; private set; } public static ConfigEntry ReactorCountdown { get; private set; } public override void Load() { - log = Log; + Logger = Log; Enabled = Config.Bind("Polus", "Enable Better Polus", true, "Enable Polus map modifications"); ReactorCountdown = Config.Bind("Polus", "Reactor Countdown", 40f, "Reactor sabotage countdown in Polus map"); - log.LogMessage($"{Name} loaded"); + Logger.LogMessage($"{Name} loaded"); Harmony.PatchAll(); } diff --git a/BetterPolus/Patches/ReactorSystemTypePatches.cs b/BetterPolus/Patches/ReactorSystemTypePatches.cs index eb79446..c50f70e 100644 --- a/BetterPolus/Patches/ReactorSystemTypePatches.cs +++ b/BetterPolus/Patches/ReactorSystemTypePatches.cs @@ -1,18 +1,42 @@ using HarmonyLib; +using Hazel; +using Il2CppSystem; namespace BetterPolus.Patches; [HarmonyPatch(typeof(ReactorSystemType))] public static class ReactorSystemTypePatches { - [HarmonyPatch(nameof(ReactorSystemType.RepairDamage))] + [HarmonyPatch(nameof(ReactorSystemType.UpdateSystem))] [HarmonyPrefix] - private static bool RepairDamagePrefix(ReactorSystemType __instance, PlayerControl player, byte opCode) + private static bool UpdateSystemPrefix(ReactorSystemType __instance, PlayerControl player, MessageReader msgReader) { - if (ShipStatus.Instance.Type != ShipStatus.MapType.Pb || opCode != 128 || __instance.IsActive) return true; - - __instance.Countdown = BetterPolusPlugin.ReactorCountdown.Value; - __instance.UserConsolePairs.Clear(); + var self = msgReader.ReadByte(); + var num = self & 3; + if (self == 128 && !__instance.IsActive) + { + __instance.Countdown = ShipStatus.Instance.Type != ShipStatus.MapType.Pb + ? __instance.ReactorDuration + : BetterPolusPlugin.ReactorCountdown.Value; + __instance.UserConsolePairs.Clear(); + } + else if (self == 16) + { + __instance.Countdown = 10000f; + } + else if (self.HasAnyBit(64)) + { + __instance.UserConsolePairs.Add(new Tuple(player.PlayerId, (byte) num)); + if (__instance.UserCount >= 2) + { + __instance.Countdown = 10000f; + } + } + else if (self.HasAnyBit(32)) + { + __instance.UserConsolePairs.Remove(new Tuple(player.PlayerId, (byte) num)); + } + __instance.IsDirty = true; return false; diff --git a/BetterPolus/Patches/ShipStatusPatches.cs b/BetterPolus/Patches/ShipStatusPatches.cs index 69719f2..c069c7c 100644 --- a/BetterPolus/Patches/ShipStatusPatches.cs +++ b/BetterPolus/Patches/ShipStatusPatches.cs @@ -74,7 +74,7 @@ public static class ShipStatusPatches } else { - BetterPolusPlugin.log.LogError("Couldn't move elements as not all of them have been fetched."); + BetterPolusPlugin.Logger.LogError("Couldn't move elements as not all of them have been fetched."); } AdjustVents(); @@ -196,7 +196,7 @@ public static class ShipStatusPatches } else { - BetterPolusPlugin.log.LogError("Couldn't adjust Vents as not all objects have been fetched."); + BetterPolusPlugin.Logger.LogError("Couldn't adjust Vents as not all objects have been fetched."); } } diff --git a/README.md b/README.md index b26e441..c89da18 100644 --- a/README.md +++ b/README.md @@ -88,6 +88,7 @@ There are two ways to install the mod : ## Releases | Among Us Version | Mod Version | All-in-one pack | DLL file | |------------------|-----------------|:---------------------------------------------------------------------------------------------------------------------------:|:-------------------------------------------------------------------------------------------------------------:| + | v2023.10.24+ | Ver. 1.2.2 | **[Download](https://github.com/Brybry16/BetterPolus/releases/download/v1.2.2/BetterPolus_All-in-one-Pack-1.2.2.zip)** | **[Download](https://github.com/Brybry16/BetterPolus/releases/download/v1.2.2/BetterPolus.dll)** | | v2023.7.12+ | Ver. 1.2.1 | **[Download](https://github.com/Brybry16/BetterPolus/releases/download/v1.2.1/BetterPolus_All-in-one-Pack-1.2.1.zip)** | **[Download](https://github.com/Brybry16/BetterPolus/releases/download/v1.2.1/BetterPolus.dll)** | | v2023.6.13+ | Ver. 1.2.0be670 | **[Download](https://github.com/Brybry16/BetterPolus/releases/download/v1.2.0/BetterPolus_All-in-one-Pack-1.2.0be670.zip)** | **[Download](https://github.com/Brybry16/BetterPolus/releases/download/v1.2.0/BetterPolus.dll)** | | v2022.10.25+ | Ver. 1.2.0 | **[Download](https://github.com/Brybry16/BetterPolus/releases/download/v1.2.0/BetterPolus_All-in-one-Pack-1.2.0.zip)** | **[Download](https://github.com/Brybry16/BetterPolus/releases/download/v1.2.0/BetterPolus.dll)** | @@ -99,6 +100,12 @@ There are two ways to install the mod : | v2020.12.9s | Ver. 1.0 | **[Download](https://github.com/Brybry16/BetterPolus/releases/download/v1.0.0/BetterPolus_All-in-one-Pack.zip)** | **[Download](https://github.com/Brybry16/BetterPolus/releases/download/v1.0.0/BetterPolus-2020.12.9s.dll)** | ### Changelog +
+ Version 1.2.2 +
    +
  • Added compatibility with Among Us v2023.10.24
  • +
+
Version 1.2.1