Decompiled source of StageBlocks v1.0.4

plugins/StageBlocks/stageBlocksPorted.dll

Decompiled 11 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameplayEntities;
using HarmonyLib;
using LLBML.Math;
using LLBML.Utils;
using LLHandlers;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("FixedCameraPlusPlus")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("FixedCameraPlusPlus")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("664de4af-aa69-4f3a-9e6b-dd07c879adf5")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.1.0")]
[module: UnverifiableCode]
namespace StageBlocks;

[BepInPlugin("us.wallace.plugins.llb.stageBlocksPorted", "StageBlocks", "1.0.3")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInProcess("LLBlaze.exe")]
public class StageBlocks : BaseUnityPlugin
{
	private class NitroStuckFix
	{
		[HarmonyTranspiler]
		[HarmonyPatch(typeof(BallEntity), "UpdateState", new Type[] { })]
		public static IEnumerable<CodeInstruction> UpdateState_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator iL)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Expected O, but got Unknown
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Expected O, but got Unknown
			CodeMatcher val = new CodeMatcher(instructions, iL);
			val.MatchForward(true, (CodeMatch[])(object)new CodeMatch[3]
			{
				new CodeMatch((OpCode?)OpCodes.Ldloc_3, (object)null, (string)null),
				new CodeMatch((OpCode?)OpCodes.Callvirt, (object)null, (string)null),
				new CodeMatch((OpCode?)OpCodes.Br, (object)null, (string)null)
			});
			try
			{
				val.Insert((CodeInstruction[])(object)new CodeInstruction[2]
				{
					new CodeInstruction(OpCodes.Ldarg_0, (object)null),
					Transpilers.EmitDelegate<Action<BallEntity>>((Action<BallEntity>)delegate(BallEntity __instance)
					{
						//IL_0040: Unknown result type (might be due to invalid IL or missing references)
						//IL_0045: Unknown result type (might be due to invalid IL or missing references)
						//IL_0054: Unknown result type (might be due to invalid IL or missing references)
						//IL_006b: Unknown result type (might be due to invalid IL or missing references)
						//IL_0070: Unknown result type (might be due to invalid IL or missing references)
						//IL_007f: Unknown result type (might be due to invalid IL or missing references)
						//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
						//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
						//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
						PlayerEntity playerEntity = PlayerHandler.instance.GetPlayerEntity(((GetHitBallEntity)__instance).ballData.cuffBallOwner);
						CopPlayer val2 = (CopPlayer)(object)((playerEntity is CopPlayer) ? playerEntity : null);
						if (((MovableData)((AbilityEntity)val2).abilityData).abilityState == "CUFF_HOOKSHOT" && HHBCPNCDNDH.HPLPMEAOJPM(HHBCPNCDNDH.NPDCPLFLLIG(((EntityData)((MovableEntity)val2).moveableData).velocity.GCPKPHMKLBN), HHBCPNCDNDH.NKKIFJJEPOL(0.5m)) && HHBCPNCDNDH.HPLPMEAOJPM(HHBCPNCDNDH.NPDCPLFLLIG(((EntityData)((MovableEntity)val2).moveableData).velocity.CGJJEHPPOAN), HHBCPNCDNDH.NKKIFJJEPOL(0.5m)))
						{
							((MovableEntity)val2).SetAbilityState("CUFF_NEUTRAL_STAY");
							((AnimatableEntity)val2).PlayAnim("cuffPull", "main");
							((AbilityEntity)val2).abilityData.specialHeading = (Side)5;
							((EntityData)((PlayerEntity)val2).playerData).velocity = IBGCBLLKIHA.GCPFGINDGEM();
							((HittingEntity)val2).GiveBall((BallState)22, __instance, false);
						}
					})
				});
			}
			catch (Exception ex)
			{
				Log.LogInfo((object)ex);
			}
			return val.InstructionEnumeration();
		}
	}

	private class WorldSetStageDimensionsPatch
	{
		[HarmonyPatch(typeof(World), "SetStageDimensions")]
		[HarmonyPostfix]
		public static void SetStageDimensions_Prefix(World __instance)
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: 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_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
			if (!customStageBlocks.Value || __instance.useStageBlocks)
			{
				return;
			}
			Instance.LoadConfig();
			if (!Instance.stageBlocks.ContainsKey(StageHandler.curStage))
			{
				return;
			}
			foreach (Rect item in Instance.stageBlocks[StageHandler.curStage])
			{
				Rect current = item;
				GameObject obj = GameObject.CreatePrimitive((PrimitiveType)3);
				obj.transform.rotation = Quaternion.identity;
				obj.transform.position = new Vector3(Floatf.op_Implicit(Floatf.op_Implicit(((Rect)(ref current)).center.x) * Floatf.op_Implicit(World.FPIXEL_SIZE)), Floatf.op_Implicit(Floatf.op_Implicit(((Rect)(ref current)).center.y) * Floatf.op_Implicit(World.FPIXEL_SIZE)));
				obj.transform.localScale = new Vector3(Floatf.op_Implicit(Floatf.op_Implicit(((Rect)(ref current)).size.x) * Floatf.op_Implicit(World.FPIXEL_SIZE)), Floatf.op_Implicit(Floatf.op_Implicit(((Rect)(ref current)).size.y) * Floatf.op_Implicit(World.FPIXEL_SIZE)), 1f);
				__instance.stageBlockList.Add(Boundsf.op_Implicit(new Boundsf(new Vector2f(Floatf.op_Implicit(((Rect)(ref current)).center.x), Floatf.op_Implicit(((Rect)(ref current)).center.y)) * Floatf.op_Implicit(World.FPIXEL_SIZE), new Vector2f(Floatf.op_Implicit(((Rect)(ref current)).size.x), Floatf.op_Implicit(((Rect)(ref current)).size.y)) * Floatf.op_Implicit(World.FPIXEL_SIZE))));
			}
		}
	}

	public static ConfigEntry<bool> customStageBlocks;

	public Dictionary<Stage, List<Rect>> stageBlocks = new Dictionary<Stage, List<Rect>>();

	private static readonly Dictionary<Stage, string> allStagesMapping = StringUtils.regularStagesNames.Union(StringUtils.retroStagesNames).ToDictionary((KeyValuePair<Stage, string> x) => x.Key, (KeyValuePair<Stage, string> x) => x.Value);

	private static readonly Dictionary<string, Stage> reverseStageMapping = allStagesMapping.ToDictionary((KeyValuePair<Stage, string> x) => x.Value, (KeyValuePair<Stage, string> x) => x.Key);

	public static ManualLogSource Log { get; private set; } = null;


	public static StageBlocks Instance { get; private set; }

	public string BlocksConfigPath => Path.Combine(ModdingFolder.GetModSubFolder(((BaseUnityPlugin)this).Info).FullName, "BlockConfig.txt");

	private void Awake()
	{
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: Expected O, but got Unknown
		//IL_0076: Unknown result type (might be due to invalid IL or missing references)
		//IL_007b: Unknown result type (might be due to invalid IL or missing references)
		Log = ((BaseUnityPlugin)this).Logger;
		Instance = this;
		((BaseUnityPlugin)this).Config.Bind<string>("Use Custom Stage Blocks", "mm_header_qol", "Use Custom Stage Blocks", new ConfigDescription("", (AcceptableValueBase)null, new object[1] { "modmenu_header" }));
		customStageBlocks = ((BaseUnityPlugin)this).Config.Bind<bool>("StageBlocksToggle", "enableCustomStageBlocks", false, (ConfigDescription)null);
		((BaseUnityPlugin)this).Logger.LogDebug((object)"liuberal poop hippie pronoun fortnite be farting pooping bacon epic, i love ivermectin flouride apartmentism");
		Harmony val = new Harmony("us.wallace.plugins.llb.stageBlocksPorted");
		val.PatchAll(typeof(WorldSetStageDimensionsPatch));
		val.PatchAll(typeof(NitroStuckFix));
		((BaseUnityPlugin)this).Logger.LogDebug((object)"allUnlockedPorted is loaded");
	}

	private void Start()
	{
		ModDependenciesUtils.RegisterToModMenu(((BaseUnityPlugin)this).Info, (List<string>)null);
		LoadConfig();
	}

	private void CreateConfig()
	{
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: Unknown result type (might be due to invalid IL or missing references)
		//IL_004f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0054: Unknown result type (might be due to invalid IL or missing references)
		//IL_0069: Unknown result type (might be due to invalid IL or missing references)
		//IL_0078: Unknown result type (might be due to invalid IL or missing references)
		//IL_007d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0092: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00db: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_0104: Unknown result type (might be due to invalid IL or missing references)
		//IL_0119: Unknown result type (might be due to invalid IL or missing references)
		//IL_0128: Unknown result type (might be due to invalid IL or missing references)
		//IL_012d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0142: Unknown result type (might be due to invalid IL or missing references)
		//IL_0151: Unknown result type (might be due to invalid IL or missing references)
		//IL_0156: Unknown result type (might be due to invalid IL or missing references)
		Dictionary<Stage, List<Rect>> config = new Dictionary<Stage, List<Rect>>
		{
			{
				(Stage)3,
				new List<Rect>
				{
					new Rect(new Vector2(-500f, 232f), new Vector2(250f, 54f)),
					new Rect(new Vector2(500f, 232f), new Vector2(250f, 54f)),
					new Rect(new Vector2(0f, 414f), new Vector2(250f, 105f)),
					new Rect(new Vector2(0f, 0f), new Vector2(250f, 54f))
				}
			},
			{
				(Stage)4,
				new List<Rect>
				{
					new Rect(new Vector2(-500f, 232f), new Vector2(250f, 54f)),
					new Rect(new Vector2(500f, 232f), new Vector2(250f, 54f)),
					new Rect(new Vector2(0f, 414f), new Vector2(250f, 105f)),
					new Rect(new Vector2(0f, 0f), new Vector2(250f, 54f))
				}
			}
		};
		using TextWriter writer = File.CreateText(BlocksConfigPath);
		WriteConfig(writer, config);
	}

	public void LoadConfig()
	{
		if (!File.Exists(BlocksConfigPath))
		{
			CreateConfig();
		}
		using TextReader reader = File.OpenText(BlocksConfigPath);
		ReadConfig(reader, stageBlocks);
	}

	public void WriteConfig(TextWriter writer, Dictionary<Stage, List<Rect>> config)
	{
		//IL_004a: Unknown result type (might be due to invalid IL or missing references)
		//IL_004f: 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_0064: Unknown result type (might be due to invalid IL or missing references)
		//IL_0069: Unknown result type (might be due to invalid IL or missing references)
		//IL_0079: 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_0091: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
		writer.WriteLine("# The format is <stage name>: <pos x>, <pos y>, <size x> <size y>");
		writer.WriteLine("# One block per line, '#' is a comment line.");
		writer.WriteLine("# stage xy origin is bottom center of the stage");
		writer.WriteLine("# block xy origin is bottom left of the block");
		writer.WriteLine("# Refer to readme for stage names (case sensitive)");
		foreach (Stage key in config.Keys)
		{
			foreach (Rect item in config[key])
			{
				Rect current2 = item;
				writer.WriteLine(allStagesMapping[key] + ": " + ((Rect)(ref current2)).position.x + ", " + ((Rect)(ref current2)).position.y + ", " + ((Rect)(ref current2)).size.x + ", " + ((Rect)(ref current2)).size.y);
			}
		}
	}

	public void ReadConfig(TextReader reader, Dictionary<Stage, List<Rect>> config)
	{
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_0043: Unknown result type (might be due to invalid IL or missing references)
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0059: Unknown result type (might be due to invalid IL or missing references)
		//IL_007f: Unknown result type (might be due to invalid IL or missing references)
		config.Clear();
		while (reader.Peek() >= 0)
		{
			string text = reader.ReadLine();
			if (text[0] != '#')
			{
				string[] array = text.Split(',', ':');
				Stage key = reverseStageMapping[array[0]];
				if (!config.ContainsKey(key))
				{
					config.Add(key, new List<Rect>());
				}
				try
				{
					config[key].Add(new Rect(float.Parse(array[1]), float.Parse(array[2]), float.Parse(array[3]), float.Parse(array[4])));
				}
				catch (FormatException ex)
				{
					((BaseUnityPlugin)this).Logger.LogWarning((object)ex);
				}
			}
		}
	}
}

