Decompiled source of DSPFogDropTweak v0.0.1

DSPFogDropTweak.dll

Decompiled 2 months ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("DspFontPatcher")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("DspFontPatcher")]
[assembly: AssemblyCopyright("Copyright ©  2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("81DF3045-8007-4F6A-AAF6-903139D85B6C")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.0.0")]
[module: UnverifiableCode]
namespace DSPFogDropTweak;

[BepInPlugin("Appun.DSP.plugin.FogDropTweak", "DSPFogDropTweak", "0.0.1")]
[HarmonyPatch]
public class Main : BaseUnityPlugin
{
	public class LogManager
	{
		public static ManualLogSource Logger;
	}

	public static ConfigEntry<int> DropRatioMultiplier;

	public static ConfigEntry<int> DropCountMultiplier;

	public static ConfigEntry<bool> DisablePlanetDropCorrection;

	public void Awake()
	{
		DropRatioMultiplier = ((BaseUnityPlugin)this).Config.Bind<int>("General", "DropRatioMultiplier", 1, "Multiply the drop ratio.");
		DropCountMultiplier = ((BaseUnityPlugin)this).Config.Bind<int>("General", "DropCountMultiplier", 1, "Multiply  the drop count.");
		DisablePlanetDropCorrection = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "DisablePlanetDropCorrection", true, "Disable planet drop correction.");
		LogManager.Logger = ((BaseUnityPlugin)this).Logger;
		Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null);
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(ItemProto), "InitEnemyDropTables")]
	public static void ItemProto_InitEnemyDropTables_Postfix(ItemProto __instance)
	{
		ItemProto[] dataArray = ((ProtoSet<ItemProto>)(object)LDB.items).dataArray;
		for (int i = 0; i < dataArray.Length; i++)
		{
			int iD = ((Proto)dataArray[i]).ID;
			if (dataArray[i].EnemyDropRange.y > 5E-05f)
			{
				dataArray[i].EnemyDropRange.y *= DropRatioMultiplier.Value;
				ItemProto obj = dataArray[i];
				obj.EnemyDropCount *= (float)DropCountMultiplier.Value;
				ItemProto.enemyDropCountTable[iD] = dataArray[i].EnemyDropCount;
				if (DisablePlanetDropCorrection.Value)
				{
					ItemProto.enemyDropMaskTable[iD] = int.MaxValue;
				}
			}
		}
	}
}