Decompiled source of No Particles v1.0.1

NoParticles.dll

Decompiled 2 weeks ago
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
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 HarmonyLib;
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("NoParticles")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("GeeztJeez")]
[assembly: AssemblyProduct("NoParticles")]
[assembly: AssemblyCopyright("Copyright © 2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("7acfaef0-7669-4401-8bff-5a9a02e18c75")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.1.0")]
[module: UnverifiableCode]
namespace NoParticles;

[BepInPlugin("GeeztJeez.NoParticles", "NoParticles", "1.0.1")]
public class Loader : BaseUnityPlugin
{
	internal static Harmony HarmonyInstance;

	private void Awake()
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_000f: Expected O, but got Unknown
		HarmonyInstance = new Harmony("GeeztJeez.NoParticles");
		HarmonyInstance.PatchAll();
		ApplyParticleSettings();
		((MonoBehaviour)this).StartCoroutine(EnforceParticleSettings());
	}

	private void ApplyParticleSettings()
	{
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		//IL_0060: Unknown result type (might be due to invalid IL or missing references)
		//IL_0065: Unknown result type (might be due to invalid IL or missing references)
		ParticleSystem[] array = Resources.FindObjectsOfTypeAll<ParticleSystem>();
		Scene scene;
		foreach (ParticleSystem val in array)
		{
			if (!((Object)(object)val == (Object)null))
			{
				scene = ((Component)val).gameObject.scene;
				if (((Scene)(ref scene)).IsValid())
				{
					val.Stop(true, (ParticleSystemStopBehavior)0);
				}
			}
		}
		ParticleSystemRenderer[] array2 = Resources.FindObjectsOfTypeAll<ParticleSystemRenderer>();
		foreach (ParticleSystemRenderer val2 in array2)
		{
			if (!((Object)(object)val2 == (Object)null))
			{
				scene = ((Component)val2).gameObject.scene;
				if (((Scene)(ref scene)).IsValid())
				{
					((Renderer)val2).enabled = false;
				}
			}
		}
	}

	private IEnumerator EnforceParticleSettings()
	{
		while (true)
		{
			ApplyParticleSettings();
			yield return (object)new WaitForSeconds(0.25f);
		}
	}

	private void OnDestroy()
	{
		Harmony harmonyInstance = HarmonyInstance;
		if (harmonyInstance != null)
		{
			harmonyInstance.UnpatchSelf();
		}
	}
}
[HarmonyPatch]
internal static class ParticleSystemPlayPatch
{
	private static IEnumerable<MethodBase> TargetMethods()
	{
		return from method in typeof(ParticleSystem).GetMethods(BindingFlags.Instance | BindingFlags.Public)
			where method.Name == "Play"
			select method;
	}

	private static bool Prefix()
	{
		return false;
	}
}
[HarmonyPatch]
internal static class ParticleSystemEmitPatch
{
	private static IEnumerable<MethodBase> TargetMethods()
	{
		return from method in typeof(ParticleSystem).GetMethods(BindingFlags.Instance | BindingFlags.Public)
			where method.Name == "Emit"
			select method;
	}

	private static bool Prefix()
	{
		return false;
	}
}
[HarmonyPatch]
internal static class ParticleSystemSimulatePatch
{
	private static IEnumerable<MethodBase> TargetMethods()
	{
		return from method in typeof(ParticleSystem).GetMethods(BindingFlags.Instance | BindingFlags.Public)
			where method.Name == "Simulate"
			select method;
	}

	private static bool Prefix()
	{
		return false;
	}
}
[HarmonyPatch(typeof(Renderer), "set_enabled")]
internal static class ParticleRendererEnabledPatch
{
	private static bool Prefix(Renderer __instance, bool value)
	{
		if (__instance is ParticleSystemRenderer && value)
		{
			return false;
		}
		return true;
	}
}