plugins/StageBlocks/StageBlocks.dll

Decompiled 11 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
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 GameplayEntities;
using HarmonyLib;
using LLBML.Math;
using LLBML.Utils;
using LLHandlers;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("StageBlocks (us.wallace.plugins.llb.stageblocks)")]
[assembly: AssemblyProduct("StageBlocks")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.4.0")]
[module: UnverifiableCode]
namespace StageBlocks;

[BepInPlugin("us.wallace.plugins.llb.stageblocks", "StageBlocks", "1.0.4")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInProcess("LLBlaze.exe")]
public class StageBlocks : BaseUnityPlugin
{
	public static ConfigEntry<bool> customStageBlocks;

	public Dictionary<Stage, List<StageBlock>> stageBlocks = new Dictionary<Stage, List<StageBlock>>();

	private const string CONFIG_HEADER = "# The format is <stage name>: <pos x>, <pos y>, <size x>, <size y>; #<hexR><hexG><hexB><hexEmmissive>\n# One block per line, '#' is a comment line.\n# stage xy origin is bottom center of the stage\n# block xy origin is bottom left of the block\n# Refer to readme for stage names (case sensitive)\n";

	private const string DEFAULT_CONFIG = "Outskirts: -500, 232, 250, 54 ; #00000000\nOutskirts: 500, 232, 250, 54 ; #00000000\nSewers: 0, 430, 132, 290 ; #00000000\nDesert: 250, 220, 630, 54 ; #00000000\nElevator: -600, 76, 280, 190 ; #00000000\nElevator: 600, 76, 280, 190 ; #00000000\nFactory: -550, 450, 350, 200 ; #00000000\nFactory: 550, 92, 350, 200 ; #00000000\nSubway: -300, 50, 250, 120 ; #00000000\nSubway: 260, 50, 250, 120 ; #00000000\nStadium: -315, 240, 82, 57 ; #00000000\nStadium: 315, 240, 82, 57 ; #00000000\nStreets: -260, 232, 300, 54 ; #00000000\nStreets: 260, 232, 300, 54 ; #00000000\nPool: 0, 220, 621, 54 ; #00000000\nRoom21: 507, 92, 231, 186 ; #00000000\nRoom21: -230, 232, 280, 54 ; #00000000\n";

	private static readonly Dictionary<Stage, string> allStagesMapping = StringUtils.regularStagesNames.Union(StringUtils.retroStagesNames).ToDictionary((KeyValuePair<Stage, string> x) => x.Key, (KeyValuePair<Stage, string> x) => x.Value);

	private static readonly Dictionary<string, Stage> reverseStageMapping = allStagesMapping.ToDictionary((KeyValuePair<Stage, string> x) => x.Value, (KeyValuePair<Stage, string> x) => x.Key);

	public static ManualLogSource Log { get; private set; } = null;


	public static StageBlocks Instance { get; private set; }

	public string BlocksConfigPath => Path.Combine(ModdingFolder.GetModSubFolder(((BaseUnityPlugin)this).Info).FullName, "BlockConfig.txt");

	private void Awake()
	{
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: Expected O, but got Unknown
		//IL_0081: Unknown result type (might be due to invalid IL or missing references)
		//IL_0086: Unknown result type (might be due to invalid IL or missing references)
		Log = ((BaseUnityPlugin)this).Logger;
		Instance = this;
		((BaseUnityPlugin)this).Config.Bind<string>("Use Custom Stage Blocks", "mm_header_qol", "Use Custom Stage Blocks", new ConfigDescription("", (AcceptableValueBase)null, new object[1] { "modmenu_header" }));
		customStageBlocks = ((BaseUnityPlugin)this).Config.Bind<bool>("StageBlocksToggle", "enableCustomStageBlocks", true, (ConfigDescription)null);
		((BaseUnityPlugin)this).Logger.LogDebug((object)"liuberal poop hippie pronoun fortnite be farting pooping bacon epic, i love ivermectin flouride apartmentism");
		Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID);
		val.PatchAll(typeof(WorldSetStageDimensionsPatch));
		val.PatchAll(typeof(NitroStuckFix));
		((BaseUnityPlugin)this).Logger.LogDebug((object)(((BaseUnityPlugin)this).Info.Metadata.Name + " is loaded"));
	}

	private void Start()
	{
		ModDependenciesUtils.RegisterToModMenu(((BaseUnityPlugin)this).Info, (List<string>)null);
		LoadConfig();
	}

	private void CreateConfig()
	{
		using TextWriter textWriter = File.CreateText(BlocksConfigPath);
		textWriter.Write("# The format is <stage name>: <pos x>, <pos y>, <size x>, <size y>; #<hexR><hexG><hexB><hexEmmissive>\n# One block per line, '#' is a comment line.\n# stage xy origin is bottom center of the stage\n# block xy origin is bottom left of the block\n# Refer to readme for stage names (case sensitive)\nOutskirts: -500, 232, 250, 54 ; #00000000\nOutskirts: 500, 232, 250, 54 ; #00000000\nSewers: 0, 430, 132, 290 ; #00000000\nDesert: 250, 220, 630, 54 ; #00000000\nElevator: -600, 76, 280, 190 ; #00000000\nElevator: 600, 76, 280, 190 ; #00000000\nFactory: -550, 450, 350, 200 ; #00000000\nFactory: 550, 92, 350, 200 ; #00000000\nSubway: -300, 50, 250, 120 ; #00000000\nSubway: 260, 50, 250, 120 ; #00000000\nStadium: -315, 240, 82, 57 ; #00000000\nStadium: 315, 240, 82, 57 ; #00000000\nStreets: -260, 232, 300, 54 ; #00000000\nStreets: 260, 232, 300, 54 ; #00000000\nPool: 0, 220, 621, 54 ; #00000000\nRoom21: 507, 92, 231, 186 ; #00000000\nRoom21: -230, 232, 280, 54 ; #00000000\n");
	}

	public void LoadConfig()
	{
		if (!File.Exists(BlocksConfigPath))
		{
			CreateConfig();
		}
		using TextReader reader = File.OpenText(BlocksConfigPath);
		ReadConfig(reader, stageBlocks);
	}

	public void WriteConfig(TextWriter writer, Dictionary<Stage, List<StageBlock>> config)
	{
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: Unknown result type (might be due to invalid IL or missing references)
		writer.Write("# The format is <stage name>: <pos x>, <pos y>, <size x>, <size y>; #<hexR><hexG><hexB><hexEmmissive>\n# One block per line, '#' is a comment line.\n# stage xy origin is bottom center of the stage\n# block xy origin is bottom left of the block\n# Refer to readme for stage names (case sensitive)\n");
		foreach (Stage key in config.Keys)
		{
			foreach (StageBlock item in config[key])
			{
				writer.WriteLine(allStagesMapping[key] + ": " + item.ToString());
			}
		}
	}

	public void ReadConfig(TextReader reader, Dictionary<Stage, List<StageBlock>> config)
	{
		//IL_0068: 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_006f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0078: Unknown result type (might be due to invalid IL or missing references)
		//IL_0085: Unknown result type (might be due to invalid IL or missing references)
		config.Clear();
		while (reader.Peek() >= 0)
		{
			string text = reader.ReadLine();
			try
			{
				if (text[0] == '#')
				{
					continue;
				}
				string[] array = text.Split(new char[1] { ':' });
				if (!reverseStageMapping.ContainsKey(array[0]))
				{
					((BaseUnityPlugin)this).Logger.LogWarning((object)("Unknown stage name: " + array[0]));
					continue;
				}
				Stage key = reverseStageMapping[array[0]];
				if (!config.ContainsKey(key))
				{
					config.Add(key, new List<StageBlock>());
				}
				try
				{
					config[key].Add(StageBlock.FromString(array[1]));
				}
				catch (FormatException ex)
				{
					((BaseUnityPlugin)this).Logger.LogWarning((object)("Couldn't convert floats from line \"" + text + "\" \n" + ex));
				}
			}
			catch (Exception ex2)
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)("Couldn't parse data from line \"" + text + "\" \n" + ex2));
			}
		}
	}
}
public static class PluginInfos
{
	public const string PLUGIN_NAME = "StageBlocks";

