Decompiled source of BetterHeldObjectSize v1.0.1

BepInEx/plugins/BetterHeldObjectSize.dll

Decompiled 3 weeks ago
using System;
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 GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("overfirec")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Overfirec_BetterHeldObjectSize")]
[assembly: AssemblyTitle("BetterHeldObjectSize")]
[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 BetterHeldObjectSize
{
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "BetterHeldObjectSize";

		public const string PLUGIN_NAME = "Overfirec_BetterHeldObjectSize";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace BetterHeldObject
{
	[BepInPlugin("BetterHeldObjectSize", "Overfirec_BetterHeldObjectSize", "1.0.0")]
	public class BetterHeldObjectPluginReg : BaseUnityPlugin
	{
		internal static BetterHeldObjectPluginReg Instance { get; private set; }

		internal static ManualLogSource Logger { get; private set; }

		internal static Harmony? Harmony { get; set; }

		private void Awake()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Expected O, but got Unknown
			Logger = Logger.CreateLogSource("BetterHeldObjectSize");
			Harmony = new Harmony("BetterHeldObjectSize");
			Instance = this;
			Harmony.PatchAll();
			Log("BetterHeldObjectSize v1.0.0 has loaded!", (LogLevel)16);
		}

		internal static void Log(string message, LogLevel level = 16)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			Logger.Log(level, (object)message);
		}
	}
	[HarmonyPatch(typeof(HUDManager))]
	public class HUDManagerPatch
	{
		private static Vector3? localScale;

		private static bool showtips;

		internal static PlayerControllerB Player { get; set; }

		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		public static void UpdatePatch()
		{
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)Player == (Object)null)
			{
				Player = GameNetworkManager.Instance.localPlayerController;
			}
			else if (Player.isHoldingObject && Player.currentlyHeldObjectServer.itemProperties.isScrap)
			{
				if (!showtips)
				{
					HUDManager.Instance.DisplayTip("BetterHeldObjectSize", "Press J to make bigger, K to make smaller(When you holding object)", false, false, "LC_Tip1");
					showtips = true;
				}
				localScale = ((Component)Player.currentlyHeldObjectServer).gameObject.transform.localScale;
				Vector3 val2 = default(Vector3);
				if (((ButtonControl)Keyboard.current.jKey).wasPressedThisFrame)
				{
					BetterHeldObjectPluginReg.Log("bigger", (LogLevel)16);
					Vector3? val = localScale;
					((Vector3)(ref val2))..ctor(0.05f, 0.05f, 0.05f);
					localScale = (val.HasValue ? new Vector3?(val.GetValueOrDefault() + val2) : null);
				}
				if (((ButtonControl)Keyboard.current.kKey).wasPressedThisFrame)
				{
					BetterHeldObjectPluginReg.Log("smaller", (LogLevel)16);
					Vector3? val = localScale;
					((Vector3)(ref val2))..ctor(0.05f, 0.05f, 0.05f);
					localScale = (val.HasValue ? new Vector3?(val.GetValueOrDefault() - val2) : null);
				}
				_ = ((ButtonControl)Keyboard.current.lKey).wasPressedThisFrame;
				Vector3 value = localScale.Value;
				value.x = Mathf.Clamp(value.x, 0f, 1f);
				value.y = Mathf.Clamp(value.y, 0f, 1f);
				value.z = Mathf.Clamp(value.z, 0f, 1f);
				localScale = value;
				((Component)Player.currentlyHeldObjectServer).gameObject.transform.localScale = localScale.Value;
			}
		}
	}
}
namespace BetterHeldObject.PluginInfo
{
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "BetterHeldObjectSize";

		public const string PLUGIN_NAME = "Overfirec_BetterHeldObjectSize";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}