using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Hazel;
using Il2CppSystem;
using Il2CppSystem.Text;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("Brybry")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("An Among Us mod that tweaks Polus, allowing a more balanced experience.")]
[assembly: AssemblyFileVersion("1.2.2.0")]
[assembly: AssemblyInformationalVersion("1.2.2")]
[assembly: AssemblyProduct("BetterPolus")]
[assembly: AssemblyTitle("BetterPolus")]
[assembly: AssemblyVersion("1.2.2.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace BetterPolus
{
[BepInPlugin("ch.brybry.betterpolus", "BetterPolus Mod", "1.2.2")]
[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.2";
private Harmony Harmony { get; } = new Harmony("ch.brybry.betterpolus");
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()
{
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Expected O, but got Unknown
Logger = ((BasePlugin)this).Log;
Enabled = ((BasePlugin)this).Config.Bind<bool>("Polus", "Enable Better Polus", true, "Enable Polus map modifications");
ReactorCountdown = ((BasePlugin)this).Config.Bind<float>("Polus", "Reactor Countdown", 40f, "Reactor sabotage countdown in Polus map");
ManualLogSource logger = Logger;
bool flag = default(bool);
BepInExMessageLogInterpolatedStringHandler val = new BepInExMessageLogInterpolatedStringHandler(7, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("BetterPolus Mod");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" loaded");
}
logger.LogMessage(val);
Harmony.PatchAll();
}
}
}
namespace BetterPolus.Patches
{
[HarmonyPatch(typeof(AmongUsClient))]
public static class AmongUsClientPatches
{
[HarmonyPatch("Awake")]
[HarmonyPrefix]
private static void AwakePrefix()
{
DestroyableSingleton<ModManager>.Instance.ShowModStamp();
}
}
[HarmonyPatch(typeof(NormalPlayerTask))]
public static class NormalPlayerTaskPatches
{
private static readonly List<TaskTypes> TaskTypesToPatch = new List<TaskTypes>
{
(TaskTypes)42,
(TaskTypes)41,
(TaskTypes)3
};
[HarmonyPatch("AppendTaskText")]
[HarmonyPrefix]
private static bool AppendTaskTextPrefix(NormalPlayerTask __instance, StringBuilder sb)
{
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Invalid comparison between Unknown and I4
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: Invalid comparison between Unknown and I4
if (!BetterPolusPlugin.Enabled.Value || !Object.op_Implicit((Object)(object)ShipStatus.Instance) || (int)ShipStatus.Instance.Type != 2)
{
return true;
}
if (!TaskTypesToPatch.Contains(((PlayerTask)__instance).TaskType))
{
return true;
}
bool flag = __instance.ShouldYellowText();
if (flag)
{
sb.Append(((PlayerTask)__instance).IsComplete ? "<color=#00DD00FF>" : "<color=#FFFF00FF>");
}
SystemTypes updatedRoom = GetUpdatedRoom(__instance);
sb.Append(DestroyableSingleton<TranslationController>.Instance.GetString(updatedRoom));
sb.Append(": ");
sb.Append(DestroyableSingleton<TranslationController>.Instance.GetString(((PlayerTask)__instance).TaskType));
if (__instance != null && __instance.ShowTaskTimer && (int)__instance.TimerStarted == 1)
{
sb.Append(" (");
sb.Append(DestroyableSingleton<TranslationController>.Instance.GetString((StringNames)389, (Object[])(object)new Object[1] { Object.op_Implicit((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)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Invalid comparison between Unknown and I4
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Invalid comparison between Unknown and I4
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Invalid comparison between Unknown and I4
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
TaskTypes taskType = ((PlayerTask)task).TaskType;
if ((int)taskType != 3)
{
if ((int)taskType != 41)
{
if ((int)taskType == 42)
{
return (SystemTypes)25;
}
return ((PlayerTask)task).StartAt;
}
return (SystemTypes)27;
}
return (SystemTypes)14;
}
}
[HarmonyPatch(typeof(ReactorSystemType))]
public static class ReactorSystemTypePatches
{
[HarmonyPatch("UpdateSystem")]
[HarmonyPrefix]
private static bool UpdateSystemPrefix(ReactorSystemType __instance, PlayerControl player, MessageReader msgReader)
{
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Invalid comparison between Unknown and I4
byte b = msgReader.ReadByte();
int num = b & 3;
if (b == 128 && !__instance.IsActive)
{
__instance.Countdown = (((int)ShipStatus.Instance.Type != 2) ? __instance.ReactorDuration : BetterPolusPlugin.ReactorCountdown.Value);
__instance.UserConsolePairs.Clear();
}
else if (b == 16)
{
__instance.Countdown = 10000f;
}
else if (Extensions.HasAnyBit(b, (byte)64))
{
__instance.UserConsolePairs.Add(new Tuple<byte, byte>(player.PlayerId, (byte)num));
if (__instance.UserCount >= 2)
{
__instance.Countdown = 10000f;
}
}
else if (Extensions.HasAnyBit(b, (byte)32))
{
__instance.UserConsolePairs.Remove(new Tuple<byte, byte>(player.PlayerId, (byte)num));
}
__instance.IsDirty = true;
return false;
}
}
[HarmonyPatch(typeof(ShipStatus))]
public static class ShipStatusPatches
{
public static readonly Vector3 DvdScreenNewPos = new Vector3(26.635f, -15.92f, 1f);
public static readonly Vector3 VitalsNewPos = new Vector3(31.275f, -6.45f, 1f);
public static readonly Vector3 WifiNewPos = new Vector3(15.975f, 0.084f, 1f);
public static readonly Vector3 NavNewPos = new Vector3(11.07f, -15.298f, -0.015f);
public static readonly Vector3 TempColdNewPos = new Vector3(7.772f, -17.103f, -0.017f);
public const float DvdScreenNewScale = 0.75f;
public static bool IsAdjustmentsDone;
public static bool IsObjectsFetched;
public static bool IsRoomsFetched;
public static bool IsVentsFetched;
public static Console WifiConsole;
public static Console NavConsole;
public static SystemConsole Vitals;
public static GameObject DvdScreenOffice;
public static Vent ElectricBuildingVent;
public static Vent ElectricalVent;
public static Vent ScienceBuildingVent;
public static Vent StorageVent;
public static Console TempCold;
public static GameObject Comms;
public static GameObject DropShip;
public static GameObject Outside;
public static GameObject Science;
private static void ApplyChanges(ShipStatus instance)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Invalid comparison between Unknown and I4
if ((int)instance.Type == 2 && BetterPolusPlugin.Enabled.Value)
{
FindPolusObjects();
AdjustPolus();
}
}
public static void FindPolusObjects()
{
FindVents();
FindRooms();
FindObjects();
}
public static void AdjustPolus()
{
if (IsObjectsFetched && IsRoomsFetched)
{
MoveVitals();
SwitchNavWifi();
MoveTempCold();
}
else
{
BetterPolusPlugin.Logger.LogError((object)"Couldn't move elements as not all of them have been fetched.");
}
AdjustVents();
IsAdjustmentsDone = true;
}
public static void FindVents()
{
List<Vent> list = ((IEnumerable<Vent>)Object.FindObjectsOfType<Vent>()).ToList();
if ((Object)(object)ElectricBuildingVent == (Object)null)
{
ElectricBuildingVent = list.Find((Vent vent) => ((Object)((Component)vent).gameObject).name == "ElectricBuildingVent");
}
if ((Object)(object)ElectricalVent == (Object)null)
{
ElectricalVent = list.Find((Vent vent) => ((Object)((Component)vent).gameObject).name == "ElectricalVent");
}
if ((Object)(object)ScienceBuildingVent == (Object)null)
{
ScienceBuildingVent = list.Find((Vent vent) => ((Object)((Component)vent).gameObject).name == "ScienceBuildingVent");
}
if ((Object)(object)StorageVent == (Object)null)
{
StorageVent = list.Find((Vent vent) => ((Object)((Component)vent).gameObject).name == "StorageVent");
}
IsVentsFetched = (Object)(object)ElectricBuildingVent != (Object)null && (Object)(object)ElectricalVent != (Object)null && (Object)(object)ScienceBuildingVent != (Object)null && (Object)(object)StorageVent != (Object)null;
}
public static void FindRooms()
{
if ((Object)(object)Comms == (Object)null)
{
Comms = ((IEnumerable<GameObject>)Object.FindObjectsOfType<GameObject>()).ToList().Find((GameObject o) => ((Object)o).name == "Comms");
}
if ((Object)(object)DropShip == (Object)null)
{
DropShip = ((IEnumerable<GameObject>)Object.FindObjectsOfType<GameObject>()).ToList().Find((GameObject o) => ((Object)o).name == "Dropship");
}
if ((Object)(object)Outside == (Object)null)
{
Outside = ((IEnumerable<GameObject>)Object.FindObjectsOfType<GameObject>()).ToList().Find((GameObject o) => ((Object)o).name == "Outside");
}
if ((Object)(object)Science == (Object)null)
{
Science = ((IEnumerable<GameObject>)Object.FindObjectsOfType<GameObject>()).ToList().Find((GameObject o) => ((Object)o).name == "Science");
}
IsRoomsFetched = (Object)(object)Comms != (Object)null && (Object)(object)DropShip != (Object)null && (Object)(object)Outside != (Object)null && (Object)(object)Science != (Object)null;
}
public static void FindObjects()
{
if ((Object)(object)WifiConsole == (Object)null)
{
WifiConsole = ((IEnumerable<Console>)Object.FindObjectsOfType<Console>()).ToList().Find((Console console) => ((Object)console).name == "panel_wifi");
}
if ((Object)(object)NavConsole == (Object)null)
{
NavConsole = ((IEnumerable<Console>)Object.FindObjectsOfType<Console>()).ToList().Find((Console console) => ((Object)console).name == "panel_nav");
}
if ((Object)(object)Vitals == (Object)null)
{
Vitals = ((IEnumerable<SystemConsole>)Object.FindObjectsOfType<SystemConsole>()).ToList().Find((SystemConsole console) => ((Object)console).name == "panel_vitals");
}
if ((Object)(object)DvdScreenOffice == (Object)null)
{
GameObject val = ((IEnumerable<GameObject>)Object.FindObjectsOfType<GameObject>()).ToList().Find((GameObject o) => ((Object)o).name == "dvdscreen");
if ((Object)(object)val != (Object)null)
{
DvdScreenOffice = Object.Instantiate<GameObject>(val);
}
}
if ((Object)(object)TempCold == (Object)null)
{
TempCold = ((IEnumerable<Console>)Object.FindObjectsOfType<Console>()).ToList().Find((Console console) => ((Object)console).name == "panel_tempcold");
}
IsObjectsFetched = (Object)(object)WifiConsole != (Object)null && (Object)(object)NavConsole != (Object)null && (Object)(object)Vitals != (Object)null && (Object)(object)DvdScreenOffice != (Object)null && (Object)(object)TempCold != (Object)null;
}
public static void AdjustVents()
{
if (IsVentsFetched)
{
ElectricBuildingVent.Left = ElectricalVent;
ElectricalVent.Center = ElectricBuildingVent;
ScienceBuildingVent.Left = StorageVent;
StorageVent.Center = ScienceBuildingVent;
}
else
{
BetterPolusPlugin.Logger.LogError((object)"Couldn't adjust Vents as not all objects have been fetched.");
}
}
public static void MoveTempCold()
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
if (((Component)TempCold).transform.position != TempColdNewPos)
{
Transform transform = ((Component)TempCold).transform;
transform.parent = Outside.transform;
transform.position = TempColdNewPos;
BoxCollider2D component = ((Component)TempCold).GetComponent<BoxCollider2D>();
((Collider2D)component).isTrigger = false;
component.size += new Vector2(0f, -0.3f);
}
}
public static void SwitchNavWifi()
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
if (((Component)WifiConsole).transform.position != WifiNewPos)
{
Transform transform = ((Component)WifiConsole).transform;
transform.parent = DropShip.transform;
transform.position = WifiNewPos;
}
if (((Component)NavConsole).transform.position != NavNewPos)
{
Transform transform2 = ((Component)NavConsole).transform;
transform2.parent = Comms.transform;
transform2.position = NavNewPos;
NavConsole.checkWalls = true;
}
}
public static void MoveVitals()
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: Unknown result type (might be due to invalid IL or missing references)
if (((Component)Vitals).transform.position != VitalsNewPos)
{
Transform transform = ((Component)Vitals).gameObject.transform;
transform.parent = Science.transform;
transform.position = VitalsNewPos;
}
if (DvdScreenOffice.transform.position != DvdScreenNewPos)
{
Transform transform2 = DvdScreenOffice.transform;
transform2.position = DvdScreenNewPos;
Vector3 localScale = transform2.localScale;
((Vector3)(ref localScale))..ctor(0.75f, localScale.y, localScale.z);
transform2.localScale = localScale;
}
}
[HarmonyPatch("Begin")]
[HarmonyPrefix]
private static void BeginPrefix(ShipStatus __instance)
{
ApplyChanges(__instance);
}
[HarmonyPatch("Awake")]
[HarmonyPrefix]
private static void AwakePrefix(ShipStatus __instance)
{
ApplyChanges(__instance);
}
[HarmonyPatch("FixedUpdate")]
[HarmonyPrefix]
private static void FixedUpdate(ShipStatus __instance)
{
if (!IsObjectsFetched || !IsAdjustmentsDone)
{
ApplyChanges(__instance);
}
}
}
[HarmonyPatch(typeof(VersionShower))]
public static class VersionShowerPatches
{
[HarmonyPatch("Start")]
[HarmonyPostfix]
private static void StartPostfix(VersionShower __instance)
{
TextMeshPro text = __instance.text;
((TMP_Text)text).text = ((TMP_Text)text).text + "<size=70%> + <color=#5E4CA6FF>BetterPolus v1.2.2</color> by Brybry</size>";
}
}
}