Decompiled source of ActualSizeStat v1.0.0

ActualSizeStat.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 ActualSizeStat.Modules;
using Assets.Scripts.Actors.Player;
using Assets.Scripts.Inventory__Items__Pickups.Stats;
using Assets.Scripts.Menu.Shop;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("ActualSizeStat")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+482148b3d2dcc1f478390ef4bfc15ea61672db56")]
[assembly: AssemblyProduct("Actual Size Stat")]
[assembly: AssemblyTitle("ActualSizeStat")]
[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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace ActualSizeStat
{
	public class Metadata
	{
		public const string PLUGIN_GUID = "Oric.Megabonk.ActualSizeStat";

		public const string PLUGIN_SHORT_GUID = "ActualSizeStat";

		public const string PLUGIN_NAME = "Actual Size Tome";

		public const string PLUGIN_VERSION = "1.0.0";

		public const string PLUGIN_PROCESS_NAME = "Megabonk.exe";
	}
	[BepInPlugin("Oric.Megabonk.ActualSizeStat", "Actual Size Tome", "1.0.0")]
	[BepInProcess("Megabonk.exe")]
	public class Plugin : BasePlugin
	{
		internal static ManualLogSource Log;

		public override void Load()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			Log = ((BasePlugin)this).Log;
			ManualLogSource log = Log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(18, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Plugin ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("ActualSizeStat");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is loaded!");
			}
			log.LogInfo(val);
			Harmony.CreateAndPatchAll(typeof(KillLeaderboard), "Oric.Megabonk.ActualSizeStat");
			Harmony.CreateAndPatchAll(typeof(Scale2SizeStat), "Oric.Megabonk.ActualSizeStat");
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "ActualSizeStat";

		public const string PLUGIN_NAME = "Actual Size Stat";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace ActualSizeStat.Modules
{
	public class KillLeaderboard : Plugin
	{
		[HarmonyPrepare]
		private static void init()
		{
			Plugin.Log.LogInfo((object)"Leaderboard uploads disabled!");
		}

		[HarmonyPatch(typeof(SteamLeaderboardsManagerNew), "UploadLeaderboardScore")]
		[HarmonyPrefix]
		private static bool KillLeaderBoard()
		{
			Plugin.Log.LogInfo((object)"Prevented Leaderboard Upload!");
			return false;
		}

		[HarmonyPatch(typeof(SteamLeaderboardsManagerNew), "QueueLeaderboardUpload")]
		[HarmonyPrefix]
		private static bool KillLeaderBoardQueue()
		{
			Plugin.Log.LogInfo((object)"Prevented Leaderboard Queue!");
			return false;
		}
	}
	public class Scale2SizeStat : Plugin
	{
		private static MyPlayer _player;

		private static PlayerCamera _camera;

		private static DetectPickups _detectPickups;

		private static float _baseHeight;

		private static float _basePush;

		private static float _baseInteractRange;

		private static Vector3 _baseScale;

		private static Vector3 _baseOffset;

		private static ConfigEntry<float> _scaleFactor;

		private static ConfigFile _config;

		[HarmonyPrepare]
		private static void init()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Expected O, but got Unknown
			_config = new ConfigFile(Utility.CombinePaths(new string[2]
			{
				Paths.ConfigPath,
				"ActualSizeStat.cfg"
			}), true);
			_scaleFactor = _config.Bind<float>("General", "Scale Factor", 1f, "A multiplier to how much the size stat affects your characters size. (0 should act as if the mod is not installed)");
		}

		[HarmonyPatch(typeof(MyPlayer), "Spawn")]
		[HarmonyPostfix]
		private static void PatchSpawn()
		{
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Expected O, but got Unknown
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			_player = MyPlayer.Instance;
			_camera = PlayerCamera.Instance;
			_detectPickups = Object.FindObjectOfType<DetectPickups>();
			Plugin.Log.LogInfo((object)"Loaded Instances for run");
			_baseHeight = _player.playerMovement.playerHeight;
			_basePush = _player.playerMovement.pushMultiplier;
			_baseInteractRange = _player.playerInput.detectInteractables.interactableRange;
			_baseScale = ((Component)_player.playerRenderer).transform.localScale;
			_baseOffset = _camera.offset3rdPerson;
			((Component)_detectPickups).transform.parent = ((Component)_player.feet).transform;
			ManualLogSource log = Plugin.Log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(32, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Bound Pickup detection to feet: ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Vector3>(((Component)_detectPickups).transform.position);
			}
			log.LogInfo(val);
			UpdateSize();
		}

		[HarmonyPatch(typeof(PlayerStatsNew), "UpdateStat")]
		[HarmonyPostfix]
		private static void PatchStatChange()
		{
			UpdateSize();
		}

		private static void UpdateSize()
		{
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: 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_00f9: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)_player == (Object)null))
			{
				float num = Mathf.Clamp((_player.inventory.playerStats.GetStat((EStat)9) - 1f) * _scaleFactor.Value + 1f, 0.1f, float.MaxValue);
				((Component)_player.playerMovement).transform.localScale = _baseScale * num;
				((Component)_player.feet).transform.localScale = _baseScale / num;
				((Component)_player.arrow).transform.localScale = _baseScale / num;
				_player.playerMovement.playerScale = _baseScale * num;
				_player.playerMovement.playerHeight = _baseHeight * num;
				_player.playerMovement.pushMultiplier = _basePush / num;
				_camera.offset3rdPerson = _baseOffset * num;
				_player.playerInput.detectInteractables.interactableRange = _baseInteractRange * num;
			}
		}
	}
}