Decompiled source of PEAK WhereCanIStand v1.0.0

BepInEx\plugins\scarletcafe-mods-peak-wherecanistand\PEAK_WhereCanIStand.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
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.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("PEAK_WhereCanIStand")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+96170cff7d2d517946882359b9cce4b459b2d02d")]
[assembly: AssemblyProduct("scarletcafe-mods-peak-wherecanistand")]
[assembly: AssemblyTitle("PEAK_WhereCanIStand")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.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 PEAK_WhereCanIStand
{
	public class AssetHolder
	{
		private static AssetBundle _bundle;

		private static Material _topMaterial;

		public static string PluginFolder { get; set; }

		public static AssetBundle Bundle
		{
			get
			{
				if ((Object)(object)_bundle == (Object)null)
				{
					_bundle = AssetBundle.LoadFromFile(Path.Join(PluginFolder.AsSpan(), "wherecanistandassets".AsSpan()));
				}
				return _bundle;
			}
		}

		public static Material TopMaterial
		{
			get
			{
				if (_topMaterial == null)
				{
					_topMaterial = Bundle.LoadAsset<Material>("TopOutlineMaterial");
				}
				return _topMaterial;
			}
		}
	}
	public class Patches
	{
		[HarmonyPatch(typeof(RunManager), "StartRun")]
		private class ApplyMaterialToRocksOnLoadPatch
		{
			private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
			{
				//IL_002c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0036: Expected O, but got Unknown
				List<CodeInstruction> list = instructions.ToList();
				MethodInfo method = typeof(Plugin).GetMethod("AddMaterialsToRocks", BindingFlags.Static | BindingFlags.Public);
				list.Insert(list.Count - 1, new CodeInstruction(OpCodes.Call, (object)method));
				return list;
			}
		}

		[HarmonyPatch(typeof(MapHandler), "ActivateCurrentSegment")]
		private class ApplyMaterialToRocksOnTransitionPatch
		{
			private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
			{
				//IL_002c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0036: Expected O, but got Unknown
				List<CodeInstruction> list = instructions.ToList();
				MethodInfo method = typeof(Plugin).GetMethod("AddMaterialsToRocks", BindingFlags.Static | BindingFlags.Public);
				list.Insert(list.Count - 1, new CodeInstruction(OpCodes.Call, (object)method));
				return list;
			}
		}
	}
	[BepInPlugin("PEAK_WhereCanIStand", "scarletcafe-mods-peak-wherecanistand", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		[CompilerGenerated]
		private sealed class <>c__DisplayClass7_0
		{
			public GameObject map;
		}

		internal static ManualLogSource Logger;

		internal static Harmony harmony;

		private ConfigEntry<KeyCode> configOverlayCycleKey;

		private static ushort overlayCycle;

		private void Awake()
		{
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Expected O, but got Unknown
			Logger = ((BaseUnityPlugin)this).Logger;
			Logger.LogInfo((object)"Plugin PEAK_WhereCanIStand is loaded!");
			configOverlayCycleKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("General", "Cycle overlay mode", (KeyCode)106, "The key to press to cycle the overlay mode.");
			AssetHolder.PluginFolder = Directory.GetParent(((BaseUnityPlugin)this).Info.Location).FullName;
			harmony = new Harmony("scarletcafe.mods.peak.wherecanistand");
			harmony.PatchAll();
		}

		private void Update()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			if (Input.GetKeyDown(configOverlayCycleKey.Value))
			{
				ToggleOverlay();
			}
		}

		public static void ToggleOverlay()
		{
			overlayCycle = (ushort)((overlayCycle + 1) % 7);
			Shader.SetGlobalFloat("_WhereCanIStandTopSurfaceEnabled", (float)(int)overlayCycle);
		}

		public static void AddMaterialsToRocks()
		{
			<>c__DisplayClass7_0 CS$<>8__locals0 = new <>c__DisplayClass7_0();
			overlayCycle = 0;
			Shader.SetGlobalFloat("_WhereCanIStandTopSurfaceEnabled", 0f);
			CS$<>8__locals0.map = GameObject.Find("/Map");
			GameObject map = CS$<>8__locals0.map;
			MapHandler val = ((map != null) ? map.GetComponent<MapHandler>() : null);
			if ((Object)(object)CS$<>8__locals0.map == (Object)null || (Object)(object)val == (Object)null)
			{
				Debug.Log((object)"WhereCanIStand didn't add any top materials because the map wasn't loaded");
			}
			else
			{
				((MonoBehaviour)val).StartCoroutine(UpdateRenderers());
			}
			[IteratorStateMachine(typeof(<>c__DisplayClass7_0.<<AddMaterialsToRocks>g__UpdateRenderers|0>d))]
			IEnumerator UpdateRenderers()
			{
				//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
				return new <>c__DisplayClass7_0.<<AddMaterialsToRocks>g__UpdateRenderers|0>d(0)
				{
					<>4__this = CS$<>8__locals0
				};
			}
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "PEAK_WhereCanIStand";

		public const string PLUGIN_NAME = "scarletcafe-mods-peak-wherecanistand";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}