-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from EnoPM/main
v2023.7.12+ support + config file entry + tasks room adjustment
- Loading branch information
Showing
10 changed files
with
448 additions
and
374 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
Oops, something went wrong.