Decompiled source of DeezMistyBalls v1.0.4

DeezMistyBalls.dll

Decompiled 6 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
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 HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("DeezMistyBalls")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Azumatt")]
[assembly: AssemblyProduct("DeezMistyBalls")]
[assembly: AssemblyCopyright("Copyright ©  2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("4358610B-F3F4-4843-B7AF-98B7BC60DCDE")]
[assembly: AssemblyFileVersion("1.0.4")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.4.0")]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace DeezMistyBalls
{
	[HarmonyPatch(typeof(SE_Demister), "Setup")]
	internal static class SeDemisterPatch
	{
		private static void Postfix(SE_Demister __instance)
		{
			if (DeezMistyBallsPlugin.CheckBallInstance(__instance))
			{
				DeezMistyBallsPlugin.DemisterParticleFf = ((Component)Utils.FindChild(__instance.m_ballInstance.transform, "Particle System Force Field", (IterativeSearchType)0)).GetComponent<ParticleSystemForceField>();
				DeezMistyBallsPlugin.UpdateDemisterRange(null, null);
			}
		}
	}
	[HarmonyPatch(typeof(SE_Demister), "UpdateStatusEffect")]
	internal static class SeDemisterUpdateStatusEffectPatch
	{
		private static void Postfix(SE_Demister __instance)
		{
			if (DeezMistyBallsPlugin.CheckBallInstance(__instance))
			{
				DeezMistyBallsPlugin.DemisterParticleFf = ((Component)Utils.FindChild(__instance.m_ballInstance.transform, "Particle System Force Field", (IterativeSearchType)0)).GetComponent<ParticleSystemForceField>();
				DeezMistyBallsPlugin.UpdateDemisterRange(null, null);
			}
		}
	}
	[HarmonyPatch]
	internal static class SeDemisterDestroyedPatches
	{
		private static IEnumerable<MethodBase> TargetMethods()
		{
			yield return AccessTools.Method(typeof(SE_Demister), "OnDestroy", (Type[])null, (Type[])null);
			yield return AccessTools.Method(typeof(SE_Demister), "Stop", (Type[])null, (Type[])null);
		}

		[HarmonyPrefix]
		private static void ItsMistyAgainBro(SE_Demister __instance)
		{
			if (DeezMistyBallsPlugin.CheckBallInstance(__instance))
			{
				DeezMistyBallsPlugin.DemisterParticleFf = null;
			}
		}
	}
	[BepInPlugin("Azumatt.DeezMistyBalls", "DeezMistyBalls", "1.0.4")]
	public class DeezMistyBallsPlugin : BaseUnityPlugin
	{
		public enum Toggle
		{
			On = 1,
			Off = 0
		}

		internal const string ModName = "DeezMistyBalls";

		internal const string ModVersion = "1.0.4";

		internal const string Author = "Azumatt";

		private const string ModGUID = "Azumatt.DeezMistyBalls";

		private static string ConfigFileName = "Azumatt.DeezMistyBalls.cfg";

		private static string ConfigFileFullPath;

		internal const string FfID = "Particle System Force Field";

		internal static ParticleSystemForceField? DemisterParticleFf;

		private readonly Harmony _harmony = new Harmony("Azumatt.DeezMistyBalls");

		public static readonly ManualLogSource DemistThisShitLogger;

		private static ConfigEntry<float> DemisterMaxRange { get; set; }

		private static ConfigEntry<Color> PointLightColor { get; set; }

		private static ConfigEntry<float> DemisterIntensityValue { get; set; }

		public void Awake()
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			DemisterMaxRange = ((BaseUnityPlugin)this).Config.Bind<float>("1 - General", "End Range", 6f, new ConfigDescription("The end range of the demister effect on the Demister Wisp. Range capped at 50 for performance reasons. Default value is vanilla value. Have fun.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(6f, 50f), Array.Empty<object>()));
			DemisterMaxRange.SettingChanged += delegate
			{
				UpdateDemisterRange(null, null);
			};
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			_harmony.PatchAll(executingAssembly);
			SetupWatcher();
			AutoDoc();
		}

		private void OnDestroy()
		{
			((BaseUnityPlugin)this).Config.Save();
			try
			{
				if ((Object)(object)DemisterParticleFf != (Object)null)
				{
					Object.Destroy((Object)(object)DemisterParticleFf);
				}
			}
			catch
			{
			}
		}

		internal static bool CheckBallInstance(SE_Demister ballthingy)
		{
			return (Object)(object)ballthingy.m_ballInstance != (Object)null;
		}

		private void SetupWatcher()
		{
			FileSystemWatcher fileSystemWatcher = new FileSystemWatcher(Paths.ConfigPath, ConfigFileName);
			fileSystemWatcher.Changed += ReadConfigValues;
			fileSystemWatcher.Created += ReadConfigValues;
			fileSystemWatcher.Renamed += ReadConfigValues;
			fileSystemWatcher.IncludeSubdirectories = true;
			fileSystemWatcher.SynchronizingObject = ThreadingHelper.SynchronizingObject;
			fileSystemWatcher.EnableRaisingEvents = true;
		}

		private void ReadConfigValues(object sender, FileSystemEventArgs e)
		{
			if (!File.Exists(ConfigFileFullPath))
			{
				return;
			}
			try
			{
				DemistThisShitLogger.LogDebug((object)"ReadConfigValues called");
				((BaseUnityPlugin)this).Config.Reload();
			}
			catch
			{
				DemistThisShitLogger.LogError((object)("There was an issue loading your " + ConfigFileName));
				DemistThisShitLogger.LogError((object)"Please check your config entries for spelling and format!");
			}
		}

		internal static void UpdateDemisterRange(object sender, EventArgs e)
		{
			if ((Object)(object)DemisterParticleFf != (Object)null)
			{
				DemisterParticleFf.endRange = DemisterMaxRange.Value;
			}
		}

		internal void AutoDoc()
		{
		}

		static DeezMistyBallsPlugin()
		{
			string configPath = Paths.ConfigPath;
			char directorySeparatorChar = Path.DirectorySeparatorChar;
			ConfigFileFullPath = configPath + directorySeparatorChar + ConfigFileName;
			DemisterParticleFf = null;
			DemistThisShitLogger = Logger.CreateLogSource("DeezMistyBalls");
			DemisterMaxRange = null;
			PointLightColor = null;
			DemisterIntensityValue = null;
		}
	}
}