Decompiled source of CustomDiscoverStateLib v1.0.0

Kistras-CustomDiscoverStateLib.dll

Decompiled 2 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Kistras-CustomDiscoverStateLib")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("CustomDiscoverStateLib")]
[assembly: AssemblyTitle("Kistras-CustomDiscoverStateLib")]
[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 CustomDiscoverStateLib
{
	[BepInPlugin("Kistras-CustomDiscoverStateLib", "CustomDiscoverStateLib", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Logger;

		private readonly Harmony harmony = new Harmony("Kistras-CustomDiscoverStateLib");

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			harmony.PatchAll(typeof(Patches));
			Logger.LogInfo((object)"Plugin Kistras-CustomDiscoverStateLib is loaded!");
		}
	}
	public static class CustomDiscoverState
	{
		public class CustomDiscoverGraphic
		{
			public Color ColorMiddle;

			public Color ColorCorner;
		}

		internal static Dictionary<State, CustomDiscoverGraphic> customStates = new Dictionary<State, CustomDiscoverGraphic>();

		private static int lastAddedIndex = 260;

		public static State AddNewDiscoverGraphic(Color middle, Color corner)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//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_0020: 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_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			State val = (State)lastAddedIndex;
			lastAddedIndex++;
			customStates[val] = new CustomDiscoverGraphic
			{
				ColorMiddle = middle,
				ColorCorner = corner
			};
			return val;
		}
	}
	[HarmonyPatch]
	internal class Patches
	{
		[HarmonyPatch(typeof(ValuableDiscover), "New")]
		[HarmonyPrefix]
		public static bool ValuableDiscoverPatch(ValuableDiscover __instance, PhysGrabObject _target, State _state)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: 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_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: 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_00aa: Unknown result type (might be due to invalid IL or missing references)
			if (!CustomDiscoverState.customStates.TryGetValue(_state, out var value))
			{
				return true;
			}
			ValuableDiscoverGraphic component = Object.Instantiate<GameObject>(__instance.graphicPrefab, ((Component)__instance).transform).GetComponent<ValuableDiscoverGraphic>();
			component.target = _target;
			component.state = _state;
			((Graphic)((Component)component.middle).GetComponent<Image>()).color = value.ColorMiddle;
			((Graphic)((Component)component.topLeft).GetComponent<Image>()).color = value.ColorCorner;
			((Graphic)((Component)component.topRight).GetComponent<Image>()).color = value.ColorCorner;
			((Graphic)((Component)component.botLeft).GetComponent<Image>()).color = value.ColorCorner;
			((Graphic)((Component)component.botRight).GetComponent<Image>()).color = value.ColorCorner;
			return false;
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "Kistras-CustomDiscoverStateLib";

		public const string PLUGIN_NAME = "CustomDiscoverStateLib";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}