Decompiled source of VisualFeedback v3.0.0

BepInEx/plugins/VisFeedback.dll

Decompiled 9 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using BombRushMP.Plugin.Gamemodes;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Reptile;
using UnityEngine;
using UnityEngine.UI;
using VisFeedback.Patches;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")]
[assembly: AssemblyCompany("VisFeedback")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("3.0.0.0")]
[assembly: AssemblyInformationalVersion("3.0.0")]
[assembly: AssemblyProduct("Visual Feedback")]
[assembly: AssemblyTitle("VisFeedback")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("3.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace VisFeedback
{
	public class Animator : MonoBehaviour
	{
		public bool IsOn = false;

		public bool animating = false;

		public bool looping;

		public bool Interrupt;

		public List<Sprite> SL;

		public GameObject ovalay;

		public float framerate;

		public float duration;

		public string AnimName;

		public bool Impulse;

		public float frametimer;

		public float passedtime;

		private int index = 0;

		public int order;

		public int priority;

		public static int currentPrio;

		public configTemplate theConfig;

		public void initAnim(GameObject uovalay, List<Sprite> uSL, bool uImpulse, configTemplate configAccess)
		{
			ovalay = uovalay;
			SL = uSL;
			theConfig = configAccess;
			framerate = configAccess.Fps.Value;
			duration = configAccess.Duration.Value;
			AnimName = configAccess.Name.Value;
			looping = configAccess.Loop.Value;
			Impulse = uImpulse;
			Interrupt = configAccess.Interupt.Value;
			order = configAccess.Order.Value;
			priority = configAccess.Prio.Value;
		}

		private void Update()
		{
			IsOn = theConfig.Enable.Value;
			((Behaviour)ovalay.GetComponent<Image>()).enabled = false;
			if (!IsOn)
			{
				return;
			}
			ovalay.GetComponent<Canvas>().sortingOrder = order;
			if (animating)
			{
				if (Interrupt)
				{
					if (priority < currentPrio)
					{
						animating = false;
						return;
					}
					currentPrio = priority;
				}
				index = 0;
				((Behaviour)ovalay.GetComponent<Image>()).enabled = true;
				index = (int)Math.Floor(frametimer * framerate);
				ovalay.GetComponent<Image>().sprite = SL[index];
				((Behaviour)ovalay.GetComponent<Image>()).enabled = Plugin.visible.Value;
				if (Impulse && passedtime >= duration * (1f / framerate))
				{
					ResetAll();
				}
				if (index >= SL.Count - 1)
				{
					if (!looping)
					{
						passedtime += Time.deltaTime;
						return;
					}
					index = 0;
					frametimer = 0f;
				}
				passedtime += Time.deltaTime;
				frametimer += Time.deltaTime;
			}
			else
			{
				ResetAll();
				if (priority == currentPrio)
				{
					currentPrio = 0;
				}
				((Behaviour)ovalay.GetComponent<Image>()).enabled = false;
			}
		}

		public void ResetAll()
		{
			passedtime = 0f;
			frametimer = 0f;
			index = 0;
			animating = false;
		}
	}
	public class configTemplate
	{
		public string categoryName;

		public ConfigEntry<bool> Enable;

		public ConfigEntry<float> Fps;

		public ConfigEntry<float> Duration;

		public ConfigEntry<bool> Loop;

		public ConfigEntry<int> Order;

		public ConfigEntry<int> Prio;

		public ConfigEntry<string> Name;

		public ConfigEntry<bool> Interupt;

		public configTemplate(string category, ConfigFile config)
		{
			categoryName = category;
			Enable = config.Bind<bool>(category + " Overlay", "Enable", false, "");
			Fps = config.Bind<float>(category + " Overlay", "Framerate", 1f, "");
			Duration = config.Bind<float>(category + " Overlay", "Duration", 1f, "");
			Loop = config.Bind<bool>(category + " Overlay", "loop", true, "");
			Order = config.Bind<int>(category + " Overlay", "Order", 1, "");
			Prio = config.Bind<int>(category + " Overlay", "Priority", 1, "");
			Name = config.Bind<string>(category + " Overlay", "File Name", "test", "");
			Interupt = config.Bind<bool>(category + " Overlay", "Interrupt", false, "");
			base..ctor();
		}
	}
	internal class initNewOvalay : MonoBehaviour
	{
		public GameObject theObject;

		public List<Sprite> theSpriteList;

		public Animator theAnimator;

		public initNewOvalay(configTemplate configtemp, bool impulse)
		{
			theObject = OvalayMaker();
			theAnimator = theObject.AddComponent(typeof(Animator)) as Animator;
			theSpriteList = spritelistmaker(configtemp.Name.Value);
			theAnimator.initAnim(theObject, theSpriteList, impulse, configtemp);
		}

		public GameObject OvalayMaker()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject();
			Component obj = val.AddComponent(typeof(RectTransform));
			RectTransform val2 = (RectTransform)(object)((obj is RectTransform) ? obj : null);
			Component obj2 = val.AddComponent(typeof(Canvas));
			Canvas val3 = (Canvas)(object)((obj2 is Canvas) ? obj2 : null);
			val3.renderMode = (RenderMode)0;
			Component obj3 = val.AddComponent(typeof(Image));
			Image val4 = (Image)(object)((obj3 is Image) ? obj3 : null);
			val2.anchoredPosition = new Vector2(0f, 0f);
			return val;
		}

		public static List<Sprite> spritelistmaker(string name)
		{
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Expected O, but got Unknown
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			List<Sprite> list = new List<Sprite>();
			bool flag = true;
			int num = 0;
			while (flag)
			{
				Debug.Log((object)(Paths.BepInExRootPath + "\\img/" + name + num + ".png"));
				if (File.Exists(Paths.BepInExRootPath + "\\img/" + name + num + ".png"))
				{
					Texture2D val = new Texture2D(1, 1);
					byte[] array = File.ReadAllBytes(Paths.BepInExRootPath + "\\img/" + name + num + ".png");
					ImageConversion.LoadImage(val, array);
					Sprite item = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f));
					list.Add(item);
					num++;
				}
				else
				{
					flag = false;
				}
			}
			return list;
		}
	}
	[BepInPlugin("VisFeedback", "Visual Feedback", "3.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Logger;

		public static Harmony Harmony;

		public static ConfigEntry<bool> enable;

		public static ConfigEntry<KeyCode> enableToggle;

		public static ConfigEntry<bool> visible;

		public static configTemplate gspot;

		public static configTemplate p;

		public static configTemplate isCombo;

		public static configTemplate ComboDrop;

		public static configTemplate boost;

		public static configTemplate ComboTimeoutVis;

		public static configTemplate PressJump;

		public static configTemplate PressSpray;

		public static configTemplate PressMoveStyle;

		public static configTemplate PressSlide;

		public static configTemplate PressBoost;

		public static configTemplate PressTrick1;

		public static configTemplate PressTrick2;

		public static configTemplate PressTrick3;

		private void Awake()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			Harmony = new Harmony("VisFeedback.Harmony");
			Harmony.PatchAll();
			enableToggle = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("1. General", "Toggle Enable Button", (KeyCode)0, "button to toggle visibiltiy");
			enable = ((BaseUnityPlugin)this).Config.Bind<bool>("1. General", "Enable Plugin", true, "enable the plugin vro");
			visible = ((BaseUnityPlugin)this).Config.Bind<bool>("1. General", "Overlay Visible", true, "show/hide overlay");
			p = new configTemplate("Default", ((BaseUnityPlugin)this).Config);
			gspot = new configTemplate("Graffiti Spot", ((BaseUnityPlugin)this).Config);
			isCombo = new configTemplate("Is Comboin", ((BaseUnityPlugin)this).Config);
			ComboDrop = new configTemplate("Combo Drop", ((BaseUnityPlugin)this).Config);
			boost = new configTemplate("Boost", ((BaseUnityPlugin)this).Config);
			ComboTimeoutVis = new configTemplate("Combo Timeout Bar visable", ((BaseUnityPlugin)this).Config);
			PressJump = new configTemplate("Pressing Jump", ((BaseUnityPlugin)this).Config);
			PressSpray = new configTemplate("Pressing Spray", ((BaseUnityPlugin)this).Config);
			PressMoveStyle = new configTemplate("Pressing MoveStyle", ((BaseUnityPlugin)this).Config);
			PressSlide = new configTemplate("Pressing Slide", ((BaseUnityPlugin)this).Config);
			PressBoost = new configTemplate("Pressing Boost", ((BaseUnityPlugin)this).Config);
			PressTrick1 = new configTemplate("Pressing Trick1", ((BaseUnityPlugin)this).Config);
			PressTrick2 = new configTemplate("Pressing Trick2", ((BaseUnityPlugin)this).Config);
			PressTrick3 = new configTemplate("Pressing Trick3", ((BaseUnityPlugin)this).Config);
		}

		private void Update()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			if (Input.GetKeyDown(enableToggle.Value))
			{
				visible.Value = !visible.Value;
			}
			if (!((Object)(object)Pawake.pOva.theObject == (Object)null))
			{
				Pawake.pOva.theAnimator.IsOn = p.Enable.Value;
				Pawake.pOva.theAnimator.animating = true;
				if (p.Interupt.Value)
				{
					Pawake.pOva.theAnimator.animating = p.Prio.Value >= Animator.currentPrio;
				}
			}
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "VisFeedback";

		public const string PLUGIN_NAME = "Visual Feedback";

		public const string PLUGIN_VERSION = "3.0.0";
	}
}
namespace VisFeedback.Patches
{
	[HarmonyPatch(typeof(GraffitiRace), "MarkGraffitiSpotDone")]
	internal class GracePatch : MonoBehaviour
	{
		public static void Postfix(GraffitiRace __instance)
		{
			Pawake.gspotOva.theAnimator.animating = true;
		}
	}
	[HarmonyPatch(typeof(GameplayUI), "OnStageInitialized")]
	internal class Pawake : MonoBehaviour
	{
		public static initNewOvalay gspotOva;

