Decompiled source of TromboneChampTimingColors v0.1.0

BepInEx/plugins/TromboneChampTimingColors.dll

Decompiled 8 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BaboonAPI.Hooks.Initializer;
using BepInEx;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("TromboneChampTimingColors")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("TromboneChampTimingColors")]
[assembly: AssemblyTitle("TromboneChampTimingColors")]
[assembly: AssemblyVersion("1.0.0.0")]
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 TromboneChampTimingColors
{
	public class NoteColorsPatch
	{
		[HarmonyPatch(typeof(GameController), "buildNotes")]
		[HarmonyPostfix]
		private static void BuildNotes_Post(List<float[]> ___leveldata, List<GameObject> ___allnotes)
		{
			for (int i = 0; i < ___allnotes.Count; i++)
			{
				float[] array = ___leveldata[i];
				GameObject val = ___allnotes[i];
				float num = array[0];
				double num2 = Math.Floor((double)num + 0.002);
				double a = (double)num - num2;
				float num3;
				float num4;
				float num5;
				if (NearlyEqual(a, 0.0))
				{
					num3 = 1f;
					num4 = 0f;
					num5 = 0f;
				}
				else if (NearlyEqual(a, 0.5))
				{
					num3 = 0f;
					num4 = 0f;
					num5 = 1f;
				}
				else if (NearlyEqual(a, 0.333) || NearlyEqual(a, 0.666))
				{
					num3 = 0.5f;
					num4 = 0f;
					num5 = 0.5f;
				}
				else if (NearlyEqual(a, 0.25) || NearlyEqual(a, 0.75))
				{
					num3 = 1f;
					num4 = 1f;
					num5 = 0f;
				}
				else if (NearlyEqual(a, 0.166) || NearlyEqual(a, 0.833))
				{
					num3 = 1f;
					num4 = 0f;
					num5 = 1f;
				}
				else if (NearlyEqual(a, 0.125) || NearlyEqual(a, 0.375) || NearlyEqual(a, 0.625) || NearlyEqual(a, 0.875))
				{
					num3 = 1f;
					num4 = 0.5f;
					num5 = 0.5f;
				}
				else if (NearlyEqual(a, 0.0833) || NearlyEqual(a, 0.4166) || NearlyEqual(a, 0.5833) || NearlyEqual(a, 0.9166))
				{
					num3 = 0f;
					num4 = 1f;
					num5 = 1f;
				}
				else if (NearlyEqual(a, 0.0625) || NearlyEqual(a, 0.1875) || NearlyEqual(a, 0.3125) || NearlyEqual(a, 0.4375) || NearlyEqual(a, 0.6875) || NearlyEqual(a, 0.8125) || NearlyEqual(a, 0.9375))
				{
					num3 = 0f;
					num4 = 1f;
					num5 = 0f;
				}
				else
				{
					num3 = 0.5f;
					num4 = 0.5f;
					num5 = 0.5f;
				}
				val.GetComponent<NoteDesigner>().setColorScheme(num3, num4, num5, num3, num4, num5);
			}
		}

		private static bool NearlyEqual(double a, double b)
		{
			return Math.Abs(a - b) < 0.002;
		}
	}
	[BepInPlugin("craftedcart.trombone_champ_timing_colors", "Trombone Champ Timing Colors", "0.1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class TimingColorsPlugin : BaseUnityPlugin
	{
		private readonly Harmony _harmony = new Harmony("craftedcart.trombone_champ_timing_colors");

		private void Awake()
		{
			GameInitializationEvent.Register(((BaseUnityPlugin)this).Info, (Action)TryInitialize);
		}

		private void TryInitialize()
		{
			_harmony.PatchAll(typeof(NoteColorsPatch));
		}
	}
}