Decompiled source of Stat Changer Simple Edition v1.0.0

Mods/Stat_Changer__Simple_Edition_.dll

Decompiled 2 days ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BoneLib;
using BoneLib.BoneMenu;
using MelonLoader;
using Microsoft.CodeAnalysis;
using Stat_Changer__Simple_Edition_;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(Core), "Stat Changer (Simple Edition)", "1.0.0", "Gorillavr35", null)]
[assembly: MelonGame("Stress Level Zero", "BONELAB")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("Stat_Changer__Simple_Edition_")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Stat_Changer__Simple_Edition_")]
[assembly: AssemblyTitle("Stat_Changer__Simple_Edition_")]
[assembly: NeutralResourcesLanguage("en-US")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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 Stat_Changer__Simple_Edition_
{
	public class Core : MelonMod
	{
		private Vector3 originalScale = Vector3.one;

		private bool hasSavedScale = false;

		public override void OnInitializeMelon()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			((MelonBase)this).LoggerInstance.Msg("Initialized.");
			Page val = Page.Root.CreatePage("Stat Changer", Color.green, 0, true);
			val.CreateFunction("Speed: +1.0", Color.cyan, (Action)delegate
			{
				ModifyStat("speedMultiplier", 1f);
			});
			val.CreateFunction("Speed: -1.0", Color.blue, (Action)delegate
			{
				ModifyStat("speedMultiplier", -1f);
			});
			val.CreateFunction("Jump: +1.0", Color.yellow, (Action)delegate
			{
				ModifyStat("jumpMultiplier", 1f);
			});
			val.CreateFunction("Jump: -1.0", Color.yellow, (Action)delegate
			{
				ModifyStat("jumpMultiplier", -1f);
			});
			val.CreateFunction("Strength: +1.0", Color.red, (Action)delegate
			{
				ModifyStat("strengthUpper", 1f);
			});
			val.CreateFunction("Strength: -1.0", Color.red, (Action)delegate
			{
				ModifyStat("strengthUpper", -1f);
			});
			val.CreateFunction("Mass: +20.0", Color.grey, (Action)delegate
			{
				ModifyStat("mass", 20f);
			});
			val.CreateFunction("Mass: -20.0", Color.black, (Action)delegate
			{
				ModifyStat("mass", -20f);
			});
			val.CreateFunction("Scale: +0.2", Color.magenta, (Action)delegate
			{
				//IL_0013: Unknown result type (might be due to invalid IL or missing references)
				//IL_0027: Unknown result type (might be due to invalid IL or missing references)
				//IL_002c: Unknown result type (might be due to invalid IL or missing references)
				CheckAndSaveOriginalScale();
				Transform transform = ((Component)Player.PhysicsRig).transform;
				transform.localScale += new Vector3(0.2f, 0.2f, 0.2f);
				((MelonBase)this).LoggerInstance.Msg("Scale increased!");
			});
			val.CreateFunction("Scale: -0.2", Color.magenta, (Action)delegate
			{
				//IL_0013: Unknown result type (might be due to invalid IL or missing references)
				//IL_0027: Unknown result type (might be due to invalid IL or missing references)
				//IL_002c: Unknown result type (might be due to invalid IL or missing references)
				CheckAndSaveOriginalScale();
				Transform transform = ((Component)Player.PhysicsRig).transform;
				transform.localScale -= new Vector3(0.2f, 0.2f, 0.2f);
				((MelonBase)this).LoggerInstance.Msg("Scale decreased!");
			});
			val.CreateFunction("RESET ALL STATS", Color.white, (Action)delegate
			{
				//IL_0059: Unknown result type (might be due to invalid IL or missing references)
				//IL_0040: Unknown result type (might be due to invalid IL or missing references)
				SetStatAbsolute("speedMultiplier", 1f);
				SetStatAbsolute("jumpMultiplier", 1f);
				ResetToDefaultAvatarStats();
				if (hasSavedScale)
				{
					((Component)Player.PhysicsRig).transform.localScale = originalScale;
				}
				else
				{
					((Component)Player.PhysicsRig).transform.localScale = Vector3.one;
				}
				((MelonBase)this).LoggerInstance.Msg("All stats reset to normal!");
			});
		}

		private void ModifyStat(string fieldName, float amount)
		{
			foreach (Component component in ((Component)Player.RigManager).GetComponents<Component>())
			{
				FieldInfo field = ((object)component).GetType().GetField(fieldName);
				if (field != null)
				{
					float num = (float)field.GetValue(component);
					field.SetValue(component, num + amount);
					((MelonBase)this).LoggerInstance.Msg($"{fieldName} changed by {amount}!");
					break;
				}
			}
		}

		private void SetStatAbsolute(string fieldName, float targetValue)
		{
			foreach (Component component in ((Component)Player.RigManager).GetComponents<Component>())
			{
				FieldInfo field = ((object)component).GetType().GetField(fieldName);
				if (field != null)
				{
					field.SetValue(component, targetValue);
					break;
				}
			}
		}

		private void ResetToDefaultAvatarStats()
		{
			if ((Object)(object)Player.RigManager.avatar != (Object)null)
			{
				SetStatAbsolute("strengthUpper", Player.RigManager.avatar.strengthUpper);
				SetStatAbsolute("mass", Player.RigManager.avatar.massTotal);
			}
		}

		private void CheckAndSaveOriginalScale()
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			if (!hasSavedScale && (Object)(object)Player.PhysicsRig != (Object)null)
			{
				originalScale = ((Component)Player.PhysicsRig).transform.localScale;
				hasSavedScale = true;
			}
		}
	}
}