BepInEx/plugins/Shuv/Shuv.dll

Decompiled 2 months ago
using System;
using System.Collections.Generic;
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 ContentSettings.API;
using HarmonyLib;
using JetBrains.Annotations;
using Microsoft.CodeAnalysis;
using UnityEngine;
using Zorro.Settings;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("Photon3Unity3D")]
[assembly: IgnoresAccessChecksTo("PhotonChat")]
[assembly: IgnoresAccessChecksTo("PhotonRealtime")]
[assembly: IgnoresAccessChecksTo("PhotonUnityNetworking")]
[assembly: IgnoresAccessChecksTo("PhotonUnityNetworking.Utilities")]
[assembly: IgnoresAccessChecksTo("PhotonVoice.API")]
[assembly: IgnoresAccessChecksTo("PhotonVoice")]
[assembly: IgnoresAccessChecksTo("PhotonVoice.PUN")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Shuv")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("0.2.3.0")]
[assembly: AssemblyInformationalVersion("0.2.3")]
[assembly: AssemblyProduct("Shuv")]
[assembly: AssemblyTitle("Shuv")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.2.3.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 Shuv
{
	public class ShuvKeyCSetting : KeyCodeSetting, IExposedSetting
	{
		protected override KeyCode GetDefaultKey()
		{
			return (KeyCode)101;
		}

		public SettingCategory GetSettingCategory()
		{
			return (SettingCategory)2;
		}

		public string GetDisplayName()
		{
			return "Hold to Shove";
		}
	}
	public class ShuvEnemiesBoolSetting : EnumSetting, IExposedSetting
	{
		public override void ApplyValue()
		{
			Shuv.Logger.LogInfo((object)("Shove Enemies: " + ((EnumSetting)this).GetChoices()[((IntSetting)this).Value]));
		}

		protected override int GetDefaultValue()
		{
			return 1;
		}

		public override List<string> GetChoices()
		{
			return new List<string>(2) { "No", "Yes" };
		}

		public SettingCategory GetSettingCategory()
		{
			return (SettingCategory)2;
		}

		public string GetDisplayName()
		{
			return "Shove Enemies";
		}
	}
	[ContentWarningPlugin("Shuv", "0.2.3", false)]
	[BepInPlugin("Shuv", "Shuv", "0.2.3")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Shuv : BaseUnityPlugin
	{
		public static Shuv Instance { get; private set; } = null;


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


		[UsedImplicitly]
		internal static Harmony? Harmony { get; set; }

		public static InputKey ShuvKey { get; private set; } = new InputKey();


		public static ShuvEnemiesBoolSetting ShuvEnemies { get; private set; } = new ShuvEnemiesBoolSetting();


		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			Instance = this;
			Patch();
			ShuvKeyCSetting shuvKeyCSetting = new ShuvKeyCSetting();
			ShuvKey.SetKeybind((KeyCodeSetting)(object)shuvKeyCSetting);
			SettingsLoader.RegisterSetting((Setting)(object)shuvKeyCSetting);
			SettingsLoader.RegisterSetting((Setting)(object)ShuvEnemies);
			Logger.LogInfo((object)"Shuv v0.2.3 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("Shuv");
			}
			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 = "Shuv";

		public const string PLUGIN_NAME = "Shuv";

		public const string PLUGIN_VERSION = "0.2.3";
	}
}
namespace Shuv.Patches
{
	[HarmonyPatch(typeof(Player))]
	public class PlayerUpdatePatch
	{
		private const float ChargePower = 10f;

		private const float MaxFallTime = 0.1f;

		private static float Charge { get; set; }

		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void CheckForShuvBinding(Player __instance)
		{
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: 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_01cc: Unknown result type (might be due to invalid IL or missing references)
			if (!__instance.refs.view.IsMine)
			{
				return;
			}
			if (Shuv.ShuvKey.GetKey() && __instance.refs != null && (Object)(object)__instance.refs.items != (Object)null)
			{
				Charge = Mathf.MoveTowards(Charge, 1f, Time.deltaTime);
				if (Time.time > __instance.refs.items.shakeTime + 0.1f)
				{
					GamefeelHandler.instance.perlin.AddShake(Charge, 0.2f, 15f);
					__instance.refs.items.shakeTime = Time.time;
					return;
				}
			}
			if (!Shuv.ShuvKey.GetKey() && Charge > 0.25f)
			{
				RaycastHit val = HelperFunctions.LineCheck(__instance.refs.cameraPos.position, __instance.refs.cameraPos.position + __instance.refs.cameraPos.forward * 2f, (LayerType)3, 0.5f);
				if ((Object)(object)((RaycastHit)(ref val)).collider != (Object)null)
				{
					Player componentInParent = ((Component)((Component)((RaycastHit)(ref val)).collider).transform.parent).GetComponentInParent<Player>();
					if ((Object)(object)componentInParent != (Object)null && (!componentInParent.ai || ((IntSetting)Shuv.ShuvEnemies).Value == 1))
					{
						componentInParent.CallTakeDamageAndAddForceAndFall(0f, __instance.refs.cameraPos.forward * Charge * (10f / (componentInParent.ai ? 4f : 1f)), Charge * 2.5f + 0.5f);
						componentInParent.CallMakeSound(0);
					}
				}
				Charge = 0f;
			}
			if (!Shuv.ShuvKey.GetKey() && Charge > 0f)
			{
				Charge = 0f;
			}
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}