Decompiled source of Fortnitemod v1.2.3

BepInEx/plugins/GravityCar.dll

Decompiled 3 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 BepInEx.Logging;
using CarStuff.BindingInfo;
using GameNetcodeStuff;
using HarmonyLib;
using LethalCompanyInputUtils.Api;
using LethalCompanyInputUtils.BindingPathEnums;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.InputSystem;

[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("GravityCar")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Project5")]
[assembly: AssemblyTitle("GravityCar")]
[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;
		}
	}
}
namespace Project5
{
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "GravityCar";

		public const string PLUGIN_NAME = "Project5";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace CarStuff
{
	public sealed class Config
	{
		private static Config instance;

		public ConfigEntry<bool> Enabled { get; set; }

		public ConfigEntry<bool> ManualSelect { get; set; }

		public ConfigEntry<bool> WasConfigFixed { get; set; }

		public ConfigEntry<bool> BuildingCar { get; set; }

		public static Config Instance
		{
			get
			{
				if (instance == null)
				{
					instance = new Config();
				}
				return instance;
			}
		}

		public void Setup()
		{
			Enabled = Project5.BepInExConfig().Bind<bool>("General", "Enabled", true, "Enables the fortnite");
			ManualSelect = Project5.BepInExConfig().Bind<bool>("General", "Gravity select mode", false, "use j, currently broken");
			WasConfigFixed = Project5.BepInExConfig().Bind<bool>("Dev", "ConfigFixed", false, "Manual select was on by default and i cant do much about it now so config to disable the config");
			BuildingCar = Project5.BepInExConfig().Bind<bool>("General", "Car go in building", true, "isnt effected by gravity control being enabled, car go building near door, dont be suprised if you fall out of the map or get stuck in a wall thats your fault my mod is flawless shut up shut up shut up shut up shut up shut up shut up shut up shut up shut up shut up shut up shut up shut up shut up shut up shut up shut up shut up shut up shut up shut up shut up shut up ");
		}
	}
	[BepInPlugin("Pandemonius.FortniteMod", "FortniteMod", "1.2.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Project5 : BaseUnityPlugin
	{
		internal static Project5 Instance;

		private readonly Harmony harmony = new Harmony("Pandemonius.FortniteMod");

		public static bool InPhysics = false;

		public static PlayerPhysicsRegion carphysics;

		public static bool ChangeGrav = false;

		public static bool SetupInput = false;

		public static bool isOutside = true;

		public static EntranceTeleport[] AllTeleports;

		public static EntranceTeleport[] outsideTeleports;

		public static EntranceTeleport[] insideTeleports;

		internal static gravbinds inputtime;

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


		public static ConfigFile BepInExConfig()
		{
			return ((BaseUnityPlugin)Instance).Config;
		}

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			Instance = this;
			Config.Instance.Setup();
			harmony.PatchAll();
			inputtime = new gravbinds();
			if (Config.Instance.ManualSelect.Value & !Config.Instance.WasConfigFixed.Value)
			{
				Config.Instance.ManualSelect.Value = false;
				Config.Instance.WasConfigFixed.Value = false;
			}
		}
	}
}
namespace CarStuff.Patches
{
	[HarmonyPatch(typeof(VehicleController))]
	public class CarPatchBuilding
	{
		public static float timeAtLastUsingEntrance = 0f;

		public static Transform ClosestPoint = new Transform();

		public static float MinMagnitude = 8f;

		public static float ClosestMagnitude = MinMagnitude;

		public static bool updated = false;

		[HarmonyPatch("FixedUpdate")]
		[HarmonyPostfix]
		public static void TeleportCar(VehicleController __instance)
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0279: Unknown result type (might be due to invalid IL or missing references)
			//IL_028a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_032c: Unknown result type (might be due to invalid IL or missing references)
			//IL_033b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0345: Unknown result type (might be due to invalid IL or missing references)
			//IL_034a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0365: Unknown result type (might be due to invalid IL or missing references)
			//IL_037a: Unknown result type (might be due to invalid IL or missing references)
			//IL_038b: Unknown result type (might be due to invalid IL or missing references)
			//IL_039a: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_03be: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fe: 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_0217: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0221: Unknown result type (might be due to invalid IL or missing references)
			//IL_0231: Unknown result type (might be due to invalid IL or missing references)
			//IL_0246: Unknown result type (might be due to invalid IL or missing references)
			//IL_024b: Unknown result type (might be due to invalid IL or missing references)
			if (!Config.Instance.BuildingCar.Value || !__instance.localPlayerInControl)
			{
				return;
			}
			Project5.isOutside = ((Component)__instance.mainRigidbody).transform.position.y > -80f;
			Project5.Logger.LogInfo((object)$"Outside = {Project5.isOutside}");
			if (((NetworkBehaviour)__instance).IsOwner & !__instance.carDestroyed & !StartOfRound.Instance.inShipPhase)
			{
				if (!(Time.realtimeSinceStartup - timeAtLastUsingEntrance > 1.8f))
				{
					return;
				}
				ClosestMagnitude = MinMagnitude;
				if (!Project5.isOutside)
				{
					int num = 0;
					EntranceTeleport[] insideTeleports = Project5.insideTeleports;
					EntranceTeleport[] array = insideTeleports;
					foreach (EntranceTeleport val in array)
					{
						if (Vector3.Distance(__instance.mainRigidbody.position, ((Component)val.entrancePoint).transform.position) < ClosestMagnitude)
						{
							ClosestMagnitude = Vector3.Distance(__instance.mainRigidbody.position, ((Component)val.entrancePoint).transform.position);
							ClosestPoint = ((Component)Project5.outsideTeleports[num]).transform;
						}
						num++;
					}
					if (ClosestMagnitude != MinMagnitude)
					{
						timeAtLastUsingEntrance = Time.realtimeSinceStartup;
						__instance.mainRigidbody.isKinematic = true;
						((Component)__instance).transform.position = ClosestPoint.position + ((Component)ClosestPoint).transform.right * 12f;
						((Component)__instance).transform.rotation = Quaternion.Euler(0f, ClosestPoint.eulerAngles.y + 90f, 0f);
						__instance.syncedPosition = ClosestPoint.position + ((Component)ClosestPoint).transform.right * 12f;
						__instance.syncedRotation = Quaternion.Euler(0f, ClosestPoint.eulerAngles.y + 90f, 0f);
					}
					return;
				}
				int num2 = 0;
				EntranceTeleport[] outsideTeleports = Project5.outsideTeleports;
				EntranceTeleport[] array2 = outsideTeleports;
				foreach (EntranceTeleport val2 in array2)
				{
					if (Vector3.Distance(__instance.mainRigidbody.position, ((Component)val2.entrancePoint).transform.position) < ClosestMagnitude)
					{
						ClosestMagnitude = Vector3.Distance(__instance.mainRigidbody.position, ((Component)val2.entrancePoint).transform.position);
						ClosestPoint = ((Component)Project5.insideTeleports[num2]).transform;
					}
					num2++;
				}
				if (ClosestMagnitude != MinMagnitude)
				{
					timeAtLastUsingEntrance = Time.realtimeSinceStartup;
					__instance.mainRigidbody.isKinematic = true;
					((Component)__instance).transform.position = ClosestPoint.position + ((Component)ClosestPoint).transform.right * 12f;
					((Component)__instance).transform.rotation = Quaternion.Euler(0f, ClosestPoint.eulerAngles.y + 90f, 0f);
					__instance.syncedPosition = ClosestPoint.position + ((Component)ClosestPoint).transform.right * 12f;
					__instance.syncedRotation = Quaternion.Euler(0f, ClosestPoint.eulerAngles.y + 90f, 0f);
				}
			}
			else
			{
				timeAtLastUsingEntrance = Time.realtimeSinceStartup;
			}
		}
	}
	[HarmonyPatch(typeof(RoundManager))]
	public class EntrancePatchCar
	{
		[HarmonyPatch("SetLevelObjectVariables")]
		[HarmonyPostfix]
		private static void GetTeleports()
		{
			Project5.AllTeleports = Object.FindObjectsOfType<EntranceTeleport>();
			Project5.outsideTeleports = (EntranceTeleport[])(object)new EntranceTeleport[Project5.AllTeleports.Length / 2];
			Project5.insideTeleports = (EntranceTeleport[])(object)new EntranceTeleport[Project5.AllTeleports.Length / 2];
			for (int i = 0; i < Project5.AllTeleports.Length; i++)
			{
				int entranceId = Project5.AllTeleports[i].entranceId;
				if (Project5.AllTeleports[i].isEntranceToBuilding)
				{
					Project5.outsideTeleports[entranceId] = Project5.AllTeleports[i];
				}
				else
				{
					Project5.insideTeleports[entranceId] = Project5.AllTeleports[i];
				}
			}
		}
	}
	[HarmonyPatch(typeof(VehicleController))]
	public class CarControl
	{
		public static Vector3 grav = Physics.gravity;

		public static RaycastHit Carhit;

		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void CarGravity(VehicleController __instance)
		{
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			if (Config.Instance.Enabled.Value)
			{
				Project5.carphysics = __instance.physicsRegion;
				__instance.physicsRegion.maxTippingAngle = 2.1474836E+09f;
				if (Config.Instance.ManualSelect.Value)
				{
					if (Project5.ChangeGrav & Physics.Raycast(((Component)__instance).transform.position, ((Component)GameNetworkManager.Instance.localPlayerController.gameplayCamera).transform.forward * 1f, ref Carhit, 2048f, StartOfRound.Instance.collidersRoomDefaultAndFoliage, (QueryTriggerInteraction)1))
					{
						Physics.gravity = Quaternion.Euler(((RaycastHit)(ref Carhit)).normal) * grav;
						Project5.ChangeGrav = false;
					}
					else
					{
						Project5.ChangeGrav = false;
					}
				}
				else
				{
					Project5.ChangeGrav = false;
					if (Physics.Raycast(((Component)__instance).transform.position, ((Component)__instance).transform.up * -1f, ref Carhit, 6f, StartOfRound.Instance.collidersAndRoomMask, (QueryTriggerInteraction)1))
					{
						Physics.gravity = ((Component)__instance).transform.rotation * grav;
					}
				}
			}
			else
			{
				Physics.gravity = grav;
				__instance.physicsRegion.maxTippingAngle = 180f;
			}
		}
	}
	[HarmonyPatch(typeof(PlayerPhysicsRegion))]
	public class PlayerFix
	{
		public static Vector3 playervel = default(Vector3);

		public static float StepOffset = 0f;

		public static float Slope = 0f;

		public static float SlopeIntensity = 0f;

		public static PlayerControllerB LocalPlayer;

		public static LayerMask Layerinfo = LayerMask.op_Implicit(1073741824);

		public static Vector3 FakeWalkForce = Vector3.zero;

		public static Vector3 FakeExternalForce = Vector3.zero;

		public static float FakeSlopeModifier = 0f;

		public static float FakeSprintMultiplier = 0f;

		public static Vector3 vector;

		[HarmonyPatch("Update")]
		[HarmonyPrefix]
		private static void PlayerPatch(PlayerPhysicsRegion __instance)
		{
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: 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_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: 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_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_021d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0228: Unknown result type (might be due to invalid IL or missing references)
			//IL_0248: Unknown result type (might be due to invalid IL or missing references)
			//IL_024d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0267: Unknown result type (might be due to invalid IL or missing references)
			//IL_026c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0280: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
			LocalPlayer = GameNetworkManager.Instance.localPlayerController;
			if (GameNetworkManager.Instance.localPlayerController.thisController.stepOffset > 0f)
			{
				StepOffset = GameNetworkManager.Instance.localPlayerController.thisController.stepOffset;
			}
			if (GameNetworkManager.Instance.localPlayerController.slopeIntensity > 0f)
			{
				SlopeIntensity = GameNetworkManager.Instance.localPlayerController.slopeIntensity;
			}
			if (GameNetworkManager.Instance.localPlayerController.thisController.slopeLimit < 180f)
			{
				Slope = GameNetworkManager.Instance.localPlayerController.thisController.slopeLimit;
			}
			if (((Object)(object)__instance == (Object)(object)Project5.carphysics) & __instance.hasLocalPlayer & !GameNetworkManager.Instance.localPlayerController.inVehicleAnimation & Config.Instance.Enabled.Value)
			{
				LocalPlayer.thisController.slopeLimit = 180f;
				LocalPlayer.playerGroundNormal = Vector3.up;
				GameNetworkManager.Instance.localPlayerController.thisController.stepOffset = 0f;
				Project5.InPhysics = true;
				if (Physics.Raycast(((Component)LocalPlayer.thisController).transform.position + ((Component)__instance).transform.up * (StepOffset * 0.5f), -((Component)__instance).transform.up, ref LocalPlayer.hit, StepOffset, LayerMask.op_Implicit(Layerinfo), (QueryTriggerInteraction)1))
				{
					playervel = ((Component)GameNetworkManager.Instance.localPlayerController).transform.up * 0f;
				}
				else
				{
					playervel = ((Component)GameNetworkManager.Instance.localPlayerController).transform.up * -3f;
				}
				GameNetworkManager.Instance.localPlayerController.thisController.Move(playervel);
				GameNetworkManager.Instance.localPlayerController.ResetFallGravity();
				if (Physics.SphereCast(((Component)LocalPlayer.thisController).transform.position + ((Component)__instance).transform.up * (StepOffset * 0.5f + LocalPlayer.thisController.radius), LocalPlayer.thisController.radius, -((Component)__instance).transform.up, ref LocalPlayer.hit, StepOffset, LayerMask.op_Implicit(Layerinfo), (QueryTriggerInteraction)1))
				{
					LocalPlayer.thisController.SimpleMove(-((Component)__instance).transform.up * (((RaycastHit)(ref LocalPlayer.hit)).distance - StepOffset * 0.5f));
				}
			}
			else
			{
				GameNetworkManager.Instance.localPlayerController.slopeIntensity = SlopeIntensity;
				GameNetworkManager.Instance.localPlayerController.thisController.slopeLimit = Slope;
				GameNetworkManager.Instance.localPlayerController.thisController.stepOffset = StepOffset;
				Project5.InPhysics = false;
			}
		}
	}
}
namespace CarStuff.BindingInfo
{
	[HarmonyPatch(typeof(PlayerControllerB))]
	public class trueorrubbish
	{
		[HarmonyPatch("ConnectClientToPlayerObject")]
		[HarmonyPrefix]
		public static void SetupKeybindCallbacks(PlayerControllerB __instance)
		{
			if (!Project5.SetupInput)
			{
				gravbinds.Instance.switchwall.performed += keybindHandler.wallswitch;
				Project5.SetupInput = true;
			}
		}
	}
	[HarmonyPatch(typeof(StartOfRound))]
	public class rubbishortrue
	{
		[HarmonyPatch("OnLocalDisconnect")]
		[HarmonyPrefix]
		public static void Disconnectkeybinds()
		{
			if (Project5.SetupInput)
			{
				gravbinds.Instance.switchwall.performed -= keybindHandler.wallswitch;
				Project5.SetupInput = false;
			}
		}
	}
	public class keybindHandler
	{
		public static void wallswitch(CallbackContext context)
		{
			if (((CallbackContext)(ref context)).performed)
			{
				Project5.ChangeGrav = true;
			}
		}
	}
	public class gravbinds : LcInputActions
	{
		public static readonly gravbinds Instance = new gravbinds();

		public InputAction switchwall => ((LcInputActions)this).Asset["gravbindss"];

		public override void CreateInputActions(in InputActionMapBuilder builder)
		{
			builder.NewActionBinding().WithActionId("gravbindss").WithActionType((InputActionType)1)
				.WithKeyboardControl((KeyboardControl)30)
				.WithGamepadControl((GamepadControl)4)
				.WithBindingName("BindGravity")
				.Finish();
		}
	}
}