Decompiled source of BananaWaffle v1.0.0

plugins/com.chouja.BananaWaffle.dll

Decompiled 2 days 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 BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("com.chouja.BananaWaffle")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("com.chouja.BananaWaffle")]
[assembly: AssemblyTitle("BananaWaffle")]
[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.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;
		}
	}
	[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 BepInEx
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class BepInAutoPluginAttribute : Attribute
	{
		public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace BepInEx.Preloader.Core.Patching
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class PatcherAutoPluginAttribute : Attribute
	{
		public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace BananaWaffle
{
	[BepInPlugin("com.chouja.BananaWaffle", "BananaWaffle", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(BananaPeel), "Update")]
		private static class BananaPeelUpdatePatch
		{
			private static bool Prefix(BananaPeel __instance)
			{
				//IL_0006: 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_0042: Unknown result type (might be due to invalid IL or missing references)
				if ((int)__instance.item.itemState == 0)
				{
					__instance.counter += Time.deltaTime;
					if (!(__instance.counter < 3f) && !(Vector3.Distance(Character.localCharacter.Center, ((Component)__instance).transform.position) > 1f * rangeMultiplier.Value) && Character.localCharacter.data.isGrounded && !(((Vector3)(ref Character.localCharacter.data.avarageVelocity)).magnitude < 1.5f))
					{
						__instance.counter = 0f;
						((Component)__instance).GetComponent<PhotonView>().RPC("RPCA_TriggerBanana", (RpcTarget)0, new object[1] { Character.localCharacter.refs.view.ViewID });
					}
				}
				return false;
			}
		}

		[HarmonyPatch(typeof(BananaPeel), "RPCA_TriggerBanana")]
		private static class BananaPeelTriggerBananaPatch
		{
			private static bool Prefix(int viewID, BananaPeel __instance)
			{
				//IL_0024: Unknown result type (might be due to invalid IL or missing references)
				//IL_002e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0033: Unknown result type (might be due to invalid IL or missing references)
				//IL_0038: Unknown result type (might be due to invalid IL or missing references)
				//IL_0042: Unknown result type (might be due to invalid IL or missing references)
				//IL_0082: 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_008c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0096: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
				//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c1: 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_00da: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
				//IL_0112: Unknown result type (might be due to invalid IL or missing references)
				//IL_011c: Unknown result type (might be due to invalid IL or missing references)
				//IL_012b: Unknown result type (might be due to invalid IL or missing references)
				//IL_014a: Unknown result type (might be due to invalid IL or missing references)
				Character component = ((Component)PhotonView.Find(viewID)).GetComponent<Character>();
				if (!((Object)(object)component == (Object)null))
				{
					((Component)__instance).GetComponent<Rigidbody>().AddForce((component.data.lookDirection_Flat * 0.5f + Vector3.up) * 40f, (ForceMode)1);
					Rigidbody bodypartRig = component.GetBodypartRig((BodypartType)16);
					Rigidbody bodypartRig2 = component.GetBodypartRig((BodypartType)13);
					Rigidbody bodypartRig3 = component.GetBodypartRig((BodypartType)0);
					Rigidbody bodypartRig4 = component.GetBodypartRig((BodypartType)4);
					component.RPCA_Fall(2f);
					bodypartRig.AddForce((component.data.lookDirection_Flat + Vector3.up) * 200f * slipMultiplier.Value, (ForceMode)1);
					bodypartRig2.AddForce((component.data.lookDirection_Flat + Vector3.up) * 200f * slipMultiplier.Value, (ForceMode)1);
					bodypartRig3.AddForce(Vector3.up * 1500f * slipMultiplier.Value, (ForceMode)1);
					bodypartRig4.AddForce(component.data.lookDirection_Flat * -300f * slipMultiplier.Value, (ForceMode)1);
					for (int i = 0; i < __instance.slipSFX.Length; i++)
					{
						__instance.slipSFX[i].Play(((Component)__instance).transform.position);
					}
				}
				return false;
			}
		}

		private static ConfigEntry<float> slipMultiplier;

		private static ConfigEntry<float> rangeMultiplier;

		public const string Id = "com.chouja.BananaWaffle";

		internal static ManualLogSource Log { get; private set; }

		public static string Name => "BananaWaffle";

		public static string Version => "1.0.0";

		private void Awake()
		{
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			slipMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("General", "SlipMultiplier", 1f, "Banana peel slip force multiplier");
			rangeMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("General", "RangeMultiplier", 1f, "Banana peel slip range multiplier");
			try
			{
				Harmony val = new Harmony("com.chouja.BananaWaffle");
				val.PatchAll();
				Log.LogInfo((object)("Plugin " + Name + " is loaded!"));
			}
			catch (Exception ex)
			{
				Log.LogError((object)("Failed to apply Harmony patches: " + ex.Message));
			}
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}