Decompiled source of Movement Company v1.0.2

BepInEx/plugins/MovementCompany.dll

Decompiled 6 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.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LC_API.ServerAPI;
using Microsoft.CodeAnalysis;
using MovementCompany.Component;
using Unity.Netcode;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.6", FrameworkDisplayName = ".NET Framework 4.6")]
[assembly: AssemblyCompany("MovementCompany")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Source moment")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("MovementCompany")]
[assembly: AssemblyTitle("MovementCompany")]
[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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace MovementCompany
{
	[BepInPlugin("MovementCompany", "MovementCompany", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		private Harmony _harmony = new Harmony("MovementCompany");

		public static ManualLogSource Log;

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

		public void OnDestroy()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			GameObject val = new GameObject("MovementAdder");
			Object.DontDestroyOnLoad((Object)val);
			val.AddComponent<MovementAdder>();
			ModdedServer.SetServerModdedOnly();
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "MovementCompany";

		public const string PLUGIN_NAME = "MovementCompany";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace MovementCompany.Component
{
	internal class MovementAdder : MonoBehaviour
	{
		public void Update()
		{
			PlayerControllerB[] array = Object.FindObjectsOfType<PlayerControllerB>();
			foreach (PlayerControllerB val in array)
			{
				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_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: 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_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: 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_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: 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_0169: 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_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: 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;
		}
	}
}