Decompiled source of SuperBanana v0.0.1

SuperBanana.dll

Decompiled 2 months ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using Photon.Pun;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("WeLovebananas")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("WeLovebananas")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("9f0485f4-0bda-4c12-a712-b02ab84ee9be")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace WeLovebananas;

[BepInPlugin("com.WeLovebananas.mod", "My Mod", "1.0.0")]
public class MyMod : BaseUnityPlugin
{
	public static float currentValue = 2.5f;

	public void Start()
	{
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Expected O, but got Unknown
		//IL_004f: Unknown result type (might be due to invalid IL or missing references)
		//IL_005d: Expected O, but got Unknown
		((BaseUnityPlugin)this).Logger.LogInfo((object)"第一步开始");
		Harmony val = new Harmony("com.WeLovebananas.mod");
		val.PatchAll();
		val.Patch((MethodBase)AccessTools.Method(typeof(BananaPeel), "Update", (Type[])null, (Type[])null), new HarmonyMethod(typeof(MyMod).GetMethod("CustomUpdate")), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
	}

	public static bool CustomUpdate(BananaPeel __instance)
	{
		//IL_008d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0093: Invalid comparison between Unknown and I4
		//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00df: Unknown result type (might be due to invalid IL or missing references)
		Item component = ((Component)__instance).GetComponent<Item>();
		BananaPeel component2 = ((Component)__instance).GetComponent<BananaPeel>();
		if ((Object)(object)component2 == (Object)null)
		{
			Debug.LogError((object)"未找到 BananaPeel 类!");
			return false;
		}
		FieldInfo field = ((object)component2).GetType().GetField("counter", BindingFlags.Instance | BindingFlags.NonPublic);
		if (field == null)
		{
			Debug.LogError((object)"未找到名为 'counter' 的字段!");
			return false;
		}
		Component component3 = ((Component)__instance).GetComponent<Component>();
		if ((Object)(object)component3 == (Object)null)
		{
			Debug.LogError((object)"未找到 Component 类!");
			return false;
		}
		if ((int)component.itemState > 0)
		{
			return false;
		}
		currentValue += Time.deltaTime;
		if (currentValue < 3f)
		{
			return false;
		}
		if (Vector3.Distance(Character.localCharacter.Center, component3.transform.position) > 2f || !Character.localCharacter.data.isGrounded)
		{
			return false;
		}
		if (((Vector3)(ref Character.localCharacter.data.avarageVelocity)).magnitude < 1.5f)
		{
			return false;
		}
		currentValue = 0f;
		component3.GetComponent<PhotonView>().RPC("RPCA_TriggerBanana", (RpcTarget)0, new object[1] { Character.localCharacter.refs.view.ViewID });
		return false;
	}
}
[BepInPlugin("com.WeLovebananas2.mod", "My Mod2", "1.0.0")]
internal class MyMod2 : BaseUnityPlugin
{
	public void Start()
	{
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Expected O, but got Unknown
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		//IL_0056: Expected O, but got Unknown
		((BaseUnityPlugin)this).Logger.LogInfo((object)"第二步开始");
		Harmony val = new Harmony("com.WeLovebananas2.mod");
		val.Patch((MethodBase)AccessTools.Method(typeof(BananaPeel), "RPCA_TriggerBanana", (Type[])null, (Type[])null), new HarmonyMethod(typeof(MyMod2).GetMethod("MyOverrideMethod")), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
	}

	public static bool MyOverrideMethod(int viewID, BananaPeel __instance)
	{
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_004b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		//IL_0055: 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_00d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dd: Expected O, but got Unknown
		//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ef: 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_0119: Expected O, but got Unknown
		//IL_0121: 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_014d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0154: Expected O, but got Unknown
		//IL_0156: Unknown result type (might be due to invalid IL or missing references)
		//IL_0160: Unknown result type (might be due to invalid IL or missing references)
		//IL_0182: Unknown result type (might be due to invalid IL or missing references)
		//IL_0189: Expected O, but got Unknown
		//IL_0191: Unknown result type (might be due to invalid IL or missing references)
		//IL_019b: Unknown result type (might be due to invalid IL or missing references)
		Component component = ((Component)__instance).GetComponent<Component>();
		Character component2 = ((Component)PhotonView.Find(viewID)).GetComponent<Character>();
		if ((Object)(object)component2 == (Object)null)
		{
			Debug.LogError((object)"RPC未找到 component !");
			return false;
		}
		component.GetComponent<Rigidbody>().AddForce((component2.data.lookDirection_Flat * 0.5f + Vector3.up) * 40f, (ForceMode)1);
		AccessTools.Method(typeof(Character), "GetBodypartRig", new Type[1] { typeof(BodypartType) }, (Type[])null);
		Type typeFromHandle = typeof(Character);
		MethodInfo methodInfo = AccessTools.Method(typeFromHandle, "GetBodypartRig", new Type[1] { typeof(BodypartType) }, (Type[])null);
		Rigidbody val = (Rigidbody)methodInfo.Invoke(component2, new object[1] { (object)(BodypartType)16 });
		val.AddForce(component2.data.lookDirection_Flat * 600f, (ForceMode)1);
		Rigidbody val2 = (Rigidbody)methodInfo.Invoke(component2, new object[1] { (object)(BodypartType)13 });
		val2.AddForce(component2.data.lookDirection_Flat * 600f, (ForceMode)1);
		Rigidbody val3 = (Rigidbody)methodInfo.Invoke(component2, new object[1] { (object)(BodypartType)0 });
		val3.AddForce(Vector3.up * 3150f, (ForceMode)1);
		Rigidbody val4 = (Rigidbody)methodInfo.Invoke(component2, new object[1] { (object)(BodypartType)4 });
		val4.AddForce(component2.data.lookDirection_Flat * -900f, (ForceMode)1);
		return true;
	}
}