Decompiled source of AnyParry v1.0.1

plugins/AnyParry.dll

Decompiled 8 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
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 PluginConfig.API;
using PluginConfig.API.Fields;
using PluginConfig.API.Functionals;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("AnyParry")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("AnyParry")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("cb6b9024-a4ab-4f88-89d0-a55eee98955f")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace AnyParry;

public static class ConfigManager
{
	public enum FilterType
	{
		Point,
		Bilinear,
		Trilinear
	}

	private static PluginConfigurator config;

	private static ButtonField openParryFolder;

	private static ButtonField refresh;

	public static EnumField<FilterType> filterType;

	private static string workingDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

	private static string iconFilePath = Path.Combine(Path.Combine(workingDirectory, "Data"), "icon.png");

	public static void Setup()
	{
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_0033: Expected O, but got Unknown
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0049: Expected O, but got Unknown
		//IL_005e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Expected O, but got Unknown
		//IL_0074: Unknown result type (might be due to invalid IL or missing references)
		//IL_007e: Expected O, but got Unknown
		config = PluginConfigurator.Create("AnyParry", "ironfarm.uk.anyparry");
		openParryFolder = new ButtonField(config.rootPanel, "Open Parry Folder", "button.openfolder");
		openParryFolder.onClick += new OnClick(OpenFolder);
		refresh = new ButtonField(config.rootPanel, "Refresh Parry Images", "button.refresh");
		refresh.onClick += new OnClick(Plugin.UpdateParryList);
		filterType = new EnumField<FilterType>(config.rootPanel, "Texture Filtering Mode", "field.filter", FilterType.Point, true);
		filterType.onValueChange += delegate
		{
			Plugin.UpdateParryList();
		};
		config.SetIconWithURL("file://" + iconFilePath);
	}

	public static void OpenFolder()
	{
		Application.OpenURL(Path.Combine(workingDirectory, "ParryImages"));
	}
}
[BepInPlugin("ironfarm.uk.anyparry", "AnyParry", "1.0.1")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BaseUnityPlugin
{
	public static class PatchDude
	{
		[HarmonyPatch(typeof(TimeController), "ParryFlash")]
		[HarmonyPostfix]
		private static void SetParryImage(TimeController __instance)
		{
			if (parrySprites.Count < 1)
			{
				__instance.parryFlash.GetComponent<Image>().sprite = null;
			}
			else
			{
				__instance.parryFlash.GetComponent<Image>().sprite = parrySprites[Random.Range(0, parrySprites.Count)];
			}
		}
	}

	public static List<string> imageTypes = new List<string> { ".jpeg", ".jpg", ".png", ".bmp" };

	public static List<Sprite> parrySprites = new List<Sprite>();

	public static string ModDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

	public Harmony harm;

	public void Start()
	{
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Expected O, but got Unknown
		ConfigManager.Setup();
		UpdateParryList();
		harm = new Harmony("ironfarm.uk.anyparry");
		harm.PatchAll(typeof(PatchDude));
	}

	public static void UpdateParryList()
	{
		//IL_0078: Unknown result type (might be due to invalid IL or missing references)
		//IL_007f: Expected O, but got Unknown
		//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
		parrySprites = new List<Sprite>();
		foreach (string item2 in Directory.EnumerateFiles(Path.Combine(Path.Combine(ModDir, "ParryImages"))))
		{
			for (int i = 0; i < imageTypes.Count; i++)
			{
				if (string.Equals(imageTypes[i], Path.GetExtension(item2), StringComparison.OrdinalIgnoreCase))
				{
					Debug.Log((object)item2);
					byte[] array = File.ReadAllBytes(item2);
					Texture2D val = new Texture2D(0, 0, (TextureFormat)4, false);
					((Texture)val).filterMode = (FilterMode)ConfigManager.filterType.value;
					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));
					parrySprites.Add(item);
					break;
				}
			}
		}
	}
}
internal class PluginInfo
{
	public const string Name = "AnyParry";

	public const string GUID = "ironfarm.uk.anyparry";

	public const string Version = "1.0.1";
}