Skip to content

Commit

Permalink
Merge pull request #12 from EnoPM/main
Browse files Browse the repository at this point in the history
Among Us v2023.10.24 support
  • Loading branch information
EnoPM committed Nov 6, 2023
2 parents 3bbe0e4 + 0efbce9 commit 1971638
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 14 deletions.
2 changes: 1 addition & 1 deletion BetterPolus/BetterPolus.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="AmongUs.GameLibs.Steam" Version="2023.7.11" />
<PackageReference Include="AmongUs.GameLibs.Steam" Version="2023.10.24" />
<PackageReference Include="BepInEx.Unity.IL2CPP" Version="6.0.0-be.672" />
<PackageReference Include="BepInEx.IL2CPP.MSBuild" Version="2.1.0-rc.1">
<PrivateAssets>all</PrivateAssets>
Expand Down
10 changes: 5 additions & 5 deletions BetterPolus/BetterPolusPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<bool> Enabled { get; private set; }
public static ConfigEntry<float> 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();
}
Expand Down
36 changes: 30 additions & 6 deletions BetterPolus/Patches/ReactorSystemTypePatches.cs
Original file line number Diff line number Diff line change
@@ -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<byte, byte>(player.PlayerId, (byte) num));
if (__instance.UserCount >= 2)
{
__instance.Countdown = 10000f;
}
}
else if (self.HasAnyBit(32))
{
__instance.UserConsolePairs.Remove(new Tuple<byte, byte>(player.PlayerId, (byte) num));
}

__instance.IsDirty = true;

return false;
Expand Down
4 changes: 2 additions & 2 deletions BetterPolus/Patches/ShipStatusPatches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public static void AdjustPolus()
}
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();
Expand Down Expand Up @@ -196,7 +196,7 @@ public static void AdjustVents()
}
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.");
}
}

Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)** |
Expand All @@ -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
<details>
<summary>Version 1.2.2</summary>
<ul>
<li>Added compatibility with Among Us v2023.10.24</li>
</ul>
</details>
<details>
<summary>Version 1.2.1</summary>
<ul>
Expand Down

0 comments on commit 1971638

Please sign in to comment.