Decompiled source of NightmareHornet v1.1.1

plugins/NightmareHornetAddon.dll

Decompiled 3 days ago
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
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("NHFilter")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("NHFilter")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("5f9bf04a-32c7-4396-9061-9dc9281e0bf7")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
[BepInPlugin("com.yourname.nightmarehornetaddon", "Nightmare Hornet Addon", "1.0.0")]
public class NightmareHornetAddon : BaseUnityPlugin
{
	private struct ColorSwap
	{
		public Color OldColor;

		public Color NewColor;

		public ColorSwap(Color old, Color newCol)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			OldColor = old;
			NewColor = newCol;
		}
	}

	public const string PluginGuid = "com.yourname.nightmarehornetaddon";

	public const string PluginName = "Nightmare Hornet Addon";

	public const string PluginVersion = "1.0.0";

	private string targetRoomName = "Memory_Red";

	private List<string> targetGroupPaths = new List<string> { "Scenery Groups/Hive Scenery", "Scenery Groups/End Scenery", "Memory Control/Hive_Memory_Lighting" };

	private List<ColorSwap> scenerySwaps;

	private List<ColorSwap> particleSwaps;

	private void Awake()
	{
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0046: Unknown result type (might be due to invalid IL or missing references)
		//IL_006b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0084: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0100: Unknown result type (might be due to invalid IL or missing references)
		//IL_0125: Unknown result type (might be due to invalid IL or missing references)
		//IL_013e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0163: Unknown result type (might be due to invalid IL or missing references)
		//IL_017c: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_01df: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_021d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0236: Unknown result type (might be due to invalid IL or missing references)
		//IL_025b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0274: Unknown result type (might be due to invalid IL or missing references)
		//IL_0299: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0315: Unknown result type (might be due to invalid IL or missing references)
		//IL_032e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0353: Unknown result type (might be due to invalid IL or missing references)
		//IL_036c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0391: Unknown result type (might be due to invalid IL or missing references)
		//IL_03aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_03cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_03e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_040d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0426: Unknown result type (might be due to invalid IL or missing references)
		//IL_044b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0464: Unknown result type (might be due to invalid IL or missing references)
		//IL_0489: Unknown result type (might be due to invalid IL or missing references)
		//IL_04a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_04c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_04e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0505: Unknown result type (might be due to invalid IL or missing references)
		//IL_051e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0543: Unknown result type (might be due to invalid IL or missing references)
		//IL_055c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0581: Unknown result type (might be due to invalid IL or missing references)
		//IL_059a: Unknown result type (might be due to invalid IL or missing references)
		//IL_05bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_05d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_05fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0616: Unknown result type (might be due to invalid IL or missing references)
		//IL_063b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0654: Unknown result type (might be due to invalid IL or missing references)
		//IL_0679: Unknown result type (might be due to invalid IL or missing references)
		//IL_0692: Unknown result type (might be due to invalid IL or missing references)
		//IL_06c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_06db: Unknown result type (might be due to invalid IL or missing references)
		//IL_0700: Unknown result type (might be due to invalid IL or missing references)
		//IL_0719: Unknown result type (might be due to invalid IL or missing references)
		((BaseUnityPlugin)this).Logger.LogInfo((object)"Nightmare Hornet Addon is loaded!");
		scenerySwaps = new List<ColorSwap>
		{
			new ColorSwap(new Color(0.434f, 0.3181f, 0.1781f, 0.6392f), new Color(0.434f, 0f, 0.1781f, 0.6392f)),
			new ColorSwap(new Color(0.7736f, 0.5417f, 0.2445f, 0.4118f), new Color(0.7736f, 0.0205f, 0.1645f, 0.4118f)),
			new ColorSwap(new Color(0.7736f, 0.5417f, 0.2445f, 0.6588f), new Color(0.7736f, 0.2517f, 0.2445f, 0.6588f)),
			new ColorSwap(new Color(0.7736f, 0.5417f, 0.2445f, 0.4941f), new Color(0.7736f, 0.2517f, 0.2445f, 0.4941f)),
			new ColorSwap(new Color(0.7642f, 0.5704f, 0.3208f, 0.7294f), new Color(0.7642f, 0.3204f, 0.3208f, 0.7294f)),
			new ColorSwap(new Color(0.7736f, 0.5417f, 0.2445f, 0.7294f), new Color(0.7736f, 0.1462f, 0.2445f, 0.7294f)),
			new ColorSwap(new Color(0.6698f, 0.4616f, 0.2117f, 0.6392f), new Color(0.6698f, 0.1116f, 0.2117f, 0.6392f)),
			new ColorSwap(new Color(0.6698f, 0.4616f, 0.2117f, 0.3882f), new Color(0.6698f, 0.1116f, 0.2117f, 0.3882f)),
			new ColorSwap(new Color(0.7075f, 0.5834f, 0.3972f, 0.5882f), new Color(0.7075f, 0.2634f, 0.3972f, 0.5882f)),
			new ColorSwap(new Color(0.6415f, 0.4655f, 0.2451f, 1f), new Color(0.6415f, 0.2255f, 0.2451f, 1f)),
			new ColorSwap(new Color(0.6415f, 0.4655f, 0.2451f, 0.7294f), new Color(0.6415f, 0.2255f, 0.2451f, 0.7294f)),
			new ColorSwap(new Color(0.6604f, 0.4577f, 0.1838f, 0.8f), new Color(0.6604f, 0.1477f, 0.1838f, 0.8f)),
			new ColorSwap(new Color(0.6415f, 0.4655f, 0.2451f, 0.3765f), new Color(0.6415f, 0.2255f, 0.2451f, 0.3765f)),
			new ColorSwap(new Color(0.6415f, 0.4655f, 0.2451f, 0.5686f), new Color(0.6415f, 0.2255f, 0.2451f, 0.5686f)),
			new ColorSwap(new Color(0.7547f, 0.4725f, 0.1317f, 0.4392f), new Color(0.7547f, 0f, 0.1317f, 0.4392f)),
			new ColorSwap(new Color(0.7529f, 0.4759f, 0.1333f, 0.5255f), new Color(0.5629f, 0f, 0.1333f, 0.5255f)),
			new ColorSwap(new Color(0.7529f, 0.4759f, 0.1333f, 0.3765f), new Color(0.5629f, 0.015f, 0.1333f, 0.3765f)),
			new ColorSwap(new Color(0.7529f, 0.4759f, 0.1333f, 0.6314f), new Color(0.5629f, 0f, 0.1333f, 0.6314f)),
			new ColorSwap(new Color(0.7529f, 0.4759f, 0.1333f, 0.9647f), new Color(0.5629f, 0f, 0.1333f, 0.9647f)),
			new ColorSwap(new Color(0.9151f, 0.7593f, 0.5655f, 0.6588f), new Color(0.9151f, 0.4093f, 0.4955f, 0.6588f)),
			new ColorSwap(new Color(0.9151f, 0.7593f, 0.5655f, 0.5529f), new Color(0.9151f, 0.4093f, 0.4955f, 0.5529f)),
			new ColorSwap(new Color(0.9338f, 0.6894f, 0.3227f, 0.3961f), new Color(0.9338f, 0.0394f, 0.3227f, 0.3961f)),
			new ColorSwap(new Color(0.8679f, 0.6612f, 0.4544f, 0.5961f), new Color(0.8679f, 0.3212f, 0.4544f, 0.5961f)),
			new ColorSwap(new Color(0.8667f, 0.6469f, 0.4706f, 1f), new Color(0.8667f, 0.3269f, 0.4706f, 1f)),
			new ColorSwap(new Color(0.5849f, 0.4711f, 0.1628f, 0.7216f), new Color(0.5849f, 0.0711f, 0.1628f, 0.7216f)),
			new ColorSwap(new Color(0.8302f, 0.5411f, 0f, 0.651f), new Color(0.8302f, 0f, 0f, 0.651f)),
			new ColorSwap(new Color(0.6698f, 0.5007f, 0.2686f, 0.8f), new Color(0.6698f, 0.1807f, 0.2686f, 0.8f))
		};
		particleSwaps = new List<ColorSwap>
		{
			new ColorSwap(new Color(0.8588f, 0.5294f, 0.0314f, 1f), new Color(0.2588f, 0.2394f, 0.43f, 1f)),
			new ColorSwap(new Color(0.8491f, 0.6633f, 0.3244f, 1f), new Color(0.988f, 0.455f, 0.518f, 1f))
		};
		SceneManager.sceneLoaded += OnSceneLoaded;
	}

	private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
	{
		if (!(((Scene)(ref scene)).name != targetRoomName))
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)("Entered room: " + ((Scene)(ref scene)).name + ". Initializing comprehensive swap..."));
			((MonoBehaviour)this).StartCoroutine(ApplyAllSwapsWithDelay());
		}
	}

	private IEnumerator ApplyAllSwapsWithDelay()
	{
		yield return (object)new WaitForSeconds(0.5f);
		foreach (string path in targetGroupPaths)
		{
			GameObject sceneryGroup = GameObject.Find(path);
			if ((Object)(object)sceneryGroup != (Object)null)
			{
				ProcessSceneryGroup(sceneryGroup);
			}
		}
		PatchAllParticlesByColor();
	}

	private void ProcessSceneryGroup(GameObject sceneryGroup)
	{
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0059: Unknown result type (might be due to invalid IL or missing references)
		//IL_0096: Unknown result type (might be due to invalid IL or missing references)
		SpriteRenderer[] componentsInChildren = sceneryGroup.GetComponentsInChildren<SpriteRenderer>(true);
		int num = 0;
		SpriteRenderer[] array = componentsInChildren;
		foreach (SpriteRenderer val in array)
		{
			foreach (ColorSwap scenerySwap in scenerySwaps)
			{
				if (ColorsMatch(val.color, scenerySwap.OldColor))
				{
					val.color = scenerySwap.NewColor;
					if ((Object)(object)((Renderer)val).material != (Object)null && ((Renderer)val).material.HasProperty("_Color"))
					{
						((Renderer)val).material.color = scenerySwap.NewColor;
					}
					num++;
					break;
				}
			}
		}
		((BaseUnityPlugin)this).Logger.LogInfo((object)$"Swapped colors on {num} sprites in '{((Object)sceneryGroup).name}'.");
	}

	private void PatchAllParticlesByColor()
	{
		//IL_001b: 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_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_004f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0053: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0072: Unknown result type (might be due to invalid IL or missing references)
		ParticleSystem[] array = Resources.FindObjectsOfTypeAll<ParticleSystem>();
		int num = 0;
		ParticleSystem[] array2 = array;
		foreach (ParticleSystem val in array2)
		{
			MainModule main = val.main;
			MinMaxGradient startColor = ((MainModule)(ref main)).startColor;
			Color color = ((MinMaxGradient)(ref startColor)).color;
			foreach (ColorSwap particleSwap in particleSwaps)
			{
				if (ColorsMatch(color, particleSwap.OldColor))
				{
					((MainModule)(ref main)).startColor = new MinMaxGradient(particleSwap.NewColor);
					num++;
					break;
				}
			}
		}
		((BaseUnityPlugin)this).Logger.LogInfo((object)$"Swapped colors on {num} Particle Systems (including blueprints).");
	}

	private bool ColorsMatch(Color c1, Color c2, float tolerance = 0.05f)
	{
		//IL_0001: 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_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: Unknown result type (might be due to invalid IL or missing references)
		//IL_0046: Unknown result type (might be due to invalid IL or missing references)
		return Mathf.Abs(c1.r - c2.r) <= tolerance && Mathf.Abs(c1.g - c2.g) <= tolerance && Mathf.Abs(c1.b - c2.b) <= tolerance && Mathf.Abs(c1.a - c2.a) <= tolerance;
	}

	private void OnDestroy()
	{
		SceneManager.sceneLoaded -= OnSceneLoaded;
	}
}