Decompiled source of MegaShuv v1.1.0

Shuv.dll

Decompiled 7 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 ContentSettings.API.Settings;
using HarmonyLib;
using JetBrains.Annotations;
using Microsoft.CodeAnalysis;
using MyceliumNetworking;
using Shuv.Settings;
using Unity.Mathematics;
using UnityEngine;
using Zorro.Settings;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Ashley.MeshSplitter")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("com.rlabrecque.steamworks.net")]
[assembly: IgnoresAccessChecksTo("Discord")]
[assembly: IgnoresAccessChecksTo("HBAO.Demo.Universal.Runtime")]
[assembly: IgnoresAccessChecksTo("HBAO.Runtime")]
[assembly: IgnoresAccessChecksTo("HBAO.Universal.Runtime")]
[assembly: IgnoresAccessChecksTo("MeshSplit")]
[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: IgnoresAccessChecksTo("pworld")]
[assembly: IgnoresAccessChecksTo("sc.posteffects.runtime")]
[assembly: IgnoresAccessChecksTo("Sirenix.OdinInspector.Attributes")]
[assembly: IgnoresAccessChecksTo("Sirenix.OdinInspector.Modules.Unity.Addressables")]
[assembly: IgnoresAccessChecksTo("Sirenix.OdinInspector.Modules.UnityLocalization")]
[assembly: IgnoresAccessChecksTo("Sirenix.Serialization.Config")]
[assembly: IgnoresAccessChecksTo("Sirenix.Serialization")]
[assembly: IgnoresAccessChecksTo("Sirenix.Utilities")]
[assembly: IgnoresAccessChecksTo("Tayx.Graphy")]
[assembly: IgnoresAccessChecksTo("Unity.Addressables")]
[assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging.DocCodeExamples")]
[assembly: IgnoresAccessChecksTo("Unity.Burst")]
[assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")]
[assembly: IgnoresAccessChecksTo("Unity.Collections")]
[assembly: IgnoresAccessChecksTo("Unity.Collections.LowLevel.ILSupport")]
[assembly: IgnoresAccessChecksTo("Unity.InternalAPIEngineBridge.013")]
[assembly: IgnoresAccessChecksTo("Unity.Localization")]
[assembly: IgnoresAccessChecksTo("Unity.Mathematics")]
[assembly: IgnoresAccessChecksTo("Unity.PlayableGraphVisualizer")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipeline.Universal.ShaderLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Universal.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Universal.Shaders")]
[assembly: IgnoresAccessChecksTo("Unity.ResourceManager")]
[assembly: IgnoresAccessChecksTo("Unity.ScriptableBuildPipeline")]
[assembly: IgnoresAccessChecksTo("Unity.Splines")]
[assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")]
[assembly: IgnoresAccessChecksTo("Unity.Timeline")]
[assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Antlr3.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Core")]
[assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Flow")]
[assembly: IgnoresAccessChecksTo("Unity.VisualScripting.State")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UI")]
[assembly: IgnoresAccessChecksTo("Zorro.Core.Runtime")]
[assembly: IgnoresAccessChecksTo("Zorro.PhotonUtility")]
[assembly: IgnoresAccessChecksTo("Zorro.Recorder")]
[assembly: IgnoresAccessChecksTo("Zorro.Settings.Runtime")]
[assembly: IgnoresAccessChecksTo("Zorro.UI.Runtime")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Shuv")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.9.0")]
[assembly: AssemblyInformationalVersion("1.0.9+7a5f3d803c0c6315cc695af3b35bc6fb05db996b")]
[assembly: AssemblyProduct("Shuv")]
[assembly: AssemblyTitle("Shuv")]
[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 BepInEx
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class BepInAutoPluginAttribute : Attribute
	{
		public BepInAutoPluginAttribute(string id = null, string name = null, string version = null)
		{
		}
	}
}
namespace BepInEx.Preloader.Core.Patching
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class PatcherAutoPluginAttribute : Attribute
	{
		public PatcherAutoPluginAttribute(string id = null, string name = null, string version = null)
		{
		}
	}
}
namespace Shuv
{
	internal static class ShuvConfig
	{
		internal static bool ShoveEnemies { get; set; } = false;


		internal static float RagdollTime { get; set; } = 1.5f;


		internal static float Strength { get; set; } = 1f;

	}
	[ContentWarningPlugin("Shuv", "1.0.9", false)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("Shuv", "Shuv", "1.0.9")]
	public class Shuv : BaseUnityPlugin
	{
		public const string Id = "Shuv";

		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();


		public static ShuvRagdollFloatSetting RagdollTime { get; private set; } = new ShuvRagdollFloatSetting();


		public static ShuvPowerFloatSetting ShuvStrength { get; private set; } = new ShuvPowerFloatSetting();


		public static string Name => "Shuv";

		public static string Version => "1.0.9";

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			Instance = this;
			Patch();
			ShuvKeyCSetting shuvKeyCSetting = new ShuvKeyCSetting();
			ShuvKey.SetKeybind((KeyCodeSetting)(object)shuvKeyCSetting);
			SettingsLoader.RegisterSetting("Modded", "Shuv", (Setting)(object)shuvKeyCSetting);
			SettingsLoader.RegisterSetting("Modded", "Shuv", (Setting)(object)ShuvEnemies);
			SettingsLoader.RegisterSetting("Modded", "Shuv", (Setting)(object)RagdollTime);
			SettingsLoader.RegisterSetting("Modded", "Shuv", (Setting)(object)ShuvStrength);
			MyceliumNetwork.RegisterLobbyDataKey("Shuv_Enemies");
			MyceliumNetwork.RegisterLobbyDataKey("Shuv_Ragdoll");
			MyceliumNetwork.RegisterLobbyDataKey("Shuv_Strength");
			MyceliumNetwork.LobbyEntered += delegate
			{
				if (MyceliumNetwork.IsHost)
				{
					MyceliumNetwork.SetLobbyData("Shuv_Enemies", (object)((IntSetting)ShuvEnemies).Value);
					MyceliumNetwork.SetLobbyData("Shuv_Ragdoll", (object)((FloatSetting)RagdollTime).Value);
					MyceliumNetwork.SetLobbyData("Shuv_Strength", (object)((FloatSetting)ShuvStrength).Value);
				}
				else
				{
					TakeLobbyDataToConfig();
				}
			};
			MyceliumNetwork.LobbyDataUpdated += delegate
			{
				TakeLobbyDataToConfig();
			};
			Logger.LogInfo((object)"Shuv v1.0.9 has loaded!");
		}

		private static void TakeLobbyDataToConfig()
		{
			if (!MyceliumNetwork.IsHost)
			{
				ShuvConfig.ShoveEnemies = MyceliumNetwork.GetLobbyData<int>("Shuv_Enemies") == 1;
				ShuvConfig.RagdollTime = MyceliumNetwork.GetLobbyData<float>("Shuv_Ragdoll");
				ShuvConfig.Strength = MyceliumNetwork.GetLobbyData<float>("Shuv_Strength");
				Logger.LogWarning((object)$"Shove Power Updated By Network: {ShuvConfig.Strength} InLobby {MyceliumNetwork.InLobby} | IsHost {MyceliumNetwork.IsHost}");
			}
		}

		internal static void Patch()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: 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 = "1.0.9";
	}
}
namespace Shuv.Settings
{
	public class ShuvEnemiesBoolSetting : EnumSetting, ICustomSetting, IExposedSetting
	{
		public override void ApplyValue()
		{
			if (!SteamManager.Initialized || !MyceliumNetwork.InLobby || MyceliumNetwork.IsHost)
			{
				ShuvConfig.ShoveEnemies = ((IntSetting)this).Value == 1;
			}
			if (SteamManager.Initialized && MyceliumNetwork.InLobby && MyceliumNetwork.IsHost)
			{
				MyceliumNetwork.SetLobbyData("Shuv_Enemies", (object)((IntSetting)this).Value);
			}
		}

		public override int GetDefaultValue()
		{
			return 1;
		}

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

		public string GetDisplayName()
		{
			return "Shove Enemies";
		}
	}
	public class ShuvKeyCSetting : KeyCodeSetting, ICustomSetting, IExposedSetting
	{
		public override KeyCode GetDefaultKey()
		{
			return (KeyCode)101;
		}

		public string GetDisplayName()
		{
			return "Hold to Shove";
		}
	}
	public class ShuvPowerFloatSetting : FloatSetting, ICustomSetting, IExposedSetting
	{
		public override void ApplyValue()
		{
			if (!SteamManager.Initialized || !MyceliumNetwork.InLobby || MyceliumNetwork.IsHost)
			{
				ShuvConfig.Strength = ((FloatSetting)this).Value;
			}
			if (SteamManager.Initialized && MyceliumNetwork.InLobby && MyceliumNetwork.IsHost)
			{
				MyceliumNetwork.SetLobbyData("Shuv_Strength", (object)((FloatSetting)this).Value);
			}
		}

		public override float GetDefaultValue()
		{
			return 10f;
		}

		public override float2 GetMinMaxValue()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			return new float2(1f, 1500f);
		}

		public string GetDisplayName()
		{
			return "Shove Strength";
		}
	}
	public class ShuvRagdollFloatSetting : FloatSetting, ICustomSetting, IExposedSetting
	{
		public override void ApplyValue()
		{
			if (!SteamManager.Initialized || !MyceliumNetwork.InLobby || MyceliumNetwork.IsHost)
			{
				ShuvConfig.RagdollTime = ((FloatSetting)this).Value;
			}
			if (SteamManager.Initialized && MyceliumNetwork.InLobby && MyceliumNetwork.IsHost)
			{
				MyceliumNetwork.SetLobbyData("Shuv_Ragdoll", (object)((FloatSetting)this).Value);
			}
		}

		public override float GetDefaultValue()
		{
			return 1f;
		}

		public override float2 GetMinMaxValue()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			return new float2(0.1f, 2.5f);
		}

		public string GetDisplayName()
		{
			return "Ragdoll Time";
		}
	}
}
namespace Shuv.Patches
{
	[HarmonyPatch(typeof(Player))]
	public class PlayerUpdatePatch
	{
		private static float Charge { get; set; }

		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void CheckForShuvBinding(Player __instance)
		{
			//IL_00d2: 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_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: 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_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: 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)
			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)
			{
				Ray val = default(Ray);
				((Ray)(ref val))..ctor(__instance.refs.cameraPos.position, __instance.refs.cameraPos.forward);
				RaycastHit[] array = Physics.RaycastAll(val, 2f, LayerMask.op_Implicit(HelperFunctions.GetMask((LayerType)3)));
				if (array == null)
				{
					return;
				}
				RaycastHit val2 = default(RaycastHit);
				Player val3 = null;
				RaycastHit[] array2 = array;
				for (int i = 0; i < array2.Length; i++)
				{
					RaycastHit val4 = array2[i];
					if (Object.op_Implicit((Object)(object)(val3 = ((Component)((Component)((RaycastHit)(ref val4)).collider).transform.parent).GetComponentInParent<Player>())) && !val3.IsLocal)
					{
						break;
					}
				}
				if ((Object)(object)val3 == (Object)null || !Object.op_Implicit((Object)(object)val3))
				{
					return;
				}
				if ((Object)(object)val3 != (Object)null && (!val3.ai || ShuvConfig.ShoveEnemies))
				{
					val3.CallTakeDamageAndAddForceAndFall(0f, __instance.refs.cameraPos.forward * Charge * (ShuvConfig.Strength / (val3.ai ? 4f : 1f)), Charge * ShuvConfig.RagdollTime + 0.5f);
					val3.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)
		{
		}
	}
}