Decompiled source of ULTRAShuv v1.2.0

ULTRAShuv.dll

Decompiled 3 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 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.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[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("Debug")]
[assembly: AssemblyFileVersion("0.0.0.0")]
[assembly: AssemblyInformationalVersion("0.0.0-dev")]
[assembly: AssemblyProduct("Shuv")]
[assembly: AssemblyTitle("Shuv")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.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; } = true;


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


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


		internal static int Damage { get; set; } = 5;

	}
	[ContentWarningPlugin("Shuv", "0.0.0", true)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("Shuv", "Shuv", "0.0.0")]
	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 ShuvDamageIntSetting ShuvDamage { get; private set; } = new ShuvDamageIntSetting();


		public static string Name => "Shuv";

		public static string Version => "0.0.0";

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			Instance = this;
			Patch();
			ShuvKeyCSetting shuvKeyCSetting = new ShuvKeyCSetting();
			ShuvKey.SetKeybind((KeyCodeSetting)(object)shuvKeyCSetting);
			SettingsLoader.RegisterSetting("Shuv", "Keybindings", (Setting)(object)shuvKeyCSetting);
			SettingsLoader.RegisterSetting("Shuv", "Options", (Setting)(object)ShuvEnemies);
			SettingsLoader.RegisterSetting("Shuv", "Options", (Setting)(object)RagdollTime);
			SettingsLoader.RegisterSetting("Shuv", "Options", (Setting)(object)ShuvStrength);
			SettingsLoader.RegisterSetting("Shuv", "Options", (Setting)(object)ShuvDamage);
			MyceliumNetwork.RegisterLobbyDataKey("Shuv_Enemies");
			MyceliumNetwork.RegisterLobbyDataKey("Shuv_Ragdoll");
			MyceliumNetwork.RegisterLobbyDataKey("Shuv_Strength");
			MyceliumNetwork.RegisterLobbyDataKey("Shuv_Damage");
			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);
					MyceliumNetwork.SetLobbyData("Shuv_Damage", (object)((IntSetting)ShuvDamage).Value);
				}
				else
				{
					TakeLobbyDataToConfig();
				}
			};
			MyceliumNetwork.LobbyDataUpdated += delegate
			{
				TakeLobbyDataToConfig();
			};
			Logger.LogInfo((object)"Shuv v0.0.0 has loaded!");
		}

		private void OnDestroy()
		{
			Unpatch();
			Logger.LogInfo((object)"Shuv v0.0.0 has unloaded!");
		}

		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");
				ShuvConfig.Damage = MyceliumNetwork.GetLobbyData<int>("Shuv_Damage");
				Logger.LogWarning((object)$"Shove Power Updated By Network: {ShuvConfig.Strength} InLobby {MyceliumNetwork.InLobby} | IsHost {MyceliumNetwork.IsHost}");
			}
		}

		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");
			}
			Harmony.PatchAll();
			Logger.LogDebug((object)"Finished patching for Shuv!");
		}

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

		public const string PLUGIN_NAME = "Shuv";

		public const string PLUGIN_VERSION = "0.0.0";
	}
}
namespace Shuv.Settings
{
	public class ShuvDamageIntSetting : IntSetting, ICustomSetting, IExposedSetting
	{
		public override void ApplyValue()
		{
			if (!SteamManager.Initialized || !MyceliumNetwork.InLobby || MyceliumNetwork.IsHost)
			{
				ShuvConfig.Damage = ((IntSetting)this).Value;
			}
			if (SteamManager.Initialized && MyceliumNetwork.InLobby && MyceliumNetwork.IsHost)
			{
				MyceliumNetwork.SetLobbyData("Shuv_Damage", (object)((IntSetting)this).Value);
			}
		}

		protected override int GetDefaultValue()
		{
			return 0;
		}

		protected override (int, int) GetMinMaxValue()
		{
			return (0, 10);
		}

		public string GetDisplayName()
		{
			return "Shove Damage";
		}
	}
	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 0;
		}

		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 25f;
		}

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

		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(1f, 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_0119: 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_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0235: Unknown result type (might be due to invalid IL or missing references)
			//IL_023f: Unknown result type (might be due to invalid IL or missing references)
			//IL_025f: Unknown result type (might be due to invalid IL or missing references)
			if (!__instance.refs.view.IsMine || __instance.refs == null)
			{
				return;
			}
			bool flag = __instance.data.health > 0f && !__instance.data.dead;
			if (Shuv.ShuvKey.GetKey() && (Object)(object)__instance.refs.items != (Object)null && flag)
			{
				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;
				}
			}
			if (!Shuv.ShuvKey.GetKey() && Charge > 0.25f && flag)
			{
				Ray val = default(Ray);
				((Ray)(ref val))..ctor(__instance.refs.cameraPos.position, __instance.refs.cameraPos.forward);
				RaycastHit[] source = Physics.RaycastAll(val, 2f, LayerMask.op_Implicit(HelperFunctions.GetMask((LayerType)3)));
				Player val2 = source.Select((RaycastHit raycastHit) => ((Component)((Component)((RaycastHit)(ref raycastHit)).collider).transform.parent).GetComponentInParent<Player>()).TakeWhile((Player potentialPlayer) => Object.op_Implicit((Object)(object)potentialPlayer) && (Object)(object)potentialPlayer != (Object)null).FirstOrDefault((Func<Player, bool>)((Player potentialPlayer) => Object.op_Implicit((Object)(object)potentialPlayer) && !potentialPlayer.IsLocal));
				Shuv.Logger.LogDebug((object)"Trying shove...");
				if ((Object)(object)val2 != (Object)null && Object.op_Implicit((Object)(object)val2))
				{
					Shuv.Logger.LogDebug((object)(val2.ai ? "Shoving AI" : "Shoving Player"));
					if (!val2.ai || ShuvConfig.ShoveEnemies)
					{
						val2.CallTakeDamageAndAddForceAndFall((float)ShuvConfig.Damage, __instance.refs.cameraPos.forward * Charge * (ShuvConfig.Strength / (val2.ai ? 4f : 1f)), Charge * ShuvConfig.RagdollTime + 0.5f);
						val2.CallMakeSound(0);
					}
				}
			}
			if ((!flag || !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)
		{
		}
	}
}