Decompiled source of Just sit down v1.1.5

Sitdown/JustSitDown.dll

Decompiled a year ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Reptile;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("MyUnityGameMod1")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MyUnityGameMod1")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("e59b1fb1-39dd-4018-81da-ce9714f55f21")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace JustSitDown
{
	[BepInPlugin("com.Dragsun.MyUnityGameMod1", "Just sit", "1.1.5")]
	public class JustSitDownPlugin : BaseUnityPlugin
	{
		private const string MyGUID = "com.Dragsun.MyUnityGameMod1";

		private const string PluginName = "Just sit";

		private const string VersionString = "1.1.5";

		public static string KeyboardShortcutExampleKey = "Recall Keyboard Shortcut";

		public static ConfigEntry<KeyboardShortcut> KeyboardShortcutExample;

		private static readonly Harmony Harmony = new Harmony("com.Dragsun.MyUnityGameMod1");

		public static ManualLogSource Log = new ManualLogSource("Just sit");

		public static Vector3 playerpos1;

		private float keyPressStartTime = 0f;

		public static Player player { get; set; }

		private void Awake()
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			KeyboardShortcutExample = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("General", KeyboardShortcutExampleKey, new KeyboardShortcut((KeyCode)109, Array.Empty<KeyCode>()), (ConfigDescription)null);
			KeyboardShortcutExample.SettingChanged += ConfigSettingChanged;
			((BaseUnityPlugin)this).Logger.LogInfo((object)"PluginName: Just sit, VersionString: 1.1.5 is loading...");
			Harmony.PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"PluginName: Just sit, VersionString: 1.1.5 is loaded.");
			Log = ((BaseUnityPlugin)this).Logger;
		}

		private void Update()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			KeyboardShortcut value = KeyboardShortcutExample.Value;
			if (((KeyboardShortcut)(ref value)).IsDown() && (Object)(object)player != (Object)null)
			{
				player.ActivateAbility((Ability)(object)player.sitAbility);
				((BaseUnityPlugin)this).Logger.LogInfo((object)((Object)((Component)player).gameObject).name);
			}
			if (Input.GetKey((KeyCode)339) || Input.GetKey((KeyCode)341))
			{
				if (keyPressStartTime == 0f)
				{
					keyPressStartTime = Time.time;
				}
				else if (Time.time - keyPressStartTime >= 2f)
				{
					player.ActivateAbility((Ability)(object)player.sitAbility);
				}
			}
			else
			{
				keyPressStartTime = 0f;
			}
		}

		private void ConfigSettingChanged(object sender, EventArgs e)
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			SettingChangedEventArgs val = (SettingChangedEventArgs)(object)((e is SettingChangedEventArgs) ? e : null);
			if (val != null && val.ChangedSetting.Definition.Key == KeyboardShortcutExampleKey)
			{
				KeyboardShortcut val2 = (KeyboardShortcut)val.ChangedSetting.BoxedValue;
			}
		}
	}
}
namespace JustSitDown.Patches
{
	[HarmonyPatch(typeof(Player))]
	internal class PlayerPatches
	{
		[HarmonyPatch("Init")]
		[HarmonyPrefix]
		public static bool Awake_Prefix(Player __instance)
		{
			if ((Object)(object)JustSitDownPlugin.player == (Object)null)
			{
				JustSitDownPlugin.player = __instance;
			}
			JustSitDownPlugin.Log.LogInfo((object)"In Player Awake method Prefix.");
			return true;
		}

		[HarmonyPatch("Awake")]
		[HarmonyPostfix]
		public static void Awake_Postfix(Player __instance)
		{
			JustSitDownPlugin.Log.LogInfo((object)"In Player Awake method Postfix.");
		}
	}
}