Decompiled source of Cart Lights MelanieMelicious v1.1.2

MelanieCartLight.dll

Decompiled 4 months ago
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
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.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.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;
		}
	}
}
internal static class CartLightCFG
{
	internal static ConfigEntry<int> range;

	internal static ConfigEntry<int> bright;

	internal static ConfigEntry<string> color;

	internal static ConfigEntry<bool> shopOff;

	internal static void SetupConfig(ConfigFile config)
	{
		range = config.Bind<int>("Light Settings", "Range", 20, "Adjust the range of cart lights.");
		bright = config.Bind<int>("Light Settings", "Brightness", 3, "Adjust the brightness of cart lights.");
		color = config.Bind<string>("Light Settings", "Light Color", "#FFF888", "Adjust the color of cart lights.");
		shopOff = config.Bind<bool>("Light Settings", "Turn Off Lights in Shop", false, "Toggle turning off cart lights when in shop.");
	}
}
public class CartLightPatch
{
	[HarmonyPostfix]
	[HarmonyPatch(typeof(PhysGrabCart), "Start")]
	private static void StartRPCPatch(PhysGrabCart __instance)
	{
		//IL_0055: Unknown result type (might be due to invalid IL or missing references)
		//IL_006e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0094: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_010a: Unknown result type (might be due to invalid IL or missing references)
		//IL_011b: Unknown result type (might be due to invalid IL or missing references)
		//IL_013b: Unknown result type (might be due to invalid IL or missing references)
		switch (((Object)__instance).name)
		{
		case "Item Cart Medium(Clone)":
		case "Item Cart kek_Big(Clone)":
		{
			GameObject val = Object.Instantiate<GameObject>(Plugin.bundle.LoadAsset<GameObject>("Assets/MelanieCartLight/Prefab/Worklight0.prefab"), Vector3.zero, new Quaternion(0f, 0f, 0f, 0f), ((Component)__instance).transform);
			val.transform.localPosition = new Vector3(0f, 0.23f, 0.95f);
			val.transform.localEulerAngles = Vector3.zero;
			LightCFG(val);
			break;
		}
		case "Item Cart Small(Clone)":
		case "Item Cart Small Plus(Clone)":
		{
			GameObject val = Object.Instantiate<GameObject>(Plugin.bundle.LoadAsset<GameObject>("Assets/MelanieCartLight/Prefab/Worklight0.prefab"), Vector3.zero, new Quaternion(0f, 0f, 0f, 0f), ((Component)__instance).transform);
			val.transform.localPosition = new Vector3(0f, 0.32f, 0.39f);
			val.transform.localEulerAngles = Vector3.zero;
			val.transform.localScale = new Vector3(1f, 1f, 0.6f);
			LightCFG(val);
			break;
		}
		}
	}

	private static void LightCFG(GameObject light0)
	{
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		//IL_0039: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
		Color val = default(Color);
		ColorUtility.TryParseHtmlString(CartLightCFG.color.Value, ref val);
		((Renderer)light0.GetComponent<MeshRenderer>()).materials[1].color = val;
		((Renderer)light0.GetComponent<MeshRenderer>()).materials[1].SetColor("_EmissionColor", val);
		if (CartLightCFG.shopOff.Value && (Object)(object)RunManager.instance.levelCurrent == (Object)(object)RunManager.instance.levelShop)
		{
			((Behaviour)light0.GetComponent<Light>()).enabled = false;
			return;
		}
		light0.GetComponent<Light>().range = CartLightCFG.range.Value;
		light0.GetComponent<Light>().intensity = CartLightCFG.bright.Value;
		light0.GetComponent<Light>().color = val;
	}
}
[BepInPlugin("MelanieMelicious.CartLight", "Melanie Melicious - Cart Lights", "1.1.2")]
public class Plugin : BaseUnityPlugin
{
	private const string GUID = "MelanieMelicious.CartLight";

	private const string NAME = "Melanie Melicious - Cart Lights";

	private const string VERSION = "1.1.2";

	private readonly Harmony harmony = new Harmony("MelanieMelicious.CartLight");

	public static ManualLogSource mls;

	public static AssetBundle bundle;

	public static Plugin instance;

	private void Awake()
	{
		instance = this;
		CartLightCFG.SetupConfig(((BaseUnityPlugin)this).Config);
		mls = Logger.CreateLogSource("MelanieMelicious - Cart Lights");
		mls = ((BaseUnityPlugin)this).Logger;
		harmony.PatchAll(typeof(CartLightPatch));
		string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "melaniecartlight");
		bundle = AssetBundle.LoadFromFile(text);
	}
}