Decompiled source of Vehicle Hangar v1.0.1

LethalGravityControl.dll

Decompiled 2 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
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 LethalLevelLoader;
using Microsoft.CodeAnalysis;
using UnityEngine;

[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("LethalGravityControl")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Project1")]
[assembly: AssemblyTitle("LethalGravityControl")]
[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 Project1
{
	[BepInPlugin("LethalGravityControl", "Project1", "1.0.0")]
	public class Project1 : BaseUnityPlugin
	{
		public static Project1 Instance { get; private set; }

		internal static ManualLogSource Logger { get; private set; }

		internal static Harmony? Harmony { get; set; }

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			Instance = this;
			Patch();
			Logger.LogInfo((object)"LethalGravityControl v1.0.0 has loaded!");
		}

		internal static void Patch()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			if (Harmony == null)
			{
				Harmony = new Harmony("LethalGravityControl");
			}
			Logger.LogDebug((object)"Patching...");
			Harmony.PatchAll();
			Logger.LogDebug((object)"Finished patching!");
		}

		internal static void Unpatch()
		{
			Logger.LogDebug((object)"Unpatching...");
			Harmony? harmony = Harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
			Logger.LogDebug((object)"Finished unpatching!");
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "LethalGravityControl";

		public const string PLUGIN_NAME = "Project1";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace Project1.Patches
{
	public class WallGravity : MonoBehaviour
	{
		[HideInInspector]
		public static bool applyWallGravity;

		public float GravityMult = 1f;

		private PlayerControllerB player;

		private void FixedUpdate()
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			if (applyWallGravity && (Object)(object)player != (Object)null)
			{
				PlayerControllerB obj = player;
				obj.externalForceAutoFade += Vector3.up * GravityMult;
				player.fallValueUncapped = -1f;
				player.fallValue = -1f;
			}
		}

		private void OnTriggerEnter(Collider other)
		{
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			PlayerControllerB val = default(PlayerControllerB);
			if (((Component)other).CompareTag("Player") && ((Component)other).TryGetComponent<PlayerControllerB>(ref val) && (Object)(object)val == (Object)(object)GameNetworkManager.Instance.localPlayerController)
			{
				player = val;
				applyWallGravity = true;
				if (player.fallValue > -2f)
				{
					PlayerControllerB obj = player;
					obj.externalForces += Vector3.up * GravityMult;
				}
			}
		}

		private void OnTriggerExit(Collider other)
		{
			PlayerControllerB val = default(PlayerControllerB);
			if (((Component)other).CompareTag("Player") && ((Component)other).TryGetComponent<PlayerControllerB>(ref val) && (Object)(object)val == (Object)(object)GameNetworkManager.Instance.localPlayerController)
			{
				applyWallGravity = false;
				player = null;
			}
		}
	}
	public class OffWallGravity : MonoBehaviour
	{
		[HideInInspector]
		public static bool applyWallGravity;

		private PlayerControllerB player;

		private void OnTriggerEnter(Collider other)
		{
			PlayerControllerB val = default(PlayerControllerB);
			if (((Component)other).CompareTag("Player") && ((Component)other).TryGetComponent<PlayerControllerB>(ref val) && (Object)(object)val == (Object)(object)GameNetworkManager.Instance.localPlayerController)
			{
				player = val;
				applyWallGravity = false;
			}
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal static class PlayerControllerBPatch
	{
		[HarmonyPatch("PlayFootstepSound")]
		[HarmonyPrefix]
		public static bool PlayFootstepSound(PlayerControllerB __instance)
		{
			return !WallGravity.applyWallGravity;
		}
	}
	public class XTextureReplaceBasedOnTags : MonoBehaviour
	{
		public Renderer renderer = null;

		public MaterialsWithNames[] materialsWithNames = Array.Empty<MaterialsWithNames>();

		public void Start()
		{
			foreach (ContentTag contentTag in ((ExtendedContent)LevelManager.CurrentExtendedLevel).ContentTags)
			{
				ReplaceTextureBasedOnTagName(contentTag.contentTagName);
			}
		}

		public void ReplaceTextureBasedOnTagName(string contentTagName)
		{
			MaterialsWithNames[] array = this.materialsWithNames;
			foreach (MaterialsWithNames materialsWithNames in array)
			{
				if (materialsWithNames.contentTagNames.Contains(contentTagName))
				{
					renderer.SetMaterials(materialsWithNames.materials);
					break;
				}
			}
		}
	}
	[Serializable]
	public class MaterialsWithNames
	{
		public List<Material> materials = new List<Material>();

		public string[] contentTagNames = Array.Empty<string>();
	}
}