Decompiled source of Movement Company Fixed v1.0.2

BepInEx/plugins/MCFixed.dll

Decompiled a year ago
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.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using MCFixed.Component;
using Unity.Netcode;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyCompany("MCFixed")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Source moment")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.2")]
[assembly: AssemblyProduct("MCFixed")]
[assembly: AssemblyTitle("MCFixed")]
[assembly: TargetFramework(".NETFramework,Version=v4.6.1", FrameworkDisplayName = ".NET Framework 4.6.1")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace MCFixed
{
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "MCFixed";

		public const string PLUGIN_NAME = "MCFixed";

		public const string PLUGIN_VERSION = "1.0.0";
	}
	[BepInPlugin("MCFixed", "MCFixed", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		private Harmony _harmony = new Harmony("MCFixed");

		public static ManualLogSource Log;

		public void Awake()
		{
			Log = ((BaseUnityPlugin)this).Logger;
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin MCFixed is loaded!");
			_harmony.PatchAll();
		}

		public void Update()
		{
			PlayerControllerB[] array = Object.FindObjectsOfType<PlayerControllerB>();
			PlayerControllerB[] array2 = array;
			foreach (PlayerControllerB val in array2)
			{
				if ((Object)(object)val != (Object)null && (Object)(object)((Component)val).gameObject.GetComponentInChildren<MovementScript>() == (Object)null && ((NetworkBehaviour)val).IsOwner && val.isPlayerControlled)
				{
					((Component)val).gameObject.AddComponent<MovementScript>().myPlayer = val;
					Log.LogMessage((object)"Gave player the movement script");
				}
			}
		}

		public void OnDestroy()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			((BaseUnityPlugin)this).Logger.LogInfo((object)"MCFixed activating...");
			GameObject val = new GameObject("MovementAdder");
			Object.DontDestroyOnLoad((Object)(object)val);
			val.AddComponent<MovementAdder>();
		}
	}
}
namespace MCFixed.Component
{
	internal class MovementAdder : MonoBehaviour
	{
		private void Awake()
		{
			Plugin.Log.LogMessage((object)"Added MovementAdder");
		}

		private void OnDestroy()
		{
			Plugin.Log.LogMessage((object)"Destroyed! Oops!");
		}

		private void Update()
		{
			PlayerControllerB[] array = Object.FindObjectsOfType<PlayerControllerB>();
			PlayerControllerB[] array2 = array;
			foreach (PlayerControllerB val in array2)
			{
				if ((Object)(object)val != (Object)null && (Object)(object)((Component)val).gameObject.GetComponentInChildren<MovementScript>() == (Object)null && ((NetworkBehaviour)val).IsOwner && val.isPlayerControlled)
				{
					((Component)val).gameObject.AddComponent<MovementScript>().myPlayer = val;
					Plugin.Log.LogMessage((object)"Gave player the movement script");
				}
			}
		}
	}
	internal class MovementScript : MonoBehaviour
	{
		public PlayerControllerB myPlayer;

		private bool inAir;

		public static Vector3 wantedVelToAdd;

		public float jumpTime;

		private Vector3 previousForward;

		public void Update()
		{
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: 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_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: 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_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: 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_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			if (myPlayer.playerBodyAnimator.GetBool("Jumping") && jumpTime < 0.1f)
			{
				myPlayer.fallValue = myPlayer.jumpForce;
				jumpTime += Time.deltaTime * 10f;
			}
			myPlayer.sprintMeter = 100f;
			if (!myPlayer.thisController.isGrounded && !myPlayer.isClimbingLadder)
			{
				if (!inAir)
				{
					inAir = true;
					Vector3 velocity = myPlayer.thisController.velocity;
					velocity.y = 0f;
					wantedVelToAdd += 0.006f * velocity;
				}
				wantedVelToAdd.y = 0f;
				myPlayer.thisController.Move(((Component)myPlayer).gameObject.transform.forward * ((Vector3)(ref wantedVelToAdd)).magnitude);
				Vector3 forward = ((Component)myPlayer).gameObject.transform.forward;
				Vector3 val = forward - previousForward;
				float num = 0.01f;
				if (((Vector3)(ref val)).magnitude > num)
				{
					wantedVelToAdd += new Vector3(0.0005f, 0.0005f, 0.0005f);
				}
				previousForward = forward;
			}
			else
			{
				wantedVelToAdd = Vector3.Lerp(wantedVelToAdd, Vector3.zero, Time.deltaTime * 4.2f);
				inAir = false;
				jumpTime = 0f;
			}
			_ = myPlayer.thisController.isGrounded;
		}
	}
}