Decompiled source of ScavengerOfPharloom v1.0.2

ScavengerOfPharloom.dll

Decompiled 5 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using DanielSteginkUtils.Utilities;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using ScavengerOfPharloom.Settings;
using TeamCherry.Localization;
using TeamCherry.SharedUtils;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("ScavengerOfPharloom")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("This is a library of custom helpers and logic for Hollow Knight: Silksong mods.")]
[assembly: AssemblyFileVersion("1.0.2.0")]
[assembly: AssemblyInformationalVersion("1.0.2+8e28d21b4d3cab3fb7ef0b89f03358a6b6ae5549")]
[assembly: AssemblyProduct("ScavengerOfPharloom")]
[assembly: AssemblyTitle("ScavengerOfPharloom")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/danielstegink/Silksong.DanielSteginkUtils")]
[assembly: NeutralResourcesLanguage("EN")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.2.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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[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 BepInEx
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class BepInAutoPluginAttribute : Attribute
	{
		public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace BepInEx.Preloader.Core.Patching
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class PatcherAutoPluginAttribute : Attribute
	{
		public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace ScavengerOfPharloom
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("io.github.danielstegink.scavengerofpharloom", "ScavengerOfPharloom", "1.0.2")]
	public class ScavengerOfPharloom : BaseUnityPlugin
	{
		public const string Id = "io.github.danielstegink.scavengerofpharloom";

		public static string Name => "ScavengerOfPharloom";

		public static string Version => "1.0.2";

		private void Awake()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			new Harmony("io.github.danielstegink.scavengerofpharloom").PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)("Plugin " + Name + " (io.github.danielstegink.scavengerofpharloom) has loaded!"));
		}

		private void Start()
		{
			ConfigSettings.Initialize(((BaseUnityPlugin)this).Config);
		}
	}
}
namespace ScavengerOfPharloom.Settings
{
	public static class ConfigSettings
	{
		public static ConfigEntry<bool> setShardDrop;

		public static ConfigEntry<bool> setRosaryDrop;

		public static ConfigEntry<bool> setSilkDrop;

		public static void Initialize(ConfigFile config)
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			LocalisedString val = default(LocalisedString);
			((LocalisedString)(ref val))..ctor("Mods.io.github.danielstegink.scavengerofpharloom", "SHARD_NAME");
			LocalisedString val2 = default(LocalisedString);
			((LocalisedString)(ref val2))..ctor("Mods.io.github.danielstegink.scavengerofpharloom", "SHARD_DESC");
			if (((LocalisedString)(ref val)).Exists && ((LocalisedString)(ref val2)).Exists)
			{
				setShardDrop = config.Bind<bool>("Modifier", LocalisedString.op_Implicit(val), true, LocalisedString.op_Implicit(val2));
			}
			else
			{
				setShardDrop = config.Bind<bool>("Modifier", "Shell Pots", true, "Allows pots, statues and more to drop shell shards");
			}
			LocalisedString val3 = default(LocalisedString);
			((LocalisedString)(ref val3))..ctor("Mods.io.github.danielstegink.scavengerofpharloom", "ROSARY_NAME");
			LocalisedString val4 = default(LocalisedString);
			((LocalisedString)(ref val4))..ctor("Mods.io.github.danielstegink.scavengerofpharloom", "ROSARY_DESC");
			if (((LocalisedString)(ref val3)).Exists && ((LocalisedString)(ref val4)).Exists)
			{
				setRosaryDrop = config.Bind<bool>("Modifier", LocalisedString.op_Implicit(val3), true, LocalisedString.op_Implicit(val4));
			}
			else
			{
				setRosaryDrop = config.Bind<bool>("Modifier", "Wealth of the Citadel", true, "Allows pots in the Citadel to drop rosaries");
			}
			LocalisedString val5 = default(LocalisedString);
			((LocalisedString)(ref val5))..ctor("Mods.io.github.danielstegink.scavengerofpharloom", "SILK_NAME");
			LocalisedString val6 = default(LocalisedString);
			((LocalisedString)(ref val6))..ctor("Mods.io.github.danielstegink.scavengerofpharloom", "SILK_DESC");
			if (((LocalisedString)(ref val5)).Exists && ((LocalisedString)(ref val6)).Exists)
			{
				setSilkDrop = config.Bind<bool>("Modifier", LocalisedString.op_Implicit(val5), true, LocalisedString.op_Implicit(val6));
			}
			else
			{
				setSilkDrop = config.Bind<bool>("Modifier", "Gratitude of the Silk Flies", true, "Allows Silk Flies to replenish Silk when freed");
			}
		}
	}
}
namespace ScavengerOfPharloom.Helpers
{
	[HarmonyPatch(typeof(Breakable), "Break")]
	public static class BreakPatch
	{
		[HarmonyPrefix]
		public static void Prefix(Breakable __instance, float flingAngleMin, float flingAngleMax, float impactMultiplier)
		{
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			Breakable __instance2 = __instance;
			if (ConfigSettings.setShardDrop.Value && new List<string> { "_skull_", "_pot_", "_cairn_", "bone_house_pieces_squat", "bone_house_breakable_point", "bone_house_breakable_mid", "barrel" }.Any((string x) => ((Object)((Component)__instance2).gameObject).name.ToLower().Contains(x)))
			{
				ClassIntegrations.SetField<Breakable>(__instance2, "shellShardDrops", (object)new MinMaxInt(0, 1), BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
			}
			if (ConfigSettings.setRosaryDrop.Value && new List<string> { "sc_break_extras_detail", "sc_break_pot" }.Any((string x) => ((Object)((Component)__instance2).gameObject).name.ToLower().Contains(x)))
			{
				ClassIntegrations.SetField<Breakable>(__instance2, "smallGeoDrops", (object)new MinMaxInt(0, 1), BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
			}
		}

		[HarmonyPostfix]
		public static void Postfix(Breakable __instance, float flingAngleMin, float flingAngleMax, float impactMultiplier)
		{
			if (ConfigSettings.setSilkDrop.Value)
			{
				if (((Object)((Component)__instance).gameObject).name.ToLower().Contains("lamp_pivot"))
				{
					HeroController.instance.AddSilk(3, false);
				}
				else if (((Object)((Component)__instance).gameObject).name.ToLower().Contains("lamp") && Random.Range(1, 101) <= 50)
				{
					HeroController.instance.SilkGain();
				}
			}
		}
	}
	[HarmonyPatch(typeof(HealthManager), "TakeDamage")]
	public static class EnemyTakeDamagePatch
	{
		[HarmonyPostfix]
		public static void Postfix(HealthManager __instance, HitInstance hitInstance)
		{
			if (ConfigSettings.setSilkDrop.Value && __instance.isDead && ((Object)((Component)__instance).gameObject).name.ToLower().Contains("automaton") && Random.Range(1, 101) <= 50)
			{
				HeroController.instance.SilkGain();
			}
		}
	}
}