Skip to content

Commit

Permalink
Merge pull request #11 from EnoPM/main
Browse files Browse the repository at this point in the history
v2023.7.12+ support + config file entry + tasks room adjustment
  • Loading branch information
EnoPM authored Oct 2, 2023
2 parents e764e1d + 48c1e8a commit 3bbe0e4
Show file tree
Hide file tree
Showing 10 changed files with 448 additions and 374 deletions.
13 changes: 8 additions & 5 deletions BetterPolus/BetterPolus.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Version>1.2.0</Version>
<Version>1.2.1</Version>

<Description>An Among Us mod that tweaks Polus, allowing a more balanced experience.</Description>
<Authors>Brybry</Authors>
Expand All @@ -10,12 +10,15 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="AmongUs.GameLibs.Steam" Version="2022.10.25" />
<PackageReference Include="BepInEx.Unity.IL2CPP" Version="6.0.0-be.662" />
<PackageReference Include="BepInEx.IL2CPP.MSBuild" Version="2.0.1" />
<PackageReference Include="Reactor" Version="2.0.0" />
<PackageReference Include="AmongUs.GameLibs.Steam" Version="2023.7.11" />
<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>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>


<Target Name="Copy" AfterTargets="Build">
<Copy SourceFiles="$(OutputPath)$(AssemblyName).dll" DestinationFiles="$(AmongUs)/BepInEx/plugins/$(AssemblyName).dll" />
</Target>
Expand Down
58 changes: 22 additions & 36 deletions BetterPolus/BetterPolusPlugin.cs
Original file line number Diff line number Diff line change
@@ -1,47 +1,33 @@
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using BepInEx.Unity.IL2CPP;

namespace BetterPolus
{
[BepInPlugin(Id, Name, Version)]
[BepInProcess("Among Us.exe")]
public class BetterPolusPlugin : BasePlugin
{
public const string Id = "ch.brybry.betterpolus";
public const string Name = "BetterPolus Mod";
public const string Version = "1.2.0";
namespace BetterPolus;

public Harmony Harmony { get; } = new Harmony(Id);
public static ManualLogSource log;
[BepInPlugin(Id, Name, Version)]
[BepInProcess("Among Us.exe")]
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 override void Load()
{
log = Log;

log.LogMessage($"{Name} loaded");
public Harmony Harmony { get; } = new Harmony(Id);
public static ManualLogSource log;
public static ConfigEntry<bool> Enabled { get; private set; }
public static ConfigEntry<float> ReactorCountdown { get; private set; }

Harmony.PatchAll();
}
public override void Load()
{
log = Log;

[HarmonyPatch(typeof(VersionShower), nameof(VersionShower.Start))]
public static class VersionShowerPatch
{
public static void Postfix(VersionShower __instance)
{
__instance.text.text += $"<size=70%> + <color=#5E4CA6FF>BetterPolus v{Version}</color> by Brybry</size>";
}
}
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");

[HarmonyPatch(typeof(AmongUsClient), nameof(AmongUsClient.Awake))]
public static class ModStampPatch
{
[HarmonyPrefix]
public static void Prefix()
{
DestroyableSingleton<ModManager>.Instance.ShowModStamp();
}
}
Harmony.PatchAll();
}
}
}
14 changes: 14 additions & 0 deletions BetterPolus/Patches/AmongUsClientPatches.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using HarmonyLib;

namespace BetterPolus.Patches;

[HarmonyPatch(typeof(AmongUsClient))]
public static class AmongUsClientPatches
{
[HarmonyPatch(nameof(AmongUsClient.Awake))]
[HarmonyPrefix]
private static void AwakePrefix()
{
DestroyableSingleton<ModManager>.Instance.ShowModStamp();
}
}
66 changes: 66 additions & 0 deletions BetterPolus/Patches/NormalPlayerTaskPatches.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
using System.Collections.Generic;
using HarmonyLib;
using Il2CppSystem.Text;

namespace BetterPolus.Patches;

[HarmonyPatch(typeof(NormalPlayerTask))]
public static class NormalPlayerTaskPatches
{
private static readonly List<TaskTypes> TaskTypesToPatch = new()
{ TaskTypes.RebootWifi, TaskTypes.RecordTemperature, TaskTypes.ChartCourse };

[HarmonyPatch(nameof(NormalPlayerTask.AppendTaskText))]
[HarmonyPrefix]
private static bool AppendTaskTextPrefix(NormalPlayerTask __instance, StringBuilder sb)
{
if (!BetterPolusPlugin.Enabled.Value || !ShipStatus.Instance || ShipStatus.Instance.Type != ShipStatus.MapType.Pb) return true;
if (!TaskTypesToPatch.Contains(__instance.TaskType)) return true;
var flag = __instance.ShouldYellowText();
if (flag)
{
sb.Append(__instance.IsComplete ? "<color=#00DD00FF>" : "<color=#FFFF00FF>");
}

var room = GetUpdatedRoom(__instance);

sb.Append(DestroyableSingleton<TranslationController>.Instance.GetString(room));
sb.Append(": ");
sb.Append(DestroyableSingleton<TranslationController>.Instance.GetString(__instance.TaskType));
if (__instance is { ShowTaskTimer: true, TimerStarted: NormalPlayerTask.TimerState.Started })
{
sb.Append(" (");
sb.Append(DestroyableSingleton<TranslationController>.Instance.GetString(StringNames.SecondsAbbv,
(int)__instance.TaskTimer));
sb.Append(")");
}
else if (__instance.ShowTaskStep)
{
sb.Append(" (");
sb.Append(__instance.taskStep);
sb.Append("/");
sb.Append(__instance.MaxStep);
sb.Append(")");
}

if (flag)
{
sb.Append("</color>");
}

sb.AppendLine();

return false;
}

private static SystemTypes GetUpdatedRoom(NormalPlayerTask task)
{
return task.TaskType switch
{
TaskTypes.RecordTemperature => SystemTypes.Outside,
TaskTypes.RebootWifi => SystemTypes.Dropship,
TaskTypes.ChartCourse => SystemTypes.Comms,
_ => task.StartAt
};
}
}
20 changes: 20 additions & 0 deletions BetterPolus/Patches/ReactorSystemTypePatches.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using HarmonyLib;

namespace BetterPolus.Patches;

[HarmonyPatch(typeof(ReactorSystemType))]
public static class ReactorSystemTypePatches
{
[HarmonyPatch(nameof(ReactorSystemType.RepairDamage))]
[HarmonyPrefix]
private static bool RepairDamagePrefix(ReactorSystemType __instance, PlayerControl player, byte opCode)
{
if (ShipStatus.Instance.Type != ShipStatus.MapType.Pb || opCode != 128 || __instance.IsActive) return true;

__instance.Countdown = BetterPolusPlugin.ReactorCountdown.Value;
__instance.UserConsolePairs.Clear();
__instance.IsDirty = true;

return false;
}
}
Loading

0 comments on commit 3bbe0e4

Please sign in to comment.