Decompiled source of ColorfulFlame v1.0.0

vsp.ColorfulFlame.dll

Decompiled 9 months ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using Jotunn.Configs;
using Jotunn.GUI;
using Jotunn.Managers;
using Jotunn.Utils;
using UnityEngine;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("ColorfulFlame")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ColorfulFlame")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("309569bc-dfe9-462e-a693-eef61af45347")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace ColorfulFlame;

internal delegate Color GetterColor();
[BepInPlugin("vsp.ColorfulFlame", "ColorfulFlame", "1.0.0")]
public class Class1 : BaseUnityPlugin
{
	private ConfigEntry<KeyCode> KeyConfig;

	private ConfigEntry<KeyboardShortcut> ShortcutConfig;

	private ButtonConfig GuiVisible;

	private ButtonConfig Select;

	private static Color choosedColor;

	private static Material material;

	private static ManualLogSource Log;

	private void Awake()
	{
		Log = ((BaseUnityPlugin)this).Logger;
		material = AssetUtils.LoadAssetBundleFromResources("flamenew").LoadAsset<Material>("Assets/Material/flameball_flipbook.mat");
		((BaseUnityPlugin)this).Logger.LogInfo((object)((Object)material).name);
		ConfigAdd();
		InputAdd();
	}

	private void Update()
	{
		if (ZInput.instance != null)
		{
			if (ZInput.GetButtonDown(GuiVisible.Name))
			{
				ChooseColor();
			}
			else if (ZInput.GetButtonDown(Select.Name))
			{
				FixColor();
			}
		}
	}

	private static void FixColor()
	{
		//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
		Transform val = null;
		try
		{
			Transform val2 = ((Humanoid)Player.m_localPlayer).GetHoverObject().transform.Find("../");
			if (!((Object)val2).name.Contains("groundtorch") && !((Object)val2).name.Contains("walltorch"))
			{
				return;
			}
			val = ((Component)val2).transform.Find("_enabled/fx_Torch_Basic");
			if ((Object)(object)val == (Object)null)
			{
				val = ((Component)val2).transform.Find("_enabled/fx_Torch_Blue");
				if ((Object)(object)val == (Object)null)
				{
					val = ((Component)val2).transform.Find("_enabled/fx_Torch_Green");
					if ((Object)(object)val == (Object)null && (Object)(object)val == (Object)null)
					{
						return;
					}
				}
			}
		}
		catch
		{
			Log.LogInfo((object)"Incorrect object");
			return;
		}
		ParticleSystemRenderer component = ((Component)val).GetComponent<ParticleSystemRenderer>();
		((Renderer)component).material = material;
		((Renderer)component).material.color = choosedColor;
	}

	private void ConfigAdd()
	{
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0039: Expected O, but got Unknown
		//IL_005f: 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_0079: Expected O, but got Unknown
		((BaseUnityPlugin)this).Config.SaveOnConfigSet = false;
		KeyConfig = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("General", "KeyCode", (KeyCode)284, new ConfigDescription("The key for displaying the menu", (AcceptableValueBase)null, Array.Empty<object>()));
		ShortcutConfig = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("General", "Shortcut", new KeyboardShortcut((KeyCode)101, (KeyCode[])(object)new KeyCode[1] { (KeyCode)304 }), new ConfigDescription("Shortcut combination", (AcceptableValueBase)null, Array.Empty<object>()));
	}

	private void InputAdd()
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: 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_001a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: Expected O, but got Unknown
		//IL_0049: 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_005a: Unknown result type (might be due to invalid IL or missing references)
		//IL_006c: Expected O, but got Unknown
		GuiVisible = new ButtonConfig
		{
			Name = "Menu",
			Key = KeyConfig.Value,
			ActiveInCustomGUI = false
		};
		InputManager.Instance.AddButton("vsp.ColorfulFlame", GuiVisible);
		Select = new ButtonConfig
		{
			Name = "Select",
			ShortcutConfig = ShortcutConfig
		};
		InputManager.Instance.AddButton("vsp.ColorfulFlame", Select);
	}

	private void ChooseColor()
	{
		//IL_004c: 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_0081: Unknown result type (might be due to invalid IL or missing references)
		//IL_0090: Unknown result type (might be due to invalid IL or missing references)
		//IL_009f: 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_00b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cc: Expected O, but got Unknown
		//IL_00cc: Expected O, but got Unknown
		if (GUIManager.Instance == null)
		{
			((BaseUnityPlugin)this).Logger.LogError((object)"GUIManager instance is null");
			return;
		}
		if (!Object.op_Implicit((Object)(object)GUIManager.CustomGUIFront))
		{
			((BaseUnityPlugin)this).Logger.LogError((object)"GUIManager CustomGUI is null");
			return;
		}
		Scene activeScene = SceneManager.GetActiveScene();
		if (((Scene)(ref activeScene)).name == "main" && ColorPicker.done)
		{
			GUIManager.Instance.CreateColorPicker(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), choosedColor, "Choose your color", new ColorEvent(SetColor), new ColorEvent(ColorChosen), false);
			GUIManager.BlockInput(true);
		}
	}

	public void SetColor(Color currentColor)
	{
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		currentColor.a = 1f;
		choosedColor = currentColor;
	}

	private void ColorChosen(Color finalColor)
	{
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		finalColor.a = 1f;
		choosedColor = finalColor;
		GUIManager.BlockInput(false);
	}
}