Decompiled source of AquaVirtualPet v1.0.0

aquavirtualpet.dll

Decompiled 13 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.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using PluginConfig.API;
using PluginConfig.API.Fields;
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: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("aquavirtualpet")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Aqua Virtual Ultra Pet")]
[assembly: AssemblyTitle("aquavirtualpet")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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 aquavirtualpet
{
	public class Aqua : MonoBehaviour
	{
		private RectTransform trans;

		private Animator ani;

		public float width = 80f;

		public float jumpMult = 1f;

		public float speedMult = 1f;

		public float gravMult = 1f;

		public float waveProbability = 20f;

		public bool willWave = true;

		public bool wallJumps = true;

		private float yVelocity;

		private float xCoeff = 1f;

		private float waveTime = 0f;

		private RectTransform canvas;

		private readonly float[] waveTimes = new float[2] { 1.35f, 1.017f };

		private void Start()
		{
			trans = ((Component)this).gameObject.GetComponent<RectTransform>();
			canvas = GameObject.Find("/Canvas").GetComponent<RectTransform>();
			ani = ((Component)this).gameObject.GetComponent<Animator>();
			Jump();
		}

		private void Jump(float min = -1f, float max = 1f, bool jumps = true, bool canWave = false)
		{
			if (waveTime > 0f)
			{
				return;
			}
			if (willWave && canWave && Random.Range(0f, 1f) > 1f - 1f / waveProbability)
			{
				int num = Random.Range(1, 3);
				ani.SetInteger("Anim", num);
				waveTime = waveTimes[num - 1] * (float)Random.Range(2, 6);
				yVelocity = 0f;
				xCoeff = 0f;
			}
			else
			{
				if (jumps)
				{
					yVelocity = width * jumpMult * Random.Range(2f, 4f);
				}
				xCoeff = Random.Range(min, max);
			}
		}

		private void Update()
		{
			//IL_0013: 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_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: 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)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_0230: Unknown result type (might be due to invalid IL or missing references)
			//IL_023a: Unknown result type (might be due to invalid IL or missing references)
			//IL_023f: Unknown result type (might be due to invalid IL or missing references)
			trans.sizeDelta = new Vector2(width, width);
			if (trans.anchoredPosition.x > canvas.sizeDelta.x / 2f - width / 2f)
			{
				trans.anchoredPosition = new Vector2(canvas.sizeDelta.x / 2f - width / 2f, trans.anchoredPosition.y);
				Jump(-1f, -0.1f, wallJumps);
			}
			if (trans.anchoredPosition.x < 0f - (canvas.sizeDelta.x / 2f - width / 2f))
			{
				trans.anchoredPosition = new Vector2(0f - (canvas.sizeDelta.x / 2f - width / 2f), trans.anchoredPosition.y);
				Jump(0.1f, 1f, wallJumps);
			}
			if (trans.anchoredPosition.y < 0f)
			{
				trans.anchoredPosition = new Vector2(trans.anchoredPosition.x, 0f);
				Jump(-1f, 1f, jumps: true, canWave: true);
			}
			if (ani.GetInteger("Anim") != 0)
			{
				waveTime -= Time.deltaTime;
				if (waveTime < 0f)
				{
					ani.SetInteger("Anim", 0);
					Jump();
				}
			}
			else
			{
				((Transform)trans).Translate(Vector2.op_Implicit(new Vector2(width * xCoeff * 2f * speedMult, yVelocity) * Time.deltaTime));
				yVelocity -= width * 8f * gravMult * Time.deltaTime;
			}
		}
	}
	[BepInPlugin("aquavirtualpet", "Aqua Virtual Ultra Pet", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static FloatValueChangeEventDelegate <>9__9_0;

			public static FloatValueChangeEventDelegate <>9__9_1;

			public static FloatValueChangeEventDelegate <>9__9_2;

			public static FloatValueChangeEventDelegate <>9__9_3;

			public static FloatValueChangeEventDelegate <>9__9_4;

			public static BoolValueChangeEventDelegate <>9__9_5;

			public static BoolValueChangeEventDelegate <>9__9_6;

			internal void <Start>b__9_0(FloatValueChangeEvent e)
			{
				if ((Object)(object)aqua != (Object)null)
				{
					aquaSettings.width = e.value;
				}
			}

			internal void <Start>b__9_1(FloatValueChangeEvent e)
			{
				if ((Object)(object)aqua != (Object)null)
				{
					aquaSettings.jumpMult = e.value;
				}
			}

			internal void <Start>b__9_2(FloatValueChangeEvent e)
			{
				if ((Object)(object)aqua != (Object)null)
				{
					aquaSettings.speedMult = e.value;
				}
			}

			internal void <Start>b__9_3(FloatValueChangeEvent e)
			{
				if ((Object)(object)aqua != (Object)null)
				{
					aquaSettings.gravMult = e.value;
				}
			}

			internal void <Start>b__9_4(FloatValueChangeEvent e)
			{
				if ((Object)(object)aqua != (Object)null)
				{
					aquaSettings.waveProbability = e.value;
				}
			}

			internal void <Start>b__9_5(BoolValueChangeEvent e)
			{
				if ((Object)(object)aqua != (Object)null)
				{
					aquaSettings.willWave = e.value;
				}
			}

			internal void <Start>b__9_6(BoolValueChangeEvent e)
			{
				if ((Object)(object)aqua != (Object)null)
				{
					aquaSettings.wallJumps = e.value;
				}
			}
		}

		internal static ManualLogSource Logger;

		public static GameObject aqua;

		public static Aqua aquaSettings;

		public Harmony harm;

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

		public static readonly AssetBundle Assets = AssetBundle.LoadFromFile(Path.Combine(directory, "aqua.bundle"));

		public static readonly Dictionary<string, Object> assetDict = new Dictionary<string, Object>();

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			Logger.LogInfo((object)"Plugin aquavirtualpet is loaded!");
			SceneManager.sceneLoaded += OnSceneLoaded;
			Object[] array = Assets.LoadAllAssets();
			Object[] array2 = array;
			foreach (Object val in array2)
			{
				Object val2 = val;
				assetDict[val2.name] = val2;
				Logger.LogInfo((object)("Loaded " + ((object)val).GetType()?.ToString() + " " + val2.name));
			}
		}

		private static void UpdateAqua()
		{
			aquaSettings.width = AQUAConfig.sizeField.value;
			aquaSettings.jumpMult = AQUAConfig.jumpField.value;
			aquaSettings.speedMult = AQUAConfig.speedField.value;
			aquaSettings.gravMult = AQUAConfig.gravField.value;
			aquaSettings.waveProbability = AQUAConfig.waveProbField.value;
			aquaSettings.willWave = AQUAConfig.waveField.value;
			aquaSettings.wallJumps = AQUAConfig.wallJumpField.value;
		}

		private void Start()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected O, but got Unknown
			//IL_004a: 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_0055: Expected O, but got Unknown
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Expected O, but got Unknown
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Expected O, but got Unknown
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Expected O, but got Unknown
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Expected O, but got Unknown
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Expected O, but got Unknown
			AQUAConfig.Init();
			FloatField sizeField = AQUAConfig.sizeField;
			object obj = <>c.<>9__9_0;
			if (obj == null)
			{
				FloatValueChangeEventDelegate val = delegate(FloatValueChangeEvent e)
				{
					if ((Object)(object)aqua != (Object)null)
					{
						aquaSettings.width = e.value;
					}
				};
				<>c.<>9__9_0 = val;
				obj = (object)val;
			}
			sizeField.onValueChange += (FloatValueChangeEventDelegate)obj;
			FloatField jumpField = AQUAConfig.jumpField;
			object obj2 = <>c.<>9__9_1;
			if (obj2 == null)
			{
				FloatValueChangeEventDelegate val2 = delegate(FloatValueChangeEvent e)
				{
					if ((Object)(object)aqua != (Object)null)
					{
						aquaSettings.jumpMult = e.value;
					}
				};
				<>c.<>9__9_1 = val2;
				obj2 = (object)val2;
			}
			jumpField.onValueChange += (FloatValueChangeEventDelegate)obj2;
			FloatField speedField = AQUAConfig.speedField;
			object obj3 = <>c.<>9__9_2;
			if (obj3 == null)
			{
				FloatValueChangeEventDelegate val3 = delegate(FloatValueChangeEvent e)
				{
					if ((Object)(object)aqua != (Object)null)
					{
						aquaSettings.speedMult = e.value;
					}
				};
				<>c.<>9__9_2 = val3;
				obj3 = (object)val3;
			}
			speedField.onValueChange += (FloatValueChangeEventDelegate)obj3;
			FloatField gravField = AQUAConfig.gravField;
			object obj4 = <>c.<>9__9_3;
			if (obj4 == null)
			{
				FloatValueChangeEventDelegate val4 = delegate(FloatValueChangeEvent e)
				{
					if ((Object)(object)aqua != (Object)null)
					{
						aquaSettings.gravMult = e.value;
					}
				};
				<>c.<>9__9_3 = val4;
				obj4 = (object)val4;
			}
			gravField.onValueChange += (FloatValueChangeEventDelegate)obj4;
			FloatField waveProbField = AQUAConfig.waveProbField;
			object obj5 = <>c.<>9__9_4;
			if (obj5 == null)
			{
				FloatValueChangeEventDelegate val5 = delegate(FloatValueChangeEvent e)
				{
					if ((Object)(object)aqua != (Object)null)
					{
						aquaSettings.waveProbability = e.value;
					}
				};
				<>c.<>9__9_4 = val5;
				obj5 = (object)val5;
			}
			waveProbField.onValueChange += (FloatValueChangeEventDelegate)obj5;
			BoolField waveField = AQUAConfig.waveField;
			object obj6 = <>c.<>9__9_5;
			if (obj6 == null)
			{
				BoolValueChangeEventDelegate val6 = delegate(BoolValueChangeEvent e)
				{
					if ((Object)(object)aqua != (Object)null)
					{
						aquaSettings.willWave = e.value;
					}
				};
				<>c.<>9__9_5 = val6;
				obj6 = (object)val6;
			}
			waveField.onValueChange += (BoolValueChangeEventDelegate)obj6;
			BoolField wallJumpField = AQUAConfig.wallJumpField;
			object obj7 = <>c.<>9__9_6;
			if (obj7 == null)
			{
				BoolValueChangeEventDelegate val7 = delegate(BoolValueChangeEvent e)
				{
					if ((Object)(object)aqua != (Object)null)
					{
						aquaSettings.wallJumps = e.value;
					}
				};
				<>c.<>9__9_6 = val7;
				obj7 = (object)val7;
			}
			wallJumpField.onValueChange += (BoolValueChangeEventDelegate)obj7;
		}

		private static void OnSceneLoaded(Scene scene, LoadSceneMode mode)
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Expected O, but got Unknown
			aqua = null;
			aquaSettings = null;
			GameObject val = GameObject.Find("/Canvas");
			if ((Object)(object)val != (Object)null)
			{
				aqua = Object.Instantiate<GameObject>((GameObject)assetDict["Aqua"], val.transform);
				aquaSettings = ((Component)aqua.transform.GetChild(0)).gameObject.AddComponent<Aqua>();
				UpdateAqua();
			}
		}
	}
	public static class AQUAConfig
	{
		private static PluginConfigurator config;

		public static FloatField sizeField;

		public static FloatField jumpField;

		public static FloatField speedField;

		public static FloatField gravField;

		public static FloatField waveProbField;

		public static BoolField waveField;

		public static BoolField wallJumpField;

		public static Dictionary<string, StringField[]> weaponPairs = new Dictionary<string, StringField[]>();

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

		public static void Init()
		{
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Expected O, but got Unknown
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Expected O, but got Unknown
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Expected O, but got Unknown
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Expected O, but got Unknown
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Expected O, but got Unknown
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Expected O, but got Unknown
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Expected O, but got Unknown
			config = PluginConfigurator.Create("Aqua Virtual Ultra Pet", "aquavirtualpet");
			config.SetIconWithURL("file://" + Path.Combine(directory, "icon.png"));
			sizeField = new FloatField(config.rootPanel, "Aqua Size", "size", 80f, 1f, 500f);
			jumpField = new FloatField(config.rootPanel, "Jump Power", "jump", 1f, 0.1f, 10f);
			speedField = new FloatField(config.rootPanel, "Speed", "spd", 1f, 0.1f, 10f);
			gravField = new FloatField(config.rootPanel, "Gravity", "grav", 1f, 0.1f, 10f);
			waveField = new BoolField(config.rootPanel, "Waves", "wv", true);
			waveProbField = new FloatField(config.rootPanel, "Wave Probability (1 in", "wvp", 20f, 1f, 100f);
			wallJumpField = new BoolField(config.rootPanel, "Wall Jumps", "wll", true);
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "aquavirtualpet";

		public const string PLUGIN_NAME = "Aqua Virtual Ultra Pet";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}