Decompiled source of SeriouslyBouncy v1.0.0

plugins/SeriouslyBouncy.dll

Decompiled 10 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 BepInEx.Configuration;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using SeriouslyBouncy;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyCompany("SeriouslyBouncy")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription(":D")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("SeriouslyBouncy")]
[assembly: AssemblyTitle("SeriouslyBouncy")]
[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;
		}
	}
}
public class BouncyCannonballPatch
{
	public static PhysicMaterial Bouncy = new PhysicMaterial("Bouncy")
	{
		bounciness = 1f,
		dynamicFriction = 0f,
		staticFriction = 0f,
		frictionCombine = (PhysicMaterialCombine)2,
		bounceCombine = (PhysicMaterialCombine)3
	};

	public static float Duration = 5f;

	[HarmonyPatch(typeof(Cannonball), "Start")]
	[HarmonyPrefix]
	public static void Start(Cannonball __instance)
	{
		((Component)__instance).gameObject.AddComponent<BouncyCannonball>().Rb = ((Component)__instance).GetComponent<Rigidbody>();
	}

	[HarmonyPatch(typeof(Cannonball), "Break")]
	[HarmonyPrefix]
	public static bool Break(Cannonball __instance)
	{
		if (Plugin.Enabled)
		{
			return ((Component)__instance).GetComponent<BouncyCannonball>().RemainingTime <= 0f;
		}
		return true;
	}
}
public class BouncyCannonball : MonoBehaviour
{
	public float RemainingTime = 5f;

	public Rigidbody Rb;

	private SphereCollider _sc;

	private bool _hurtPlayer;

	public void Update()
	{
		RemainingTime -= Time.deltaTime;
		if (RemainingTime <= 0f)
		{
			((Collider)_sc).material = null;
		}
	}

	private void Start()
	{
		_sc = ((Component)this).gameObject.AddComponent<SphereCollider>();
		_sc.radius = 0.8f;
		((Collider)_sc).material = BouncyCannonballPatch.Bouncy;
		RemainingTime = BouncyCannonballPatch.Duration;
	}

	private void OnTriggerEnter(Collider other)
	{
	}
}
namespace SeriouslyBouncy
{
	[BepInPlugin("com.zeddevstuff.seriouslybouncy", "Seriously Bouncy", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		public static ConfigEntry<float> bounciness;

		public static ConfigEntry<float> duration;

		public static ConfigEntry<bool> enabled;

		public static bool Enabled = true;

		private void Awake()
		{
			enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "Enabled", true, "Whether the bouncy cannonballs are enabled.");
			Enabled = enabled.Value;
			enabled.SettingChanged += delegate
			{
				Enabled = enabled.Value;
			};
			bounciness = ((BaseUnityPlugin)this).Config.Bind<float>("Settings", "Bounciness", 1f, "How bouncy the cannonballs are. 1 is very bouncy, 0 is not bouncy at all.");
			BouncyCannonballPatch.Bouncy.bounciness = bounciness.Value;
			bounciness.SettingChanged += delegate
			{
				BouncyCannonballPatch.Bouncy.bounciness = bounciness.Value;
			};
			duration = ((BaseUnityPlugin)this).Config.Bind<float>("Settings", "Duration", 5f, "How long the cannonball can bounce for in seconds.");
			BouncyCannonballPatch.Duration = duration.Value;
			duration.SettingChanged += delegate
			{
				BouncyCannonballPatch.Duration = duration.Value;
			};
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin SeriouslyBouncy is loaded!");
			Harmony.CreateAndPatchAll(typeof(BouncyCannonballPatch), "SeriouslyBouncy");
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "SeriouslyBouncy";

		public const string PLUGIN_NAME = "SeriouslyBouncy";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}