Decompiled source of StackIncrease v0.4.0

StackIncrease.dll

Decompiled 8 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("StackIncrease")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Valheim-mod: ökar max-stackstorleken för stapelbara föremål")]
[assembly: AssemblyFileVersion("0.4.0.0")]
[assembly: AssemblyInformationalVersion("0.4.0")]
[assembly: AssemblyProduct("StackIncrease")]
[assembly: AssemblyTitle("StackIncrease")]
[assembly: AssemblyVersion("0.4.0.0")]
[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 StackIncrease
{
	[HarmonyPatch(typeof(ObjectDB), "UpdateRegisters")]
	public static class ObjectDB_UpdateRegisters_Patch
	{
		private static readonly HashSet<SharedData> AlreadyScaled = new HashSet<SharedData>();

		private static void Postfix(ObjectDB __instance)
		{
			int value = Plugin.StackMultiplier.Value;
			float value2 = Plugin.WeightMultiplier.Value;
			foreach (GameObject item in __instance.m_items)
			{
				ItemDrop component = item.GetComponent<ItemDrop>();
				if ((Object)(object)component == (Object)null)
				{
					continue;
				}
				SharedData shared = component.m_itemData.m_shared;
				if (shared != null && !AlreadyScaled.Contains(shared))
				{
					AlreadyScaled.Add(shared);
					if (shared.m_maxStackSize > 1)
					{
						shared.m_maxStackSize *= value;
						shared.m_weight *= value2;
					}
				}
			}
		}
	}
	[BepInPlugin("toxo.stackincrease", "Stack Increase", "0.4.0")]
	public class Plugin : BaseUnityPlugin
	{
		public const string PluginGUID = "toxo.stackincrease";

		public const string PluginName = "Stack Increase";

		public const string PluginVersion = "0.4.0";

		public static ConfigEntry<int> StackMultiplier;

		public static ConfigEntry<float> WeightMultiplier;

		private Harmony harmony;

		private void Awake()
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Expected O, but got Unknown
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Expected O, but got Unknown
			StackMultiplier = ((BaseUnityPlugin)this).Config.Bind<int>("General", "StackMultiplier", 10, new ConfigDescription("Hur mycket max-stackstorleken för stapelbara föremål multipliceras med. Föremål som redan bara kan bära 1 (vapen, rustning m.m.) påverkas inte. Kräver omstart av spelet för att en ändring ska slå igenom.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 1000), Array.Empty<object>()));
			WeightMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("General", "WeightMultiplier", 0.2f, new ConfigDescription("Vikten för samma stapelbara material multipliceras med detta (0.2 = 20% av originalvikten, dvs 80% lättare). Föremål med maxstack 1 (vapen, rustning m.m.) påverkas inte. Kräver omstart av spelet för att en ändring ska slå igenom.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.01f, 2f), Array.Empty<object>()));
			harmony = new Harmony("toxo.stackincrease");
			harmony.PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Stack Increase v0.4.0 laddad!");
		}

		private void OnDestroy()
		{
			Harmony obj = harmony;
			if (obj != null)
			{
				obj.UnpatchSelf();
			}
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "StackIncrease";

		public const string PLUGIN_NAME = "StackIncrease";

		public const string PLUGIN_VERSION = "0.4.0";
	}
}