Decompiled source of CustomColors v2.0.0

CustomColors.dll

Decompiled 5 months ago
using System;
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;

[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.6", FrameworkDisplayName = ".NET Framework 4.6")]
[assembly: AssemblyCompany("CustomColors")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Allows you to make your Bopl any RGB color you want!")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("CustomColors")]
[assembly: AssemblyTitle("CustomColors")]
[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 CustomColors
{
	[BepInPlugin("com.rbdev.CustomColors", "CustomColors", "1.0.0")]
	[BepInProcess("BoplBattle.exe")]
	public class Plugin : BaseUnityPlugin
	{
		public class Patches
		{
			[HarmonyPatch(typeof(PlayerBody), "UpdateSim")]
			[HarmonyPostfix]
			public static void ColorPatch(ref IPlayerIdHolder ___idHolder)
			{
				//IL_0069: Unknown result type (might be due to invalid IL or missing references)
				SlimeController[] slimeControllers = GetSlimeControllers();
				foreach (SlimeController val in slimeControllers)
				{
					if (val.GetPlayerId() == localPlayerId && (Object)(object)val != (Object)null)
					{
						MonoBehaviour.print((object)"found a match!");
						((Renderer)val.GetPlayerSprite()).material.SetColor("_ShadowColor", new Color(red / 255f, green / 255f, blue / 255f));
					}
				}
			}

			[HarmonyPatch(typeof(Player), "UpdateFRAMEDependentInputs")]
			[HarmonyPrefix]
			public static void PlayerPatch(Player __instance)
			{
				if (__instance.IsLocalPlayer)
				{
					localPlayerId = __instance.Id;
				}
			}

			public static GameSessionHandler GetGameSessionHandler()
			{
				FieldInfo field = typeof(GameSessionHandler).GetField("selfRef", BindingFlags.Static | BindingFlags.NonPublic);
				object? value = field.GetValue(null);
				return (GameSessionHandler)((value is GameSessionHandler) ? value : null);
			}

			public static SlimeController[] GetSlimeControllers()
			{
				FieldInfo field = typeof(GameSessionHandler).GetField("slimeControllers", BindingFlags.Instance | BindingFlags.NonPublic);
				return field.GetValue(GetGameSessionHandler()) as SlimeController[];
			}
		}

		internal static float red = 255f;

		internal static float green = 255f;

		internal static float blue = 255f;

		internal static int localPlayerId = 1;

		internal static bool customColorsWindow = true;

		private static ManualLogSource logger;

		private void Awake()
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected O, but got Unknown
			logger = ((BaseUnityPlugin)this).Logger;
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin CustomColors is loaded!");
			Harmony val = new Harmony("com.rbdev.CustomColors");
			val.PatchAll(typeof(Patches));
			InfoLog("Log test, ignore");
			WarnLog("Warning test, ignore");
			ErrorLog("Error test, ignore");
		}

		private void CustomColorsWindow(int windowID)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: 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_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0205: Unknown result type (might be due to invalid IL or missing references)
			//IL_0224: Unknown result type (might be due to invalid IL or missing references)
			//IL_0249: Unknown result type (might be due to invalid IL or missing references)
			//IL_0268: Unknown result type (might be due to invalid IL or missing references)
			//IL_028d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_02dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fc: Unknown result type (might be due to invalid IL or missing references)
			GUI.color = new Color(red / 255f, 0f, 0f);
			red = GUI.HorizontalSlider(new Rect(10f, 20f, 150f, 30f), red, 0f, 255f);
			GUI.color = new Color(0f, green / 255f, 0f);
			green = GUI.HorizontalSlider(new Rect(10f, 45f, 150f, 30f), green, 0f, 255f);
			GUI.color = new Color(0f, 0f, blue / 255f);
			blue = GUI.HorizontalSlider(new Rect(10f, 70f, 150f, 30f), blue, 0f, 255f);
			GUI.color = new Color(red / 255f, 0f, 0f);
			red = float.Parse(GUI.TextField(new Rect(200f, 20f, 50f, 20f), red.ToString(), 5));
			GUI.color = new Color(0f, green / 255f, 0f);
			green = float.Parse(GUI.TextField(new Rect(200f, 45f, 50f, 20f), green.ToString(), 5));
			GUI.color = new Color(0f, 0f, blue / 255f);
			blue = float.Parse(GUI.TextField(new Rect(200f, 70f, 50f, 20f), blue.ToString(), 5));
			GUI.color = new Color(red / 255f, 0f, 0f);
			GUI.Label(new Rect(255f, 20f, 50f, 20f), "███████");
			GUI.color = new Color(0f, green / 255f, 0f);
			GUI.Label(new Rect(255f, 45f, 50f, 20f), "███████");
			GUI.color = new Color(0f, 0f, blue / 255f);
			GUI.Label(new Rect(255f, 70f, 50f, 20f), "███████");
			GUI.color = new Color(red / 255f, green / 255f, blue / 255f);
			GUI.Label(new Rect(25f, 95f, 200f, 20f), "███████████████████████████████████");
			GUI.DragWindow();
		}

		private void OnGUI()
		{
			//IL_0001: 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_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Expected O, but got Unknown
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			GUI.color = Color.yellow;
			if (GUI.Button(new Rect(25f, 100f, 100f, 20f), "Custom Colors"))
			{
				if (customColorsWindow)
				{
					customColorsWindow = false;
				}
				else
				{
					customColorsWindow = true;
				}
			}
			if (customColorsWindow)
			{
				GUI.color = Color.yellow;
				GUI.Window(42069, new Rect(10f, 125f, 300f, 125f), new WindowFunction(CustomColorsWindow), "Custom Colors");
			}
		}

		internal static void InfoLog(string message)
		{
			logger.LogInfo((object)message);
		}

		internal static void WarnLog(string message)
		{
			logger.LogWarning((object)message);
		}

		internal static void ErrorLog(string message)
		{
			logger.LogError((object)message);
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "CustomColors";

		public const string PLUGIN_NAME = "CustomColors";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}