Decompiled source of LethalPhysics v0.2.0

LethalPhysics.dll

Decompiled 13 hours ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LethalPhysics.Patches;
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("LethalPhysics")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("LethalPhysics")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("94f05109-45d5-4285-857d-e26079d71719")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace LethalPhysics
{
	[BepInPlugin("jacobot5.LethalPhysics", "LethalPhysics", "0.2.0")]
	public class LethalPhysicsMod : BaseUnityPlugin
	{
		private const string modGUID = "jacobot5.LethalPhysics";

		private const string modName = "LethalPhysics";

		private const string modVersion = "0.2.0";

		public static ConfigEntry<bool> configGravityOnMoons;

		private readonly Harmony harmony = new Harmony("jacobot5.LethalPhysics");

		private static LethalPhysicsMod Instance;

		internal ManualLogSource mls;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			mls = Logger.CreateLogSource("jacobot5.LethalPhysics");
			mls.LogInfo((object)"LethalPhysics has awoken.");
			configGravityOnMoons = ((BaseUnityPlugin)this).Config.Bind<bool>("General.Toggles", "GravityOnMoons", true, "Whether or not to enable gravity on moons");
			harmony.PatchAll(typeof(LethalPhysicsMod));
			harmony.PatchAll(typeof(PlayerControllerBPatch));
			harmony.PatchAll(typeof(GrabbableObjectPatch));
		}
	}
}
namespace LethalPhysics.Patches
{
	[HarmonyPatch(typeof(GrabbableObject))]
	internal class GrabbableObjectPatch
	{
		[HarmonyPatch("FallWithCurve")]
		[HarmonyPrefix]
		private static bool ItemZeroGravityPatch()
		{
			StartOfRound instance = StartOfRound.Instance;
			if ((instance != null && instance.inShipPhase) || !LethalPhysicsMod.configGravityOnMoons.Value)
			{
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal class PlayerControllerBPatch
	{
		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void PlayerZeroGravityPatch(PlayerControllerB __instance)
		{
			StartOfRound instance = StartOfRound.Instance;
			if ((instance != null && instance.inShipPhase) || !LethalPhysicsMod.configGravityOnMoons.Value)
			{
				__instance.fallValue = -0.1f;
				__instance.takingFallDamage = false;
			}
		}
	}
}