using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using HarmonyLib;
using UnityEngine;
using UnityModManagerNet;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("IronBro Multiplayer Mod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("IronBro Multiplayer Mod")]
[assembly: AssemblyCopyright("Copyright © 2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("09d698d6-bb15-47aa-9964-302a3b0b53d2")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace IronBro_Multiplayer_Mod;
[HarmonyPatch(/*Could not decode attribute arguments.*/)]
internal static class GameModeController_AllowPlayerDropIn_Patch
{
public static void Postfix(GameModeController __instance, ref bool __result)
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Invalid comparison between Unknown and I4
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Invalid comparison between Unknown and I4
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Invalid comparison between Unknown and I4
if (Main.enabled)
{
__result = HeroController.InstanceExists && ((int)GameModeController.GameMode == 2 || (int)GameModeController.GameMode == 0 || (int)GameModeController.GameMode == 1 || GameModeController.IsHardcoreMode || ((int)GameModeController.GameMode != 7 && false));
}
}
}
[HarmonyPatch(typeof(GameModeController), "LevelFinish")]
internal static class GameModeController_LevelFinish_Patch
{
public static bool Prefix(GameModeController __instance, LevelResult result)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Invalid comparison between Unknown and I4
if (!Main.enabled || !Main.settings.helicopterWait)
{
return true;
}
if ((int)result != 1 || HeroController.GetPlayersOnHelicopterAmount() == 0)
{
return true;
}
if (HeroController.GetPlayersOnHelicopterAmount() == HeroController.GetPlayersAliveCount())
{
Helicopter_Leave_Patch.attachCalled = false;
Main.heli.Leave();
return true;
}
Main.control = __instance;
return false;
}
}
[HarmonyPatch(typeof(TestVanDammeAnim), "AttachToHelicopter")]
internal static class TestVanDammeAnim_AttachToHelicopter_Patch
{
public static void Prefix(TestVanDammeAnim __instance)
{
Helicopter_Leave_Patch.attachCalled = true;
}
}
[HarmonyPatch(typeof(Helicopter), "Leave")]
internal static class Helicopter_Leave_Patch
{
public static bool attachCalled;
public static bool Prefix(Helicopter __instance)
{
if (!Main.enabled || !Main.settings.helicopterWait)
{
return true;
}
if (HeroController.GetPlayersOnHelicopterAmount() == HeroController.GetPlayersAliveCount() || (HeroController.GetPlayersOnHelicopterAmount() == 0 && !attachCalled))
{
return true;
}
Main.heli = __instance;
return false;
}
}
[HarmonyPatch(typeof(Map), "StartLevelEndExplosions")]
internal static class Map_StartLevelEndExplosions_Patch
{
public static bool Prefix(Map __instance)
{
if (!Main.enabled || !Main.settings.helicopterWait)
{
return true;
}
if (HeroController.GetPlayersOnHelicopterAmount() == HeroController.GetPlayersAliveCount())
{
return true;
}
Main.map = __instance;
return false;
}
}
[HarmonyPatch(typeof(Player), "RemoveLife")]
internal static class Player_RemoveLife_Patch
{
public static void Postfix(Player __instance)
{
if (Main.enabled)
{
if (GameModeController.IsHardcoreMode && ((HeroController.GetPlayersOnHelicopterAmount() == HeroController.GetPlayersAliveCount() && HeroController.GetPlayersOnHelicopterAmount() > 0) || HeroController.GetTotalLives() == 0))
{
GameModeController.LevelFinish((LevelResult)3);
}
if (!GameModeController.IsHardcoreMode && HeroController.GetPlayersOnHelicopterAmount() == HeroController.GetPlayersAliveCount() && HeroController.GetPlayersOnHelicopterAmount() > 0)
{
GameModeController.LevelFinish((LevelResult)1);
}
}
}
}
[HarmonyPatch(typeof(Player), "SetLivesRPC")]
internal static class Player_SetLivesRPC_Patch
{
public static void Prefix(Player __instance, ref int _lives)
{
if (!Main.enabled || !GameModeController.IsHardcoreMode || HeroController.GetPlayersPlayingCount() <= 1)
{
return;
}
for (int i = 0; i < 4; i++)
{
if (i != __instance.playerNum && HeroController.IsPlayerPlaying(i))
{
HeroController.players[i].hud.SetLives(_lives);
}
}
}
}
[HarmonyPatch(/*Could not decode attribute arguments.*/)]
internal static class GameModeController_IsHardcoreMode_Patch
{
public static bool disableHardcoreCheck;
public static void Postfix(GameModeController __instance, ref bool __result)
{
if (disableHardcoreCheck)
{
__result = false;
}
}
}
[HarmonyPatch(typeof(PauseMenu), "HandlegamePausedChangedEvent")]
internal static class PauseMenu_ReturnToMenu_Patch
{
public static void Prefix()
{
GameModeController_IsHardcoreMode_Patch.disableHardcoreCheck = true;
}
public static void Postfix()
{
GameModeController_IsHardcoreMode_Patch.disableHardcoreCheck = false;
}
}
[HarmonyPatch(typeof(JoinScreen), "Start")]
internal static class JoinScreen_Start_Patch
{
public static void Prefix()
{
if (Main.enabled)
{
GameModeController_IsHardcoreMode_Patch.disableHardcoreCheck = true;
}
}
public static void Postfix()
{
if (Main.enabled)
{
GameModeController_IsHardcoreMode_Patch.disableHardcoreCheck = false;
}
}
}
[HarmonyPatch(typeof(JoinScreen), "Update")]
internal static class JoinScreen_Update_Patch
{
public static void Prefix()
{
if (Main.enabled)
{
GameModeController_IsHardcoreMode_Patch.disableHardcoreCheck = true;
}
}
public static void Postfix()
{
if (Main.enabled)
{
GameModeController_IsHardcoreMode_Patch.disableHardcoreCheck = false;
}
}
}
[HarmonyPatch(typeof(JoinScreen), "Join")]
internal static class JoinScreen_Join_Patch
{
public static void Prefix(JoinScreen __instance)
{
if (Main.enabled)
{
GameModeController_IsHardcoreMode_Patch.disableHardcoreCheck = true;
}
}
public static void Postfix(JoinScreen __instance)
{
if (Main.enabled)
{
GameModeController_IsHardcoreMode_Patch.disableHardcoreCheck = false;
}
}
}
[HarmonyPatch(typeof(HeroController), "DropoutRPC")]
internal static class HeroController_DropoutRPC_Patch
{
public static void Postfix(HeroController __instance)
{
if (Main.enabled && GameModeController.IsHardcoreMode)
{
HeroController.Instance.IDroppedOutThisRound = false;
}
}
}
internal static class Main
{
public static ModEntry mod;
public static bool enabled;
public static Settings settings;
public static int playersFinished;
public static GameModeController control;
public static Map map;
public static Helicopter heli;
private static bool Load(ModEntry modEntry)
{
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
modEntry.OnGUI = OnGUI;
modEntry.OnSaveGUI = OnSaveGUI;
modEntry.OnToggle = OnToggle;
settings = ModSettings.Load<Settings>(modEntry);
Harmony val = new Harmony(modEntry.Info.Id);
Assembly executingAssembly = Assembly.GetExecutingAssembly();
val.PatchAll(executingAssembly);
mod = modEntry;
return true;
}
private static void OnGUI(ModEntry modEntry)
{
settings.helicopterWait = GUILayout.Toggle(settings.helicopterWait, "Helicopter waits for all players", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(300f) });
}
private static void OnSaveGUI(ModEntry modEntry)
{
((ModSettings)settings).Save(modEntry);
}
private static bool OnToggle(ModEntry modEntry, bool value)
{
enabled = value;
return true;
}
public static void Log(string str)
{
if (mod != null)
{
mod.Logger.Log(str);
}
}
}
public class Settings : ModSettings
{
public bool helicopterWait;
public override void Save(ModEntry modEntry)
{
ModSettings.Save<Settings>(this, modEntry);
}
}