Decompiled source of GravityController v1.0.1

gravmod.dll

Decompiled 6 days ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using Configgy;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("gravmod")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("My first plugin")]
[assembly: AssemblyTitle("gravmod")]
[assembly: AssemblyVersion("1.0.0.0")]
[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 gravmod
{
	[BepInPlugin("lakeull.modding.gravitynmod", "Gravity Controller", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		private static bool gravityReset = false;

		private ConfigBuilder config;

		[Configgable("", "Mod Enabled", 0, "")]
		public static bool modEnabled = true;

		[Configgable("", "X Direction", 2, "The direction of the gravity. 0 will not affect the player, but setting it to 1 will send the player left. Default: 0")]
		public static float xDir = 0f;

		[Configgable("", "Y Direction", 3, "The direction of the gravity. 0 will not affect the player, but setting it to 1 will send the player down. Default: 1")]
		public static float yDir = 1f;

		[Configgable("", "Z Direction", 4, "The direction of the gravity. 0 will not affect the player, but setting it to 1 will send the player backwards. Default: 0")]
		public static float zDir = 0f;

		[Configgable("", "X Multiplier", 6, "How much to multiply the gravity in the x axis by. Default: 1")]
		public static float xMult = 1f;

		[Configgable("", "Y Multiplier", 7, "How much to multiply the gravity in the y axis by. Default: 1")]
		public static float yMult = 1f;

		[Configgable("", "Z Multiplier", 8, "How much to multiply the gravity in the z axis by. Default: 1")]
		public static float zMult = 1f;

		[Configgable("", "Debug Info", 10, "")]
		private static bool debugMode = false;

		internal static ManualLogSource Logger { get; private set; } = null;


		private void Awake()
		{
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			Logger = ((BaseUnityPlugin)this).Logger;
			Logger.LogInfo((object)"Plugin lakeull.modding.gravitynmod is loaded!");
			((Object)((Component)this).gameObject).hideFlags = (HideFlags)4;
			SceneManager.sceneLoaded += OnSceneLoaded;
			config = new ConfigBuilder("Lakeull.GravChanger", "GravChanger");
			config.BuildAll();
		}

		public void OnSceneLoaded(Scene scene, LoadSceneMode lsm)
		{
			((MonoBehaviour)this).InvokeRepeating("ReAssignGravity", 1f, 0.1f);
		}

		public void ReAssignGravity()
		{
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_020d: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Unknown result type (might be due to invalid IL or missing references)
			if (SceneHelper.CurrentScene == "Main Menu" || SceneHelper.CurrentScene == "Intro")
			{
				return;
			}
			if ((Object)(object)MonoSingleton<NewMovement>.Instance == (Object)null)
			{
				Logger.LogError((object)"newmovement is null");
				return;
			}
			if ((Object)(object)MonoSingleton<CameraController>.Instance == (Object)null)
			{
				Logger.LogError((object)"camera controller fucked");
			}
			if ((Object)(object)GameStateManager.Instance == (Object)null)
			{
				Logger.LogError((object)"game state manager fucked");
			}
			else if (GameStateManager.Instance.IsStateActive("pit-falling") || !MonoSingleton<NewMovement>.Instance.activated)
			{
				MonoSingleton<NewMovement>.Instance.ResetGravity(true);
			}
			else if (!modEnabled && !gravityReset)
			{
				MonoSingleton<NewMovement>.Instance.ResetGravity(true);
				gravityReset = true;
			}
			else
			{
				if (!modEnabled)
				{
					return;
				}
				if (xDir == 0f && yDir == 0f && zDir == 0f)
				{
					Logger.LogError((object)"Error: directions cannot all equal 0! if you want 0 gravity use the multipliers instead.");
					return;
				}
				Vector3 val = default(Vector3);
				((Vector3)(ref val))..ctor(xDir, yDir, zDir);
				Vector3 val2 = Vector3.Normalize(val);
				Vector3 val3 = default(Vector3);
				((Vector3)(ref val3))..ctor(val2.x * (40f * xMult), val2.y * (-40f * yMult), val2.z * (40f * zMult));
				MonoSingleton<NewMovement>.Instance.SwitchGravity(val3, false, false);
				gravityReset = false;
				if (debugMode)
				{
					ManualLogSource logger = Logger;
					Vector3 val4 = val;
					logger.LogInfo((object)("vector: " + ((object)(Vector3)(ref val4)).ToString()));
					ManualLogSource logger2 = Logger;
					val4 = val3;
					logger2.LogInfo((object)("final calculated vector: " + ((object)(Vector3)(ref val4)).ToString()));
					Logger.LogInfo((object)("gravity has been reset: " + gravityReset));
					Logger.LogInfo((object)("scene: " + SceneHelper.CurrentScene));
				}
			}
		}
	}
	internal static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "lakeull.modding.gravitynmod";

		public const string PLUGIN_NAME = "My first plugin";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}