	public const string PLUGIN_ID = "us.wallace.plugins.llb.stageblocks";

	public const string PLUGIN_VERSION = "1.0.4";
}
internal class NitroStuckFix
{
	[HarmonyTranspiler]
	[HarmonyPatch(typeof(BallEntity), "UpdateState", new Type[] { })]
	public static IEnumerable<CodeInstruction> UpdateState_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator iL)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Expected O, but got Unknown
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Expected O, but got Unknown
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_0038: Expected O, but got Unknown
		//IL_0046: Unknown result type (might be due to invalid IL or missing references)
		//IL_004c: Expected O, but got Unknown
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: Expected O, but got Unknown
		CodeMatcher val = new CodeMatcher(instructions, iL);
		val.MatchForward(true, (CodeMatch[])(object)new CodeMatch[3]
		{
			new CodeMatch((OpCode?)OpCodes.Ldloc_3, (object)null, (string)null),
			new CodeMatch((OpCode?)OpCodes.Callvirt, (object)null, (string)null),
			new CodeMatch((OpCode?)OpCodes.Br, (object)null, (string)null)
		});
		try
		{
			val.Insert((CodeInstruction[])(object)new CodeInstruction[2]
			{
				new CodeInstruction(OpCodes.Ldarg_0, (object)null),
				Transpilers.EmitDelegate<Action<BallEntity>>((Action<BallEntity>)delegate(BallEntity __instance)
				{
					//IL_0040: Unknown result type (might be due to invalid IL or missing references)
					//IL_0045: Unknown result type (might be due to invalid IL or missing references)
					//IL_0054: Unknown result type (might be due to invalid IL or missing references)
					//IL_006b: Unknown result type (might be due to invalid IL or missing references)
					//IL_0070: Unknown result type (might be due to invalid IL or missing references)
					//IL_007f: Unknown result type (might be due to invalid IL or missing references)
					//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
					//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
					//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
					PlayerEntity playerEntity = PlayerHandler.instance.GetPlayerEntity(((GetHitBallEntity)__instance).ballData.cuffBallOwner);
					CopPlayer val2 = (CopPlayer)(object)((playerEntity is CopPlayer) ? playerEntity : null);
					if (((MovableData)((AbilityEntity)val2).abilityData).abilityState == "CUFF_HOOKSHOT" && HHBCPNCDNDH.HPLPMEAOJPM(HHBCPNCDNDH.NPDCPLFLLIG(((EntityData)((MovableEntity)val2).moveableData).velocity.GCPKPHMKLBN), HHBCPNCDNDH.NKKIFJJEPOL(0.5m)) && HHBCPNCDNDH.HPLPMEAOJPM(HHBCPNCDNDH.NPDCPLFLLIG(((EntityData)((MovableEntity)val2).moveableData).velocity.CGJJEHPPOAN), HHBCPNCDNDH.NKKIFJJEPOL(0.5m)))
					{
						((MovableEntity)val2).SetAbilityState("CUFF_NEUTRAL_STAY");
						((AnimatableEntity)val2).PlayAnim("cuffPull", "main");
						((AbilityEntity)val2).abilityData.specialHeading = (Side)5;
						((EntityData)((PlayerEntity)val2).playerData).velocity = IBGCBLLKIHA.GCPFGINDGEM();
						((HittingEntity)val2).GiveBall((BallState)22, __instance, false);
					}
				})
			});
		}
		catch (Exception ex)
		{
			StageBlocks.Log.LogInfo((object)ex);
		}
		return val.InstructionEnumeration();
	}
}
internal class WorldSetStageDimensionsPatch
{
	[HarmonyPatch(typeof(World), "SetStageDimensions")]
	[HarmonyPostfix]
	public static void SetStageDimensions_Postfix(World __instance)
	{
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0047: 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)
		//IL_006a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0077: Unknown result type (might be due to invalid IL or missing references)
		//IL_0089: 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)
		//IL_0098: Unknown result type (might be due to invalid IL or missing references)
		//IL_009d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0108: Unknown result type (might be due to invalid IL or missing references)
		//IL_0112: Unknown result type (might be due to invalid IL or missing references)
		//IL_0117: Unknown result type (might be due to invalid IL or missing references)
		//IL_011c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0121: Unknown result type (might be due to invalid IL or missing references)
		//IL_0130: Unknown result type (might be due to invalid IL or missing references)
		//IL_0146: Unknown result type (might be due to invalid IL or missing references)
		//IL_016b: Unknown result type (might be due to invalid IL or missing references)
		//IL_017d: Unknown result type (might be due to invalid IL or missing references)
		//IL_018f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0199: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_01af: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01be: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
		if (!StageBlocks.customStageBlocks.Value || __instance.useStageBlocks)
		{
			return;
		}
		StageBlocks.Instance.LoadConfig();
		if (!StageBlocks.Instance.stageBlocks.ContainsKey(StageHandler.curStage))
		{
			return;
		}
		foreach (StageBlock item in StageBlocks.Instance.stageBlocks[StageHandler.curStage])
		{
			Rect box = item.box;
			GameObject obj = GameObject.CreatePrimitive((PrimitiveType)3);
			obj.transform.rotation = Quaternion.identity;
			obj.transform.position = new Vector3(Floatf.op_Implicit(Floatf.op_Implicit(((Rect)(ref box)).center.x) * Floatf.op_Implicit(World.FPIXEL_SIZE)), Floatf.op_Implicit(Floatf.op_Implicit(((Rect)(ref box)).center.y) * Floatf.op_Implicit(World.FPIXEL_SIZE)));
			obj.transform.localScale = new Vector3(Floatf.op_Implicit(Floatf.op_Implicit(((Rect)(ref box)).size.x) * Floatf.op_Implicit(World.FPIXEL_SIZE)), Floatf.op_Implicit(Floatf.op_Implicit(((Rect)(ref box)).size.y) * Floatf.op_Implicit(World.FPIXEL_SIZE)), 1f);
			Renderer component = obj.GetComponent<Renderer>();
			component.material.color = item.color;
			component.material.EnableKeyword("_EMISSION");
			component.material.SetColor("_EmissionColor", item.color * ((float)(int)item.emission / 128f));
			__instance.stageBlockList.Add(Boundsf.op_Implicit(new Boundsf(new Vector2f(Floatf.op_Implicit(((Rect)(ref box)).center.x), Floatf.op_Implicit(((Rect)(ref box)).center.y)) * Floatf.op_Implicit(World.FPIXEL_SIZE), new Vector2f(Floatf.op_Implicit(((Rect)(ref box)).size.x), Floatf.op_Implicit(((Rect)(ref box)).size.y)) * Floatf.op_Implicit(World.FPIXEL_SIZE))));
		}
	}
}
public struct StageBlock
{
	public const float emissionMultiplier = 128f;

