Decompiled source of AcidTrip v1.0.0

AcidTrip.dll

Decompiled 2 months ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BoplFixedMath;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[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", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("AcidTrip")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("My first plugin")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("AcidTrip")]
[assembly: AssemblyTitle("AcidTrip")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.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 AcidTrip
{
	[BepInPlugin("AcidTrip", "AcidTrip", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		internal static Random random = new Random();

		internal static int localPlayerId = 1;

		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)"Plugin AcidTrip is loaded!");
			Harmony val = new Harmony("AcidTrip");
			val.PatchAll(typeof(Patches));
		}
	}
	public class Patches
	{
		[HarmonyPatch(typeof(Player), "HorizontalAxis")]
		[HarmonyPostfix]
		public static void HorizPostfix(Player __instance, ref Fix __result)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			MonoBehaviour.print((object)"Patched!");
			__result = -__instance.Inputs.InputVector.x;
		}

		[HarmonyPatch(typeof(Player), "VerticalAxis")]
		[HarmonyPostfix]
		public static void VertPostfix(Player __instance, ref Fix __result)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			if (__instance.IsLocalPlayer)
			{
				MonoBehaviour.print((object)"Patched!");
				__result = -__instance.Inputs.InputVector.y;
			}
		}

		[HarmonyPatch(typeof(Player), "InputVector")]
		[HarmonyPostfix]
		public static void Vec2Postfix(Player __instance, ref Vec2 __result)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: 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_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			if (__instance.IsLocalPlayer)
			{
				Vec2 val = default(Vec2);
				((Vec2)(ref val))..ctor(-__instance.Inputs.InputVector.x, -__instance.Inputs.InputVector.y);
				MonoBehaviour.print((object)"Patched!");
				__result = val;
			}
		}

		[HarmonyPatch(typeof(Player), "AbilityButtonIsDown")]
		[HarmonyPrefix]
		public static void AbilityPrefix(ref int __0, Player __instance)
		{
			if (__instance.IsLocalPlayer)
			{
				if (__0 == 0)
				{
					__0 = 2;
				}
				else if (__0 == 2)
				{
					__0 = 0;
				}
			}
		}

		[HarmonyPatch(typeof(PlayerBody), "UpdateSim")]
		[HarmonyPostfix]
		public static void ColorPatch(ref IPlayerIdHolder ___idHolder)
		{
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			if (Plugin.random.Next(11) < 5)
			{
				return;
			}
			SlimeController[] slimeControllers = GetSlimeControllers();
			foreach (SlimeController val in slimeControllers)
			{
				if (val.GetPlayerId() == Plugin.localPlayerId && (Object)(object)val != (Object)null)
				{
					Color color = ((Renderer)val.GetPlayerSprite()).material.GetColor("_ShadowColor");
					((Renderer)val.GetPlayerSprite()).material.SetColor("_ShadowColor", new Color(0f - color.r + 1f, 0f - color.g + 1f, 0f - color.b + 1f));
				}
			}
		}

		[HarmonyPatch(typeof(Player), "UpdateFRAMEDependentInputs")]
		[HarmonyPrefix]
		public static void PlayerPatch(Player __instance)
		{
			if (__instance.IsLocalPlayer)
			{
				Plugin.localPlayerId = __instance.Id;
			}
		}

		public static GameSessionHandler GetGameSessionHandler()
		{
			FieldInfo field = typeof(GameSessionHandler).GetField("selfRef", BindingFlags.Static | BindingFlags.NonPublic);
			object? value = field.GetValue(null);
			return (GameSessionHandler)((value is GameSessionHandler) ? value : null);
		}

		public static SlimeController[] GetSlimeControllers()
		{
			FieldInfo field = typeof(GameSessionHandler).GetField("slimeControllers", BindingFlags.Instance | BindingFlags.NonPublic);
			return field.GetValue(GetGameSessionHandler()) as SlimeController[];
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "AcidTrip";

		public const string PLUGIN_NAME = "AcidTrip";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}