Decompiled source of LargerCoin v1.3.0

LargerCoin.dll

Decompiled 2 weeks ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using Configgy;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("LargerCoin")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("LargerCoin")]
[assembly: AssemblyTitle("LargerCoin")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace LargerCoin;

[BepInPlugin("LargerCoin.adry.ultrakill", "LargerCoin", "1.3.0")]
public class LargerCoin : BaseUnityPlugin
{
	public class LargerCoinMarker : MonoBehaviour
	{
		public Vector3 originalScale;
	}

	[HarmonyPatch(typeof(Coin), "Start")]
	public class CoinStartPatch
	{
		private static void Postfix(Coin __instance)
		{
			//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_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: 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)
			if ((Object)(object)((Component)__instance).GetComponent<LargerCoinMarker>() != (Object)null || !((Object)(object)__instance.sourceWeapon != (Object)null))
			{
				return;
			}
			Revolver component = __instance.sourceWeapon.GetComponent<Revolver>();
			if (!((Object)(object)component != (Object)null) || component.gunVariation != 1)
			{
				return;
			}
			LargerCoinMarker largerCoinMarker = ((Component)__instance).gameObject.AddComponent<LargerCoinMarker>();
			largerCoinMarker.originalScale = ((Component)__instance).transform.localScale;
			int value = ((ConfigValueElement<int>)(object)coinSizeSlider).GetValue();
			float num = 1f + ((float)value - 1f) * (19f / 99f);
			((Component)__instance).transform.localScale = largerCoinMarker.originalScale * num;
			string text = ((ConfigValueElement<string>)(object)coinColorDropdown).GetValue();
			if (!(text != "default"))
			{
				return;
			}
			if (text == "rainbow")
			{
				text = baseColors[Random.Range(0, baseColors.Length)];
			}
			Color color = default(Color);
			if (ColorUtility.TryParseHtmlString(text, ref color))
			{
				MeshRenderer[] componentsInChildren = ((Component)__instance).GetComponentsInChildren<MeshRenderer>();
				MeshRenderer[] array = componentsInChildren;
				foreach (MeshRenderer val in array)
				{
					((Renderer)val).material.color = color;
				}
			}
		}
	}

	[Configgable("General", "Coin Size Slider", 0, "Set the coin size using a slider from 1 (default size) to 100 (20x larger).")]
	private static ConfigSlider<int> coinSizeSlider = (ConfigSlider<int>)new IntegerSlider(1, 1, 100);

	[Configgable("General", "Coin Color", 1, "Select the coin color. 'Default' uses the original color; 'Rainbow' picks a random color.")]
	private static ConfigDropdown<string> coinColorDropdown;

	private static readonly string[] baseColors = new string[50]
	{
		"#FF0000", "#FFA500", "#FFFF00", "#00FF00", "#0000FF", "#4B0082", "#8B00FF", "#FF69B4", "#800080", "#FFFFFF",
		"#00FFFF", "#000080", "#006400", "#90EE90", "#800000", "#FF4500", "#4682B4", "#9370DB", "#48D1CC", "#FF1493",
		"#7CFC00", "#BDB76B", "#FF00FF", "#CD853F", "#8B4513", "#228B22", "#483D8B", "#2E8B57", "#B8860B", "#FF8C00",
		"#8FBC8F", "#BA55D3", "#4169E1", "#32CD32", "#FF69B4", "#DAA520", "#7B68EE", "#FF6347", "#20B2AA", "#9932CC",
		"#8B0000", "#556B2F", "#66CDAA", "#9400D3", "#CD5C5C", "#008B8B", "#BC8F8F", "#4B0082", "#00CED1", "#FF4040"
	};

	private static readonly string[] baseColorNames = new string[50]
	{
		"Red", "Orange", "Yellow", "Green", "Blue", "Indigo", "Violet", "Pink", "Purple", "White",
		"Cyan", "Navy Blue", "Dark Green", "Light Green", "Maroon", "Orange Red", "Steel Blue", "Medium Purple", "Turquoise", "Deep Pink",
		"Lawn Green", "Dark Khaki", "Magenta", "Peru", "Saddle Brown", "Forest Green", "Dark Slate Blue", "Sea Green", "Dark Goldenrod", "Dark Orange",
		"Dark Sea Green", "Medium Orchid", "Royal Blue", "Lime Green", "Hot Pink", "Goldenrod", "Medium Slate Blue", "Tomato", "Light Sea Green", "Dark Orchid",
		"Dark Red", "Dark Olive Green", "Medium Aquamarine", "Dark Violet", "Indian Red", "Dark Cyan", "Rosy Brown", "Dark Purple", "Dark Turquoise", "Crimson"
	};

	private void Awake()
	{
		//IL_0090: Unknown result type (might be due to invalid IL or missing references)
		//IL_0096: Expected O, but got Unknown
		//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a8: Expected O, but got Unknown
		string[] array = new string[baseColors.Length + 2];
		string[] array2 = new string[baseColors.Length + 2];
		array[0] = "default";
		array[1] = "rainbow";
		array2[0] = "Default";
		array2[1] = "Rainbow";
		for (int i = 0; i < baseColors.Length; i++)
		{
			array[i + 2] = baseColors[i];
			array2[i + 2] = baseColorNames[i];
		}
		coinColorDropdown = new ConfigDropdown<string>(array, array2, 0);
		ConfigBuilder val = new ConfigBuilder("LargerCoin.mod.ultrakill", "LargerCoin");
		val.BuildAll();
		Harmony val2 = new Harmony("LargerCoin.mod.ultrakill");
		val2.PatchAll();
		Debug.Log((object)"Larger Coin mod loaded!");
	}
}