		public static initNewOvalay isComboOva;

		public static initNewOvalay ComboDropOva;

		public static initNewOvalay pOva;

		public static initNewOvalay boostOva;

		public static initNewOvalay ComboTimeoutVisOva;

		public static initNewOvalay PressJumpOva;

		public static initNewOvalay PressSprayOva;

		public static initNewOvalay PressMoveStyleOva;

		public static initNewOvalay PressSlideOva;

		public static initNewOvalay PressBoostOva;

		public static initNewOvalay PressTrick1Ova;

		public static initNewOvalay PressTrick2Ova;

		public static initNewOvalay PressTrick3Ova;

		public static void Postfix(GameplayUI __instance)
		{
			if (Plugin.enable.Value)
			{
				pOva = new initNewOvalay(Plugin.p, impulse: false);
				gspotOva = new initNewOvalay(Plugin.gspot, impulse: true);
				isComboOva = new initNewOvalay(Plugin.isCombo, impulse: false);
				ComboDropOva = new initNewOvalay(Plugin.ComboDrop, impulse: true);
				boostOva = new initNewOvalay(Plugin.boost, impulse: false);
				ComboTimeoutVisOva = new initNewOvalay(Plugin.ComboTimeoutVis, impulse: false);
				PressJumpOva = new initNewOvalay(Plugin.PressJump, impulse: false);
				PressSprayOva = new initNewOvalay(Plugin.PressSpray, impulse: false);
				PressMoveStyleOva = new initNewOvalay(Plugin.PressMoveStyle, impulse: false);
				PressSlideOva = new initNewOvalay(Plugin.PressSlide, impulse: false);
				PressBoostOva = new initNewOvalay(Plugin.PressBoost, impulse: false);
				PressTrick1Ova = new initNewOvalay(Plugin.PressTrick1, impulse: false);
				PressTrick2Ova = new initNewOvalay(Plugin.PressTrick2, impulse: false);
				PressTrick3Ova = new initNewOvalay(Plugin.PressTrick3, impulse: false);
			}
		}
	}
	[HarmonyPatch(typeof(Player))]
	internal class PlayerPatch : MonoBehaviour
	{
		[HarmonyPostfix]
		[HarmonyPatch("FixedUpdatePlayer")]
		public static void Postfix1(Player __instance)
		{
			if (!__instance.isAI)
			{
				Pawake.PressJumpOva.theAnimator.animating = __instance.jumpButtonHeld;
				Pawake.PressSprayOva.theAnimator.animating = __instance.sprayButtonHeld;
				Pawake.PressMoveStyleOva.theAnimator.animating = __instance.switchStyleButtonHeld;
				Pawake.PressSlideOva.theAnimator.animating = __instance.slideButtonHeld;
				Pawake.PressBoostOva.theAnimator.animating = __instance.boostButtonHeld;
				Pawake.PressTrick1Ova.theAnimator.animating = __instance.trick1ButtonHeld;
				Pawake.PressTrick2Ova.theAnimator.animating = __instance.trick2ButtonHeld;
				Pawake.PressTrick3Ova.theAnimator.animating = __instance.trick3ButtonHeld;
				Pawake.isComboOva.theAnimator.animating = __instance.IsComboing();
				Pawake.boostOva.theAnimator.animating = __instance.boosting;
				Pawake.ComboTimeoutVisOva.theAnimator.animating = __instance.ui.comboTimeOutBackdrop.fillAmount != 0f;
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch("HitScore")]
		public static void Postfix2(Player __instance)
		{
			Pawake.ComboDropOva.theAnimator.animating = true;
		}
	}
}