	public Rect box;

	public Color color;

	public byte emission;

	public StageBlock(Rect block, Color? color = null)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		box = block;
		this.color = (Color)(((??)color) ?? Color.clear);
		emission = Convert.ToByte(this.color.a * 255f);
		this.color.a = 1f;
	}

	public static implicit operator StageBlock(Rect a)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		return new StageBlock(a);
	}

	public override string ToString()
	{
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: Unknown result type (might be due to invalid IL or missing references)
		//IL_005e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0063: Unknown result type (might be due to invalid IL or missing references)
		//IL_0081: Unknown result type (might be due to invalid IL or missing references)
		//IL_0086: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
		string text = "";
		text = text + ((Rect)(ref box)).position.x + ", " + ((Rect)(ref box)).position.y + ", " + ((Rect)(ref box)).size.x + ", " + ((Rect)(ref box)).size.y;
		text = text + " ; #" + ColorUtility.ToHtmlStringRGB(color);
		return text + StringUtils.BytesToHexString(new byte[1] { emission });
	}

	public static StageBlock FromString(string data)
	{
		//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_0099: Unknown result type (might be due to invalid IL or missing references)
		string[] array = data.Split(new char[1] { ';' });
		string[] array2 = array[0].Split(new char[1] { ',' });
		Rect block = default(Rect);
		((Rect)(ref block))..ctor(float.Parse(array2[0]), float.Parse(array2[1]), float.Parse(array2[2]), float.Parse(array2[3]));
		if (array.Length > 1)
		{
			string text = array[1].Replace(" ", "");
			text = ((text[0] == '#') ? text : ("#" + text));
			Color value = default(Color);
			if (!ColorUtility.TryParseHtmlString(text, ref value))
			{
				StageBlocks.Log.LogWarning((object)"Failed to load colour. Is it in the right format? e.g. #1a1a22");
				return new StageBlock(block);
			}
			return new StageBlock(block, value);
		}
		return new StageBlock(block);
	}
}