Decompiled source of BetterTrampoline v1.0.2

plugins\BetterTrampoline.dll

Decompiled 5 hours 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 HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.1", FrameworkDisplayName = ".NET Framework 4.7.1")]
[assembly: AssemblyCompany("BetterTrampoline")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Jump higher with every bounce on the trampoline!")]
[assembly: AssemblyFileVersion("1.0.2.0")]
[assembly: AssemblyInformationalVersion("1.0.2")]
[assembly: AssemblyProduct("BetterTrampoline")]
[assembly: AssemblyTitle("BetterTrampoline")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.2.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 BetterTrampoline
{
	[BepInPlugin("AST_Studios.BetterTrampoline", "Better Trampoline", "1.0.2")]
	public class BetterTrampolinePlugin : BaseUnityPlugin
	{
		public static ConfigEntry<float> BonusVelocityPerBounce;

		public static ConfigEntry<int> MaxBounces;

		public static ConfigEntry<float> ResetTime;

		private void Awake()
		{
			BonusVelocityPerBounce = ((BaseUnityPlugin)this).Config.Bind<float>("General", "BonusVelocityPerBounce", 5f, "How much extra upward velocity is added per consecutive bounce.");
			MaxBounces = ((BaseUnityPlugin)this).Config.Bind<int>("General", "MaxBounces", 5, "Maximum number of consecutive bounces that increase height.");
			ResetTime = ((BaseUnityPlugin)this).Config.Bind<float>("General", "ResetTime", 1.5f, "Time in seconds before the bounce combo resets if you haven't touched a trampoline.");
			Harmony.CreateAndPatchAll(typeof(TrampolinePatch), (string)null);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Better Trampoline loaded! Time to bounce higher!");
		}
	}
	public class TrampolineBouncer : MonoBehaviour
	{
		public int bounceCount;

		public float lastBounceTime;

		private void Update()
		{
			if (bounceCount > 0 && Time.time - lastBounceTime > BetterTrampolinePlugin.ResetTime.Value)
			{
				bounceCount = 0;
			}
		}
	}
	[HarmonyPatch(typeof(Trampoline), "OnCollisionEnter")]
	public static class TrampolinePatch
	{
		private static void Postfix(Trampoline __instance, Collision collision)
		{
			//IL_008c: 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_009f: 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)
			if (collision == null || (Object)(object)collision.rigidbody == (Object)null)
			{
				return;
			}
			PlayerController component = collision.gameObject.GetComponent<PlayerController>();
			if (!((Object)(object)component == (Object)null))
			{
				TrampolineBouncer trampolineBouncer = collision.gameObject.GetComponent<TrampolineBouncer>();
				if ((Object)(object)trampolineBouncer == (Object)null)
				{
					trampolineBouncer = collision.gameObject.AddComponent<TrampolineBouncer>();
				}
				trampolineBouncer.bounceCount++;
				trampolineBouncer.lastBounceTime = Time.time;
				int num = Math.Min(trampolineBouncer.bounceCount, BetterTrampolinePlugin.MaxBounces.Value);
				float num2 = BetterTrampolinePlugin.BonusVelocityPerBounce.Value * (float)num;
				Vector3 velocity = collision.rigidbody.velocity;
				collision.rigidbody.AddForce(((Component)__instance).transform.up * num2, (ForceMode)2);
			}
		}
	}
}