Decompiled source of FlametalOreVeinWontSink v1.0.0

FlametalOreVeinWontSink.dll

Decompiled 7 months ago
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Jotunn.Utils;
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("FlametalOreVeinWontSink")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("FlametalOreVeinWontSink")]
[assembly: AssemblyCopyright("Copyright ©  2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("e3243d22-4307-4008-ba36-9f326008cde5")]
[assembly: AssemblyFileVersion("0.0.1.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.1.0")]
namespace FlametalOreVeinWontSink;

public class Configs
{
	public static ConfigEntry<bool> AffectFlametalOreVeins;

	public static ConfigEntry<bool> AffectLeviathans;

	public static ConfigurationManagerAttributes IsAdminOnly = new ConfigurationManagerAttributes
	{
		IsAdminOnly = true
	};

	public static void SetupConfigs(ConfigFile config)
	{
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_0030: Expected O, but got Unknown
		//IL_005a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0064: Expected O, but got Unknown
		AffectFlametalOreVeins = config.Bind<bool>("General", GenerateConfigKey("AffectFlametalOreVeins"), true, new ConfigDescription("Prevent flametal ore veins from sinking.", (AcceptableValueBase)null, new object[1] { IsAdminOnly }));
		AffectLeviathans = config.Bind<bool>("General", GenerateConfigKey("AffectLeviathans"), false, new ConfigDescription("Prevent leviathans from sinking.", (AcceptableValueBase)null, new object[1] { IsAdminOnly }));
	}

	public static string GenerateConfigKey(string key)
	{
		return GenerateConfigKey(key, null);
	}

	public static string GenerateConfigKey(string key, string unit)
	{
		key = string.Concat(key.Select((char x) => char.IsUpper(x) ? (" " + x) : x.ToString())).TrimStart(new char[1] { ' ' });
		if (!string.IsNullOrEmpty(unit))
		{
			key += $" ({unit})";
		}
		return key;
	}
}
[BepInPlugin("FlametalOreVeinWontSink", "FlametalOreVeinWontSink", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
internal class FlametalOreVeinWontSink : BaseUnityPlugin
{
	[HarmonyPatch(typeof(Leviathan), "Awake")]
	public static class Leviathan_Awake_Patch
	{
		public static void Postfix(Leviathan __instance, ref float ___m_hitReactionChance)
		{
			if (Configs.AffectFlametalOreVeins.Value && ((Object)((Component)__instance).gameObject).name.StartsWith("LeviathanLava"))
			{
				___m_hitReactionChance = 0f;
			}
			if (Configs.AffectLeviathans.Value && ((Object)((Component)__instance).gameObject).name.StartsWith("Leviathan") && !((Object)((Component)__instance).gameObject).name.StartsWith("LeviathanLava"))
			{
				___m_hitReactionChance = 0f;
			}
		}
	}

	public const string PluginGUID = "FlametalOreVeinWontSink";

	public const string PluginName = "FlametalOreVeinWontSink";

	public const string PluginVersion = "1.0.0";

	private static Harmony harmony;

	private void Awake()
	{
		Configs.SetupConfigs(((BaseUnityPlugin)this).Config);
		harmony = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "FlametalOreVeinWontSink");
	}

	private void OnDestroy()
	{
		Harmony obj = harmony;
		if (obj != null)
		{
			obj.UnpatchSelf();
		}
	}
}