Decompiled source of Random Metal Sheet Weight v1.1.0

RMSW.dll

Decompiled 6 months ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using RMSW.Patches;
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("RMSW")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("RMSW")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("e4121de3-f9ae-4852-9df5-c6adc2bdd61f")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace RMSW
{
	[BepInPlugin("RZOR.RMSW", "Random Metal Sheet Weight", "1.1.0")]
	public class RMSWBase : BaseUnityPlugin
	{
		public class Config
		{
			public static ConfigEntry<int> subtract;

			public static ConfigEntry<int> add;

			public Config(ConfigFile cfg)
			{
				subtract = cfg.Bind<int>("General", "MinimumWeight", 9, "This is the lowest weight the metal sheet can be");
				add = cfg.Bind<int>("General", "MaximumWeight", 22, "This is the highest weight the metal sheet can be");
			}
		}

		private const string modGUID = "RZOR.RMSW";

		private const string modName = "Random Metal Sheet Weight";

		private const string modVersion = "1.1.0";

		private readonly Harmony harmony = new Harmony("RZOR.RMSW");

		private static RMSWBase Instance;

		internal ManualLogSource mls;

		public static Config MyConfig { get; internal set; }

		private void Awake()
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Expected O, but got Unknown
			MyConfig = new Config(((BaseUnityPlugin)this).Config);
			MethodInfo methodInfo = AccessTools.DeclaredMethod(typeof(GrabbableObject), "Start", (Type[])null, (Type[])null);
			MethodInfo methodInfo2 = AccessTools.DeclaredMethod(typeof(ItemPatch), "GrabbableObjectStart", (Type[])null, (Type[])null);
			harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		}
	}
}
namespace RMSW.Patches
{
	internal class ItemPatch
	{
		internal static void GrabbableObjectStart(GrabbableObject __instance)
		{
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_028f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0294: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ca: Unknown result type (might be due to invalid IL or missing references)
			if (((Object)__instance.itemProperties).name == "MetalSheet")
			{
				Random random = new Random();
				int value = RMSWBase.Config.subtract.Value;
				int value2 = RMSWBase.Config.add.Value;
				float num = random.Next(value, value2 + 1);
				num /= 100f;
				Item val = ScriptableObject.CreateInstance<Item>();
				val.allowDroppingAheadOfPlayer = __instance.itemProperties.allowDroppingAheadOfPlayer;
				val.automaticallySetUsingPower = __instance.itemProperties.automaticallySetUsingPower;
				val.batteryUsage = __instance.itemProperties.batteryUsage;
				val.canBeGrabbedBeforeGameStart = __instance.itemProperties.canBeGrabbedBeforeGameStart;
				val.canBeInspected = __instance.itemProperties.canBeInspected;
				val.creditsWorth = __instance.itemProperties.creditsWorth;
				val.dropSFX = __instance.itemProperties.dropSFX;
				val.floorYOffset = __instance.itemProperties.floorYOffset;
				val.grabAnim = __instance.itemProperties.grabAnim;
				val.grabAnimationTime = __instance.itemProperties.grabAnimationTime;
				val.grabSFX = __instance.itemProperties.grabSFX;
				((Object)val).hideFlags = ((Object)__instance.itemProperties).hideFlags;
				val.highestSalePercentage = __instance.itemProperties.highestSalePercentage;
				val.holdButtonUse = __instance.itemProperties.holdButtonUse;
				val.isConductiveMetal = __instance.itemProperties.isConductiveMetal;
				val.isDefensiveWeapon = __instance.itemProperties.isDefensiveWeapon;
				val.isScrap = __instance.itemProperties.isScrap;
				val.itemIcon = __instance.itemProperties.itemIcon;
				val.itemId = __instance.itemProperties.itemId;
				val.itemIsTrigger = __instance.itemProperties.itemIsTrigger;
				val.itemName = __instance.itemProperties.itemName;
				val.itemSpawnsOnGround = __instance.itemProperties.itemSpawnsOnGround;
				val.lockedInDemo = __instance.itemProperties.lockedInDemo;
				val.materialVariants = __instance.itemProperties.materialVariants;
				val.maxValue = __instance.itemProperties.maxValue;
				val.meshOffset = __instance.itemProperties.meshOffset;
				val.meshVariants = __instance.itemProperties.meshVariants;
				val.minValue = __instance.itemProperties.minValue;
				((Object)val).name = ((Object)__instance.itemProperties).name;
				val.pocketAnim = __instance.itemProperties.pocketAnim;
				val.pocketSFX = __instance.itemProperties.pocketSFX;
				val.positionOffset = __instance.itemProperties.positionOffset;
				val.requiresBattery = __instance.itemProperties.requiresBattery;
				val.restingRotation = __instance.itemProperties.restingRotation;
				val.rotationOffset = __instance.itemProperties.rotationOffset;
				val.saveItemVariable = __instance.itemProperties.saveItemVariable;
				val.spawnPositionTypes = __instance.itemProperties.spawnPositionTypes;
				val.spawnPrefab = __instance.itemProperties.spawnPrefab;
				val.syncDiscardFunction = __instance.itemProperties.syncDiscardFunction;
				val.syncGrabFunction = __instance.itemProperties.syncGrabFunction;
				val.syncInteractLRFunction = __instance.itemProperties.syncInteractLRFunction;
				val.syncUseFunction = __instance.itemProperties.syncUseFunction;
				val.throwAnim = __instance.itemProperties.throwAnim;
				val.throwSFX = __instance.itemProperties.throwSFX;
				val.toolTips = __instance.itemProperties.toolTips;
				val.twoHanded = __instance.itemProperties.twoHanded;
				val.twoHandedAnimation = __instance.itemProperties.twoHandedAnimation;
				val.usableInSpecialAnimations = __instance.itemProperties.usableInSpecialAnimations;
				val.useAnim = __instance.itemProperties.useAnim;
				val.verticalOffset = __instance.itemProperties.verticalOffset;
				val.weight = 1f + num;
				__instance.itemProperties = val;
			}
		}
	}
}