Decompiled source of RGBeamer v1.0.0

RepoBeamColorMod.dll

Decompiled 3 months ago
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 HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("RepoBeamColorMod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("RepoBeamColorMod")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("1da36b51-dd3f-4348-9706-6da677913988")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
[BepInPlugin("com.homeboyyosh.BeamColor", "REPO Beam Color Mod", "1.0.0")]
public class RepoMod : BaseUnityPlugin
{
	private void Awake()
	{
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Expected O, but got Unknown
		((BaseUnityPlugin)this).Logger.LogInfo((object)"REPO RGBeamer Mod Loaded");
		Harmony val = new Harmony("com.homeboyyosh.BeamColor");
		val.PatchAll();
	}
}
[HarmonyPatch(typeof(SemiLaser), "LaserEffectLine")]
public class LaserEffectLinePatch
{
	private static HashSet<Material> configuredMaterials = new HashSet<Material>();

	private static void Postfix(SemiLaser __instance)
	{
		//IL_014c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0151: Unknown result type (might be due to invalid IL or missing references)
		//IL_019b: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_02eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0300: Unknown result type (might be due to invalid IL or missing references)
		//IL_030a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0314: Unknown result type (might be due to invalid IL or missing references)
		//IL_0376: Unknown result type (might be due to invalid IL or missing references)
		//IL_0385: Unknown result type (might be due to invalid IL or missing references)
		//IL_0394: Unknown result type (might be due to invalid IL or missing references)
		//IL_03a3: Unknown result type (might be due to invalid IL or missing references)
		FieldInfo fieldInfo = AccessTools.Field(typeof(SemiLaser), "lineRenderers");
		List<LineRenderer> list = fieldInfo.GetValue(__instance) as List<LineRenderer>;
		FieldInfo fieldInfo2 = AccessTools.Field(typeof(SemiLaser), "pointLights");
		List<Light> list2 = fieldInfo2.GetValue(__instance) as List<Light>;
		FieldInfo fieldInfo3 = AccessTools.Field(typeof(SemiLaser), "hitLight");
		object? value = fieldInfo3.GetValue(__instance);
		Light val = (Light)((value is Light) ? value : null);
		FieldInfo fieldInfo4 = AccessTools.Field(typeof(SemiLaser), "hitParticles");
		List<ParticleSystem> list3 = fieldInfo4.GetValue(__instance) as List<ParticleSystem>;
		FieldInfo fieldInfo5 = AccessTools.Field(typeof(SemiLaser), "shootParticles");
		List<ParticleSystem> list4 = fieldInfo5.GetValue(__instance) as List<ParticleSystem>;
		FieldInfo fieldInfo6 = AccessTools.Field(typeof(SemiLaser), "graceParticles");
		List<ParticleSystem> list5 = fieldInfo6.GetValue(__instance) as List<ParticleSystem>;
		FieldInfo fieldInfo7 = AccessTools.Field(typeof(SemiLaser), "hitMeshRenderers");
		List<MeshRenderer> list6 = fieldInfo7.GetValue(__instance) as List<MeshRenderer>;
		if (list == null || list2 == null || (Object)(object)val == (Object)null || list3 == null || list4 == null || list5 == null || list6 == null)
		{
			return;
		}
		float num = Time.time * 2f % 1f;
		Color val2 = Color.HSVToRGB(num, 1f, 1f);
		foreach (LineRenderer item in list)
		{
			if ((Object)(object)item != (Object)null && (Object)(object)((Renderer)item).material != (Object)null)
			{
				((Renderer)item).material.SetColor("_EmissionColor", val2);
				if (!configuredMaterials.Contains(((Renderer)item).material))
				{
					((Renderer)item).material.SetFloat("_Mode", 1f);
					((Renderer)item).material.renderQueue = 3000;
					((Renderer)item).material.SetInt("_SrcBlend", 1);
					((Renderer)item).material.SetInt("_DstBlend", 1);
					((Renderer)item).material.SetInt("_ZWrite", 0);
					((Renderer)item).material.DisableKeyword("_ALPHATEST_ON");
					((Renderer)item).material.DisableKeyword("_ALPHABLEND_ON");
					((Renderer)item).material.EnableKeyword("_ALPHAPREMULTIPLY_ON");
					((Renderer)item).material.EnableKeyword("_EMISSION");
					configuredMaterials.Add(((Renderer)item).material);
				}
			}
		}
		foreach (Light item2 in list2)
		{
			if ((Object)(object)item2 != (Object)null)
			{
				item2.color = val2;
			}
		}
		__instance.laserSpotLight.color = val2;
		val.color = val2;
		RecolorParticles(list3, val2);
		RecolorParticles(list4, val2);
		RecolorParticles(list5, val2);
		foreach (MeshRenderer item3 in list6)
		{
			if ((Object)(object)item3 == (Object)null)
			{
				continue;
			}
			Material[] materials = ((Renderer)item3).materials;
			foreach (Material val3 in materials)
			{
				if ((Object)(object)val3 != (Object)null)
				{
					val3.color = val2;
					val3.SetColor("_Color", val2);
					val3.SetColor("_EmissionColor", val2);
					val3.SetColor("_TintColor", val2);
					if (!configuredMaterials.Contains(val3))
					{
						val3.SetFloat("_Mode", 1f);
						val3.renderQueue = 3000;
						val3.SetInt("_SrcBlend", 1);
						val3.SetInt("_DstBlend", 1);
						val3.SetInt("_ZWrite", 0);
						val3.DisableKeyword("_ALPHATEST_ON");
						val3.DisableKeyword("_ALPHABLEND_ON");
						val3.EnableKeyword("_ALPHAPREMULTIPLY_ON");
						configuredMaterials.Add(val3);
					}
				}
			}
		}
		static void RecolorParticles(List<ParticleSystem> systems, Color color)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: 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_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			foreach (ParticleSystem system in systems)
			{
				if (!((Object)(object)system == (Object)null))
				{
					MainModule main = system.main;
					((MainModule)(ref main)).startColor = new MinMaxGradient(color);
					ParticleSystemRenderer component = ((Component)system).GetComponent<ParticleSystemRenderer>();
					if ((Object)(object)component != (Object)null && (Object)(object)((Renderer)component).material != (Object)null)
					{
						((Renderer)component).material.color = color;
						((Renderer)component).material.SetColor("_Color", color);
						((Renderer)component).material.SetColor("_TintColor", color);
					}
					if ((Object)(object)component.trailMaterial != (Object)null)
					{
						component.trailMaterial.color = color;
						component.trailMaterial.SetColor("_Color", color);
						component.trailMaterial.SetColor("_TintColor", color);
						component.trailMaterial.SetColor("_EmissionColor", color);
						if (!configuredMaterials.Contains(component.trailMaterial))
						{
							component.trailMaterial.SetFloat("_Mode", 1f);
							component.trailMaterial.renderQueue = 3000;
							component.trailMaterial.SetInt("_SrcBlend", 1);
							component.trailMaterial.SetInt("_DstBlend", 1);
							component.trailMaterial.SetInt("_ZWrite", 0);
							component.trailMaterial.DisableKeyword("_ALPHATEST_ON");
							component.trailMaterial.DisableKeyword("_ALPHABLEND_ON");
							component.trailMaterial.EnableKeyword("_ALPHAPREMULTIPLY_ON");
							component.trailMaterial.EnableKeyword("_EMISSION");
							configuredMaterials.Add(component.trailMaterial);
						}
					}
				}
			}
		}
	}
}