Decompiled source of DogHaus Architecture v1.0.6

plugins/DogHausArchitecture.dll

Decompiled 4 days ago
using System;
using System.Reflection;
using System.Runtime.CompilerServices;
using BepInEx;
using BepInEx.Logging;
using DogHausArch;
using DogHausBalance;
using DogHausLonghouse;
using DogHausOctagon;
using DogHausQoL;
using HarmonyLib;
using UnityEngine;

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

[HarmonyPatch(typeof(ZNetScene), "Awake")]
internal static class ZNetScene_Awake_ArchLadder
{
	[HarmonyBefore(new string[] { "doghaus.piecebalance" })]
	[HarmonyPriority(0)]
	[HarmonyAfter(new string[] { "balrond.astafaraios.BalrondFurnitureReborn" })]
	private static void Postfix(ZNetScene __instance)
	{
		try
		{
			ModSplit.Shell("doghaus.architecture", ArchitecturePlugin.Log, (ObjectDB)null, (Action)delegate
			{
				LadderSix.Register(__instance);
			});
		}
		catch (Exception ex)
		{
			ArchitecturePlugin.Log.LogWarning((object)("Wood Ladder 6m could not be registered (DogHausTweaks will): " + ex));
		}
	}
}
[HarmonyPatch(typeof(ObjectDB), "Awake")]
internal static class ObjectDB_Awake_ArchLadder
{
	[HarmonyPriority(0)]
	[HarmonyAfter(new string[] { "balrond.astafaraios.BalrondFurnitureReborn" })]
	private static void Postfix()
	{
		try
		{
			ModSplit.Shell("doghaus.architecture", ArchitecturePlugin.Log, (ObjectDB)null, (Action)delegate
			{
				LadderSix.Again();
			});
		}
		catch (Exception ex)
		{
			Quiet.Once("Architecture: LadderSix ObjectDB.Awake", ex);
		}
	}
}
[HarmonyPatch(typeof(ObjectDB), "CopyOtherDB")]
internal static class ObjectDB_CopyOtherDB_ArchLadder
{
	[HarmonyPriority(0)]
	[HarmonyAfter(new string[] { "balrond.astafaraios.BalrondFurnitureReborn" })]
	private static void Postfix()
	{
		try
		{
			ModSplit.Shell("doghaus.architecture", ArchitecturePlugin.Log, (ObjectDB)null, (Action)delegate
			{
				LadderSix.Again();
			});
		}
		catch (Exception ex)
		{
			Quiet.Once("Architecture: LadderSix ObjectDB.CopyOtherDB", ex);
		}
	}
}
[HarmonyPatch(typeof(Player), "OnSpawned")]
internal static class Player_OnSpawned_ArchLadder
{
	private static void Postfix(Player __instance)
	{
		if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer)
		{
			return;
		}
		try
		{
			ModSplit.Shell("doghaus.architecture", ArchitecturePlugin.Log, (ObjectDB)null, (Action)delegate
			{
				LadderSix.Again();
			});
		}
		catch (Exception ex)
		{
			Quiet.Once("Architecture: LadderSix Player.OnSpawned", ex);
		}
	}
}
[HarmonyPatch(typeof(ZNetScene), "Awake")]
internal static class ZNetScene_Awake_ArchGate
{
	[HarmonyPriority(0)]
	[HarmonyBefore(new string[] { "doghaus.piecebalance" })]
	[HarmonyAfter(new string[] { "blacks7ar.FineWoodBuildPieces" })]
	private static void Postfix(ZNetScene __instance)
	{
		try
		{
			ModSplit.Shell("doghaus.architecture", ArchitecturePlugin.Log, (ObjectDB)null, (Action)delegate
			{
				HeavyGateWood.Register(__instance);
			});
		}
		catch (Exception ex)
		{
			ArchitecturePlugin.Log.LogWarning((object)("Heavy Wood Gate could not be registered (DogHausTweaks will): " + ex));
		}
	}
}
[HarmonyPatch(typeof(ObjectDB), "Awake")]
internal static class ObjectDB_Awake_ArchGate
{
	[HarmonyAfter(new string[] { "blacks7ar.FineWoodBuildPieces" })]
	[HarmonyPriority(0)]
	private static void Postfix()
	{
		try
		{
			ModSplit.Shell("doghaus.architecture", ArchitecturePlugin.Log, (ObjectDB)null, (Action)delegate
			{
				HeavyGateWood.Again();
			});
		}
		catch (Exception ex)
		{
			Quiet.Once("Architecture: HeavyGateWood ObjectDB.Awake", ex);
		}
	}
}
[HarmonyPatch(typeof(ObjectDB), "CopyOtherDB")]
internal static class ObjectDB_CopyOtherDB_ArchGate
{
	[HarmonyPriority(0)]
	[HarmonyAfter(new string[] { "blacks7ar.FineWoodBuildPieces" })]
	private static void Postfix()
	{
		try
		{
			ModSplit.Shell("doghaus.architecture", ArchitecturePlugin.Log, (ObjectDB)null, (Action)delegate
			{
				HeavyGateWood.Again();
			});
		}
		catch (Exception ex)
		{
			Quiet.Once("Architecture: HeavyGateWood CopyOtherDB", ex);
		}
	}
}
[HarmonyPatch(typeof(Player), "OnSpawned")]
internal static class Player_OnSpawned_ArchGate
{
	private static void Postfix()
	{
		try
		{
			ModSplit.Shell("doghaus.architecture", ArchitecturePlugin.Log, (ObjectDB)null, (Action)delegate
			{
				HeavyGateWood.Again();
			});
		}
		catch (Exception ex)
		{
			Quiet.Once("Architecture: HeavyGateWood OnSpawned", ex);
		}
	}
}
[HarmonyPatch(typeof(ZNetScene), "Awake")]
internal static class ZNetScene_Awake_ArchFence
{
	[HarmonyBefore(new string[] { "doghaus.piecebalance" })]
	[HarmonyPriority(0)]
	[HarmonyAfter(new string[] { "balrond.astafaraios.BalrondConstructions" })]
	private static void Postfix(ZNetScene __instance)
	{
		try
		{
			ModSplit.Shell("doghaus.architecture", ArchitecturePlugin.Log, (ObjectDB)null, (Action)delegate
			{
				FenceSizes.Register(__instance);
			});
		}
		catch (Exception ex)
		{
			ArchitecturePlugin.Log.LogWarning((object)("Fence sizes could not be registered (DogHausTweaks will): " + ex));
		}
	}
}
[HarmonyPatch(typeof(ObjectDB), "Awake")]
internal static class ObjectDB_Awake_ArchFence
{
	[HarmonyAfter(new string[] { "balrond.astafaraios.BalrondConstructions" })]
	[HarmonyPriority(0)]
	private static void Postfix()
	{
		try
		{
			ModSplit.Shell("doghaus.architecture", ArchitecturePlugin.Log, (ObjectDB)null, (Action)delegate
			{
				FenceSizes.Again();
			});
		}
		catch (Exception ex)
		{
			Quiet.Once("Architecture: FenceSizes ObjectDB.Awake", ex);
		}
	}
}
[HarmonyPatch(typeof(ObjectDB), "CopyOtherDB")]
internal static class ObjectDB_CopyOtherDB_ArchFence
{
	[HarmonyAfter(new string[] { "balrond.astafaraios.BalrondConstructions" })]
	[HarmonyPriority(0)]
	private static void Postfix()
	{
		try
		{
			ModSplit.Shell("doghaus.architecture", ArchitecturePlugin.Log, (ObjectDB)null, (Action)delegate
			{
				FenceSizes.Again();
			});
		}
		catch (Exception ex)
		{
			Quiet.Once("Architecture: FenceSizes CopyOtherDB", ex);
		}
	}
}
[HarmonyPatch(typeof(Player), "OnSpawned")]
internal static class Player_OnSpawned_ArchFence
{
	private static void Postfix(Player __instance)
	{
		if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer)
		{
			return;
		}
		try
		{
			ModSplit.Shell("doghaus.architecture", ArchitecturePlugin.Log, (ObjectDB)null, (Action)delegate
			{
				FenceSizes.Again();
			});
		}
		catch (Exception ex)
		{
			Quiet.Once("Architecture: FenceSizes OnSpawned", ex);
		}
	}
}
[HarmonyPatch(typeof(ZNetScene), "Awake")]
internal static class ZNetScene_Awake_ArchGrand
{
	[HarmonyBefore(new string[] { "doghaus.piecebalance" })]
	[HarmonyAfter(new string[] { "blacks7ar.FineWoodBuildPieces" })]
	[HarmonyPriority(0)]
	private static void Postfix(ZNetScene __instance)
	{
		try
		{
			ModSplit.Shell("doghaus.architecture", ArchitecturePlugin.Log, (ObjectDB)null, (Action)delegate
			{
				GrandGates.Register(__instance);
			});
		}
		catch (Exception ex)
		{
			ArchitecturePlugin.Log.LogWarning((object)("Grand gates could not be registered (DogHausTweaks will): " + ex));
		}
	}
}
[HarmonyPatch(typeof(ObjectDB), "Awake")]
internal static class ObjectDB_Awake_ArchGrand
{
	[HarmonyPriority(0)]
	[HarmonyAfter(new string[] { "blacks7ar.FineWoodBuildPieces" })]
	private static void Postfix()
	{
		try
		{
			ModSplit.Shell("doghaus.architecture", ArchitecturePlugin.Log, (ObjectDB)null, (Action)delegate
			{
				GrandGates.Again();
			});
		}
		catch (Exception ex)
		{
			Quiet.Once("Architecture: GrandGates ObjectDB.Awake", ex);
		}
	}
}
[HarmonyPatch(typeof(ObjectDB), "CopyOtherDB")]
internal static class ObjectDB_CopyOtherDB_ArchGrand
{
	[HarmonyPriority(0)]
	[HarmonyAfter(new string[] { "blacks7ar.FineWoodBuildPieces" })]
	private static void Postfix()
	{
		try
		{
			ModSplit.Shell("doghaus.architecture", ArchitecturePlugin.Log, (ObjectDB)null, (Action)delegate
			{
				GrandGates.Again();
			});
		}
		catch (Exception ex)
		{
			Quiet.Once("Architecture: GrandGates CopyOtherDB", ex);
		}
	}
}
[HarmonyPatch(typeof(Player), "OnSpawned")]
internal static class Player_OnSpawned_ArchGrand
{
	private static void Postfix(Player __instance)
	{
		if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer)
		{
			return;
		}
		try
		{
			ModSplit.Shell("doghaus.architecture", ArchitecturePlugin.Log, (ObjectDB)null, (Action)delegate
			{
				GrandGates.Again();
			});
		}
		catch (Exception ex)
		{
			Quiet.Once("Architecture: GrandGates OnSpawned", ex);
		}
	}
}
[HarmonyPatch(typeof(ZNetScene), "Awake")]
internal static class ZNetScene_Awake_ArchBeam67
{
	[HarmonyPriority(0)]
	[HarmonyBefore(new string[] { "doghaus.piecebalance" })]
	private static void Postfix(ZNetScene __instance)
	{
		try
		{
			ModSplit.Shell("doghaus.architecture", ArchitecturePlugin.Log, (ObjectDB)null, (Action)delegate
			{
				Beam67.Register(__instance);
			});
		}
		catch (Exception ex)
		{
			ArchitecturePlugin.Log.LogWarning((object)("Wood Beam 67 could not be registered (DogHausTweaks will): " + ex));
		}
	}
}
[HarmonyPatch(typeof(ObjectDB), "Awake")]
internal static class ObjectDB_Awake_ArchBeam67
{
	[HarmonyPriority(0)]
	private static void Postfix()
	{
		try
		{
			ModSplit.Shell("doghaus.architecture", ArchitecturePlugin.Log, (ObjectDB)null, (Action)delegate
			{
				Beam67.Again();
			});
		}
		catch (Exception ex)
		{
			Quiet.Once("Architecture: Beam67 ObjectDB.Awake", ex);
		}
	}
}
[HarmonyPatch(typeof(ObjectDB), "CopyOtherDB")]
internal static class ObjectDB_CopyOtherDB_ArchBeam67
{
	[HarmonyPriority(0)]
	private static void Postfix()
	{
		try
		{
			ModSplit.Shell("doghaus.architecture", ArchitecturePlugin.Log, (ObjectDB)null, (Action)delegate
			{
				Beam67.Again();
			});
		}
		catch (Exception ex)
		{
			Quiet.Once("Architecture: Beam67 CopyOtherDB", ex);
		}
	}
}
[HarmonyPatch(typeof(Player), "OnSpawned")]
internal static class Player_OnSpawned_ArchBeam67
{
	private static void Postfix(Player __instance)
	{
		if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer)
		{
			return;
		}
		try
		{
			ModSplit.Shell("doghaus.architecture", ArchitecturePlugin.Log, (ObjectDB)null, (Action)delegate
			{
				Beam67.Again();
			});
		}
		catch (Exception ex)
		{
			Quiet.Once("Architecture: Beam67 OnSpawned", ex);
		}
	}
}
[HarmonyPatch(typeof(ZNetScene), "Awake")]
internal static class ZNetScene_Awake_ArchOctagon
{
	[HarmonyPriority(600)]
	private static void Postfix(ZNetScene __instance)
	{
		try
		{
			ModSplit.Shell("doghaus.architecture", ArchitecturePlugin.Log, (ObjectDB)null, (Action)delegate
			{
				OctagonRoofs.Register(__instance);
			});
		}
		catch (Exception ex)
		{
			ArchitecturePlugin.Log.LogWarning((object)("Octagon roofs could not be registered (DogHausTweaks will): " + ex));
		}
	}
}
[HarmonyPatch(typeof(ZNetScene), "Awake")]
internal static class ZNetScene_Awake_ArchLonghouse
{
	[HarmonyPriority(600)]
	private static void Postfix(ZNetScene __instance)
	{
		try
		{
			ModSplit.Shell("doghaus.architecture", ArchitecturePlugin.Log, (ObjectDB)null, (Action)delegate
			{
				LonghousePieces.Register(__instance);
			});
		}
		catch (Exception ex)
		{
			ArchitecturePlugin.Log.LogWarning((object)("Longhouse pieces could not be registered (DogHausTweaks will): " + ex));
		}
	}
}
[HarmonyPatch(typeof(ZNetScene), "Awake")]
internal static class ZNetScene_Awake_ArchArch
{
	[HarmonyPriority(600)]
	private static void Postfix(ZNetScene __instance)
	{
		try
		{
			ModSplit.Shell("doghaus.architecture", ArchitecturePlugin.Log, (ObjectDB)null, (Action)delegate
			{
				ArchPieces.Register(__instance);
			});
		}
		catch (Exception ex)
		{
			ArchitecturePlugin.Log.LogWarning((object)("Arch pieces could not be registered (DogHausTweaks will): " + ex));
		}
	}
}
[HarmonyPatch(typeof(Hud), "SetupPieceInfo")]
internal static class Hud_SetupPieceInfo_ArchLabel
{
	[HarmonyPriority(0)]
	private static void Postfix(Hud __instance, Piece piece)
	{
		ModSplit.LabelPiece("doghaus.architecture", __instance, piece);
	}
}
[BepInPlugin("doghaus.architecture", "DogHaus Architecture", "1.0.6")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency("doghaus.tweaks", "2.0.3")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class ArchitecturePlugin : BaseUnityPlugin
{
	public const string GUID = "doghaus.architecture";

	public const string NAME = "DogHaus Architecture";

	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.architecture", ((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 Architecture stands down with it (no pieces registered).");
			((Behaviour)this).enabled = false;
			return;
		}
		Harmony h = new Harmony("doghaus.architecture");
		HookReport val = new HookReport(((BaseUnityPlugin)this).Logger, "DogHaus Architecture");
		Register(h, val, typeof(ZNetScene_Awake_ArchLadder));
		Register(h, val, typeof(ObjectDB_Awake_ArchLadder));
		Register(h, val, typeof(ObjectDB_CopyOtherDB_ArchLadder));
		Register(h, val, typeof(Player_OnSpawned_ArchLadder));
		Register(h, val, typeof(ZNetScene_Awake_ArchGate));
		Register(h, val, typeof(ObjectDB_Awake_ArchGate));
		Register(h, val, typeof(ObjectDB_CopyOtherDB_ArchGate));
		Register(h, val, typeof(Player_OnSpawned_ArchGate));
		Register(h, val, typeof(ZNetScene_Awake_ArchFence));
		Register(h, val, typeof(ObjectDB_Awake_ArchFence));
		Register(h, val, typeof(ObjectDB_CopyOtherDB_ArchFence));
		Register(h, val, typeof(Player_OnSpawned_ArchFence));
		Register(h, val, typeof(ZNetScene_Awake_ArchGrand));
		Register(h, val, typeof(ObjectDB_Awake_ArchGrand));
		Register(h, val, typeof(ObjectDB_CopyOtherDB_ArchGrand));
		Register(h, val, typeof(Player_OnSpawned_ArchGrand));
		Register(h, val, typeof(ZNetScene_Awake_ArchBeam67));
		Register(h, val, typeof(ObjectDB_Awake_ArchBeam67));
		Register(h, val, typeof(ObjectDB_CopyOtherDB_ArchBeam67));
		Register(h, val, typeof(Player_OnSpawned_ArchBeam67));
		Register(h, val, typeof(ZNetScene_Awake_ArchOctagon));
		Register(h, val, typeof(ZNetScene_Awake_ArchLonghouse));
		Register(h, val, typeof(ZNetScene_Awake_ArchArch));
		Register(h, val, typeof(Hud_SetupPieceInfo_ArchLabel));
		val.Summary();
		((BaseUnityPlugin)this).Logger.LogInfo((object)("DogHaus Architecture 1.0.6 loaded: registers the DogHaus building pieces (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);
		}
	}
}