Decompiled source of DogHaus Drinks v1.0.6

plugins/DogHausDrinks.dll

Decompiled 4 days ago
using System;
using System.Reflection;
using System.Runtime.CompilerServices;
using BepInEx;
using BepInEx.Logging;
using DogHausBalance;
using DogHausDrinks;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: AssemblyVersion("0.0.0.0")]
namespace DogHausDrinksMod;

[HarmonyPatch(typeof(ObjectDB), "Awake")]
internal static class ObjectDB_Awake_DrinksReg
{
	private static bool Prepare()
	{
		return AccessTools.Method(typeof(ObjectDB), "Awake", (Type[])null, (Type[])null) != null;
	}

	[HarmonyPriority(200)]
	private static void Postfix(ObjectDB __instance)
	{
		try
		{
			ModSplit.Shell("doghaus.drinks", DrinksPlugin.Log, __instance, (Action)delegate
			{
				FunDrinks.Apply(__instance);
			});
		}
		catch (Exception ex)
		{
			DrinksPlugin.Log.LogWarning((object)("Fun drinks could not be registered (DogHausTweaks will): " + ex));
		}
	}
}
[HarmonyPatch(typeof(ObjectDB), "CopyOtherDB")]
internal static class ObjectDB_CopyOtherDB_DrinksReg
{
	private static bool Prepare()
	{
		return AccessTools.Method(typeof(ObjectDB), "CopyOtherDB", (Type[])null, (Type[])null) != null;
	}

	[HarmonyPriority(200)]
	private static void Postfix(ObjectDB __instance)
	{
		try
		{
			ModSplit.Shell("doghaus.drinks", DrinksPlugin.Log, __instance, (Action)delegate
			{
				FunDrinks.Apply(__instance);
			});
		}
		catch (Exception ex)
		{
			DrinksPlugin.Log.LogWarning((object)("Fun drinks could not be registered (DogHausTweaks will): " + ex));
		}
	}
}
[HarmonyPatch(typeof(ZNetScene), "Awake")]
internal static class ZNetScene_Awake_DrinksReg
{
	private static bool Prepare()
	{
		return AccessTools.Method(typeof(ZNetScene), "Awake", (Type[])null, (Type[])null) != null;
	}

	[HarmonyPriority(200)]
	private static void Postfix(ZNetScene __instance)
	{
		try
		{
			ModSplit.Shell("doghaus.drinks", DrinksPlugin.Log, (ObjectDB)null, (Action)delegate
			{
				FunDrinks.RegisterScene(__instance);
				if ((Object)(object)ObjectDB.instance != (Object)null)
				{
					FunDrinks.Apply(ObjectDB.instance);
				}
			});
		}
		catch (Exception ex)
		{
			DrinksPlugin.Log.LogWarning((object)("Fun drinks could not be registered (DogHausTweaks will): " + ex));
		}
	}
}
[HarmonyPatch]
internal static class ItemData_GetTooltip_DrinksLabel
{
	private static bool Prepare()
	{
		return ModSplit.TooltipMethod() != null;
	}

	private static MethodBase TargetMethod()
	{
		return ModSplit.TooltipMethod();
	}

	[HarmonyPriority(0)]
	private static void Postfix(ItemData __0, bool __2, ref string __result)
	{
		ModSplit.LabelTooltip("doghaus.drinks", __0, __2, ref __result);
	}
}
[BepInDependency("doghaus.tweaks", "2.0.3")]
[BepInPlugin("doghaus.drinks", "DogHaus Drinks", "1.0.6")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class DrinksPlugin : BaseUnityPlugin
{
	public const string GUID = "doghaus.drinks";

	public const string NAME = "DogHaus Drinks";

	public const string VERSION = "1.0.6";

	internal const string TweaksGuid = "doghaus.tweaks";

	internal const string TweaksMinVersion = "2.0.3";

	internal static ManualLogSource Log;

	private void Awake()
	{
		//IL_004e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0054: Expected O, but got Unknown
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0065: Expected O, but got Unknown
		Log = ((BaseUnityPlugin)this).Logger;
		if (Kill.Off("doghaus.drinks", ((BaseUnityPlugin)this).Logger))
		{
			((Behaviour)this).enabled = false;
			return;
		}
		if (Kill.IsOff("doghaus.qualityoflife"))
		{
			((BaseUnityPlugin)this).Logger.LogWarning((object)"doghaus.qualityoflife is switched off in DogHausTweaks.disable.txt - DogHaus Drinks stands down with it (no drinks registered).");
			((Behaviour)this).enabled = false;
			return;
		}
		Harmony h = new Harmony("doghaus.drinks");
		HookReport val = new HookReport(((BaseUnityPlugin)this).Logger, "DogHaus Drinks");
		Register(h, val, typeof(ObjectDB_Awake_DrinksReg));
		Register(h, val, typeof(ObjectDB_CopyOtherDB_DrinksReg));
		Register(h, val, typeof(ZNetScene_Awake_DrinksReg));
		Register(h, val, typeof(ItemData_GetTooltip_DrinksLabel));
		val.Summary();
		((BaseUnityPlugin)this).Logger.LogInfo((object)("DogHaus Drinks 1.0.6 loaded: registers the DogHaus fun drinks (code in DogHausTweaks; label line " + (ModSplit.WmatLoaded ? "from WhichModAddedThis" : "printed by this plugin") + ")."));
	}

	private static void Register(Harmony h, HookReport hooks, Type patch)
	{
		try
		{
			hooks.Patch(h, patch);
		}
		catch (Exception ex)
		{
			hooks.Failed(patch, ex);
		}
	}
}