Decompiled source of NoStageEffects v1.3.0

NoStageEffects.dll

Decompiled 19 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using LLBML.Utils;
using Microsoft.CodeAnalysis;
using StageBackground;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyCompany("NoStageEffects")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.3.0.0")]
[assembly: AssemblyInformationalVersion("1.3.0+364979c886b60f55f5400554dbcc3d7fe2e71bdc")]
[assembly: AssemblyProduct("NoStageEffects")]
[assembly: AssemblyTitle("NoStageEffects")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.3.0.0")]
[module: UnverifiableCode]
[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 NoStageEffects
{
	internal static class Configs
	{
		private static ConfigFile config;

		internal static ConfigEntry<bool> DoShockwaveEffect { get; private set; }

		internal static ConfigEntry<bool> DoEclipseEffect { get; private set; }

		internal static ConfigEntry<bool> DoHeavenEffect { get; private set; }

		internal static ConfigEntry<bool> DoKOCamera { get; private set; }

		internal static ConfigEntry<bool> DoStageIntros { get; private set; }

		internal static ConfigEntry<bool> DoElevatorMove { get; private set; }

		internal static ConfigEntry<bool> DoSubwayMove { get; private set; }

		internal static ConfigEntry<bool> DoStadiumScreen { get; private set; }

		internal static ConfigEntry<bool> DoStreetsDrones { get; private set; }

		internal static ConfigEntry<bool> DoPoolBlimp { get; private set; }

		internal static ConfigEntry<bool> DoFactoryBuckets { get; private set; }

		internal static ConfigEntry<bool> DoSewersSubmarine { get; private set; }

		internal static void Init()
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Expected O, but got Unknown
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Expected O, but got Unknown
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Expected O, but got Unknown
			config = ((BaseUnityPlugin)Plugin.Instance).Config;
			config.Bind<string>("General Effects", "mm_header_general", "General Effects", new ConfigDescription("", (AcceptableValueBase)null, new object[1] { "modmenu_header" }));
			DoShockwaveEffect = config.Bind<bool>("Toggles", "ShockwaveEffect", false, "Camera glitch and impact wave effect when the ball is hit");
			DoEclipseEffect = config.Bind<bool>("Toggles", "EclipseEffect", false, "Stage transition at 250 ball speed");
			DoHeavenEffect = config.Bind<bool>("Toggles", "HeavenEffect", false, "Pure white stage effect at 1,000,000 ball speed");
			DoKOCamera = config.Bind<bool>("Toggles", "KOCamera", false, "Cinematic camera on kill in local games");
			DoStageIntros = config.Bind<bool>("Toggles", "StageIntros", false, "Intro cutscene in local games");
			config.Bind<int>("gap", "mm_header_gap", 50, new ConfigDescription("", (AcceptableValueBase)null, new object[1] { "modmenu_gap" }));
			config.Bind<string>("Stage Animations", "mm_header_stages", "Stage Animations", new ConfigDescription("", (AcceptableValueBase)null, new object[1] { "modmenu_header" }));
			DoElevatorMove = config.Bind<bool>("Toggles", "ElevatorMove", false, "Elevator moves between floors");
			DoSubwayMove = config.Bind<bool>("Toggles", "SubwayMove", false, "Subway moves between stations and makes turns");
			DoStadiumScreen = config.Bind<bool>("Toggles", "StadiumScreen", false, "Stadium screen shows players and ball");
			DoStreetsDrones = config.Bind<bool>("Toggles", "StreetsDrones", false, "Drones appear on Streets");
			DoPoolBlimp = config.Bind<bool>("Toggles", "PoolBlimp", false, "Large blimp appears on Pool");
			DoFactoryBuckets = config.Bind<bool>("Toggles", "FactoryBuckets", false, "Iron buckets appear on Factory");
			DoSewersSubmarine = config.Bind<bool>("Toggles", "SewersSubmarine", false, "Submarine appears on Sewers");
			ModDependenciesUtils.RegisterToModMenu(((BaseUnityPlugin)Plugin.Instance).Info, new List<string>(2) { "This mod allows you to disable distracting stage effects and animations", "All effects are disabled by default" });
		}
	}
	internal static class HarmonyPatches
	{
		private static class ScreenEffects
		{
			private static bool BGIntro;

			[HarmonyPatch(typeof(BG), "StartUp")]
			[HarmonyPostfix]
			private static void StartUp_Postfix()
			{
				BGIntro = false;
			}

			[HarmonyPatch(typeof(BG), "SetState")]
			[HarmonyPrefix]
			private static void SetState_Prefix(ref BGState state, ref bool stageReset)
			{
				if (!BGIntro)
				{
					BGIntro = true;
				}
				else if ((((int)state == 2) | stageReset) && !Configs.DoEclipseEffect.Value)
				{
					Plugin.LogGlobal.LogInfo((object)"Blocking attempt to activate BG state ECLIPSE");
					state = (BGState)1;
					stageReset = false;
				}
				else if ((int)state == 3 && !Configs.DoHeavenEffect.Value)
				{
					Plugin.LogGlobal.LogInfo((object)"Blocking attempt to activate BG state HEAVEN");
					state = (BGState)1;
				}
			}

			[HarmonyPatch(typeof(GameCamera), "StartWave")]
			[HarmonyPrefix]
			private static bool StartWave_Prefix()
			{
				return Configs.DoShockwaveEffect.Value;
			}

			[HarmonyPatch(typeof(GameCamera), "StartGlitchWave")]
			[HarmonyPrefix]
			private static bool StartGlitchWave_Prefix()
			{
				return Configs.DoShockwaveEffect.Value;
			}

			[HarmonyPatch(typeof(World), "ActivateKOCamMode")]
			[HarmonyPrefix]
			private static bool ActivateKOCamMode_Prefix()
			{
				return Configs.DoKOCamera.Value;
			}

			[HarmonyPatch(/*Could not decode attribute arguments.*/)]
			[HarmonyTranspiler]
			private static IEnumerable<CodeInstruction> KGameStart_MoveNext_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator il)
			{
				//IL_0003: Unknown result type (might be due to invalid IL or missing references)
				//IL_0009: Expected O, but got Unknown
				//IL_0026: Unknown result type (might be due to invalid IL or missing references)
				//IL_002c: Expected O, but got Unknown
				//IL_003a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0040: Expected O, but got Unknown
				//IL_004e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0054: Expected O, but got Unknown
				//IL_0062: Unknown result type (might be due to invalid IL or missing references)
				//IL_0068: Expected O, but got Unknown
				//IL_0076: Unknown result type (might be due to invalid IL or missing references)
				//IL_007c: Expected O, but got Unknown
				//IL_008a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0090: Expected O, but got Unknown
				//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d4: Expected O, but got Unknown
				CodeMatcher val = new CodeMatcher(instructions, il);
				val.Start();
				val.MatchForward(true, (CodeMatch[])(object)new CodeMatch[6]
				{
					new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null),
					new CodeMatch((OpCode?)OpCodes.Ldfld, (object)null, (string)null),
					new CodeMatch((OpCode?)OpCodes.Call, (object)null, (string)null),
					new CodeMatch((OpCode?)OpCodes.Brtrue, (object)null, (string)null),
					new CodeMatch((OpCode?)OpCodes.Call, (object)null, (string)null),
					new CodeMatch((OpCode?)OpCodes.Brtrue, (object)null, (string)null)
				});
				CodeInstruction instruction = val.Instruction;
				val.Insert((CodeInstruction[])(object)new CodeInstruction[2]
				{
					Transpilers.EmitDelegate<Func<bool>>((Func<bool>)delegate
					{
						if (!Configs.DoStageIntros.Value)
						{
							Plugin.LogGlobal.LogInfo((object)"Skipping stage intro cutscene");
						}
						return !Configs.DoStageIntros.Value;
					}),
					new CodeInstruction(instruction)
				});
				return val.InstructionEnumeration();
			}
		}

		public static class StagePatches
		{
			private static bool SubwayIntro;

			[HarmonyPatch(typeof(ElevatorScript), "SetState")]
			[HarmonyPrefix]
			private static void Elevator_SetState_Prefix(ref ElevatorState setState)
			{
				if (!Configs.DoElevatorMove.Value && (int)setState != 8 && (int)setState != 6 && setState)
				{
					Plugin.LogGlobal.LogInfo((object)"Stopping Elevator movement");
					setState = (ElevatorState)7;
				}
			}

			[HarmonyPatch(typeof(ElevatorScript), "StopFalling")]
			[HarmonyPostfix]
			private static void Elevator_StopFalling_Postfix(ElevatorScript __instance)
			{
				//IL_0025: Unknown result type (might be due to invalid IL or missing references)
				//IL_0037: Unknown result type (might be due to invalid IL or missing references)
				if (!Configs.DoElevatorMove.Value)
				{
					__instance.currentFloor = 0;
					__instance.targetFloor = 2;
					__instance.worldTf.position = Vector3.up * __instance.floorPos[__instance.targetFloor];
				}
			}

			[HarmonyPatch(typeof(TrainScript), "Start")]
			[HarmonyPostfix]
			private static void Subway_Start_Postfix(TrainScript __instance)
			{
				if (!Configs.DoSubwayMove.Value)
				{
					SubwayIntro = false;
					__instance.SetState((TrainAnimationType)4);
					SubwayIntro = true;
					Plugin.LogGlobal.LogInfo((object)"Disabling Subway train movement");
				}
			}

			[HarmonyPatch(typeof(TrainScript), "SetState")]
			[HarmonyPrefix]
			private static void Subway_SetState_Prefix(ref TrainAnimationType state)
			{
				if (SubwayIntro && !Configs.DoSubwayMove.Value)
				{
					state = (TrainAnimationType)0;
				}
			}

			[HarmonyPatch(typeof(DroneScript), "StartDroneSequence")]
			[HarmonyPrefix]
			private static bool Streets_StartDroneSequence_Prefix()
			{
				if (!Configs.DoStreetsDrones.Value)
				{
					Plugin.LogGlobal.LogInfo((object)"Disabling Streets drones");
				}
				return Configs.DoStreetsDrones.Value;
			}

			[HarmonyPatch(typeof(BlimpScript), "Update")]
			[HarmonyPrefix]
			private static bool Pool_Update_Prefix(BlimpScript __instance)
			{
				if (Configs.DoPoolBlimp.Value)
				{
					return true;
				}
				if (((Object)((Component)__instance).gameObject).name != "Blimp_Animated 2")
				{
					return true;
				}
				Plugin.LogGlobal.LogInfo((object)"Disabling Pool big blimp");
				((Component)__instance).gameObject.SetActive(false);
				return false;
			}

			[HarmonyPatch(typeof(AssemblyScript), "Start")]
			[HarmonyPostfix]
			private static void Factory_Start_Postfix(AssemblyScript __instance)
			{
				if (!Configs.DoFactoryBuckets.Value)
				{
					Plugin.LogGlobal.LogInfo((object)"Disabling Factory buckets");
					__instance.animbucket1["ironBucketTrack"].enabled = false;
					__instance.animbucket2["ironBucketTrack"].enabled = false;
					__instance.animbucket3["ironBucketTrack"].enabled = false;
					__instance.animbucket4["ironBucketTrack"].enabled = false;
				}
			}

			[HarmonyPatch(typeof(Stadium_ScreenCamController), "Awake")]
			[HarmonyPostfix]
			private static void Stadium_Awake_Postfix(Stadium_ScreenCamController __instance)
			{
				if (!Configs.DoStadiumScreen.Value)
				{
					Plugin.LogGlobal.LogInfo((object)"Disabling Stadium screen");
					__instance.OnEclipse(true);
				}
			}

			[HarmonyPatch(typeof(Stadium_ScreenCamController), "OnEclipse")]
			[HarmonyPrefix]
			private static void Stadium_OnEclipse_Prefix(ref bool pEclipseActive)
			{
				if (!(Configs.DoStadiumScreen.Value | pEclipseActive))
				{
					Plugin.LogGlobal.LogInfo((object)"Disabling Stadium screen");
					pEclipseActive = true;
				}
			}

			[HarmonyPatch(typeof(SubmarineScript), "StartAnim")]
			[HarmonyPrefix]
			private static bool Sewers_StartAnim_Prefix()
			{
				if (!Configs.DoSewersSubmarine.Value)
				{
					Plugin.LogGlobal.LogInfo((object)"Disabling Sewers submarine");
				}
				return Configs.DoSewersSubmarine.Value;
			}
		}

		internal static void PatchAll()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			Harmony val = new Harmony("avgduck.plugins.llb.nostageeffects");
			val.PatchAll(typeof(ScreenEffects));
			Plugin.LogGlobal.LogInfo((object)"Screen effects patches applied");
			val.PatchAll(typeof(StagePatches));
			Plugin.LogGlobal.LogInfo((object)"Stage animation patches applied");
		}
	}
	[BepInPlugin("avgduck.plugins.llb.nostageeffects", "NoStageEffects", "1.3.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		public const string GUID = "avgduck.plugins.llb.nostageeffects";

		public static Plugin Instance { get; private set; }

		internal static ManualLogSource LogGlobal { get; private set; }

		private void Awake()
		{
			Instance = this;
			LogGlobal = ((BaseUnityPlugin)this).Logger;
			Configs.Init();
			HarmonyPatches.PatchAll();
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "NoStageEffects";

		public const string PLUGIN_NAME = "NoStageEffects";

		public const string PLUGIN_VERSION = "1.3.0";
	}
}