Decompiled source of AnarchyHammer v1.0.0

AnarchyHammer.dll

Decompiled a day ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("SelectiveBuildRestrictions")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SelectiveBuildRestrictions")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("2ce989e4-8c1f-4d40-bd41-8c252afc0264")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace AnarchyHammer;

[BepInPlugin("com.robit.anarchyhammer", "Anarchy Hammer - Build Anywhere, Any Way", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
	public const string ModGUID = "com.robit.anarchyhammer";

	public const string ModName = "Anarchy Hammer - Build Anywhere, Any Way";

	public const string ModVersion = "1.0.0";

	internal static ConfigEntry<bool> IgnoreInvalid;

	internal static ConfigEntry<bool> IgnoreBlockedByPlayer;

	internal static ConfigEntry<bool> IgnoreNoBuildZone;

	internal static ConfigEntry<bool> IgnorePrivateZone;

	internal static ConfigEntry<bool> IgnoreNoTeleportArea;

	internal static ConfigEntry<bool> IgnoreWrongBiome;

	internal static ConfigEntry<bool> IgnoreNotInDungeon;

	internal static ConfigEntry<bool> MakeAllPiecesSupport;

	private Harmony _harmony;

	private void Awake()
	{
		//IL_0106: Unknown result type (might be due to invalid IL or missing references)
		//IL_0110: Expected O, but got Unknown
		IgnoreInvalid = ((BaseUnityPlugin)this).Config.Bind<bool>("Restrictions", "IgnoreInvalid", true, "Allows placement when Valheim reports Invalid.");
		IgnoreBlockedByPlayer = ((BaseUnityPlugin)this).Config.Bind<bool>("Restrictions", "IgnoreBlockedByPlayer", true, "Allows pieces to be placed when blocked by a player.");
		IgnoreNoBuildZone = ((BaseUnityPlugin)this).Config.Bind<bool>("Restrictions", "IgnoreNoBuildZone", true, "Allows building in normally protected locations such as boss areas.");
		IgnorePrivateZone = ((BaseUnityPlugin)this).Config.Bind<bool>("Restrictions", "IgnorePrivateZone", false, "Allows placement inside wards/private areas.");
		IgnoreNoTeleportArea = ((BaseUnityPlugin)this).Config.Bind<bool>("Restrictions", "IgnoreNoTeleportArea", true, "Ignores teleport-area placement restrictions.");
		IgnoreWrongBiome = ((BaseUnityPlugin)this).Config.Bind<bool>("Restrictions", "IgnoreWrongBiome", true, "Ignores biome placement restrictions.");
		IgnoreNotInDungeon = ((BaseUnityPlugin)this).Config.Bind<bool>("Restrictions", "IgnoreNotInDungeon", true, "Allows pieces normally disallowed in dungeon interiors.");
		MakeAllPiecesSupport = ((BaseUnityPlugin)this).Config.Bind<bool>("Structural Support", "AllPiecesCanSupport", true, "Allows normally non-supporting build pieces, such as chests, to transmit structural support.");
		_harmony = new Harmony("com.robit.anarchyhammer");
		_harmony.PatchAll();
		((BaseUnityPlugin)this).Logger.LogInfo((object)"Anarchy Hammer - Build Anywhere, Any Way 1.0.0 loaded.");
	}

	private void OnDestroy()
	{
		Harmony harmony = _harmony;
		if (harmony != null)
		{
			harmony.UnpatchSelf();
		}
	}
}
[HarmonyPatch]
internal static class PlacementPatch
{
	private static MethodBase TargetMethod()
	{
		return AccessTools.Method(typeof(Player), "UpdatePlacementGhost", (Type[])null, (Type[])null);
	}

	[HarmonyPostfix]
	[HarmonyPriority(200)]
	private static void Postfix(ref PlacementStatus ___m_placementStatus, GameObject ___m_placementGhost)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0003: Unknown result type (might be due to invalid IL or missing references)
		//IL_0005: Invalid comparison between Unknown and I4
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		//IL_0015: Invalid comparison between Unknown and I4
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_0025: Invalid comparison between Unknown and I4
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: Invalid comparison between Unknown and I4
		//IL_0043: Unknown result type (might be due to invalid IL or missing references)
		//IL_0045: Invalid comparison between Unknown and I4
		//IL_0053: Unknown result type (might be due to invalid IL or missing references)
		//IL_0055: Invalid comparison between Unknown and I4
		//IL_0063: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: Invalid comparison between Unknown and I4
		PlacementStatus val = ___m_placementStatus;
		if (((int)val != 1 || !Plugin.IgnoreInvalid.Value) && ((int)val != 2 || !Plugin.IgnoreBlockedByPlayer.Value) && ((int)val != 3 || !Plugin.IgnoreNoBuildZone.Value) && ((int)val != 4 || !Plugin.IgnorePrivateZone.Value) && ((int)val != 6 || !Plugin.IgnoreNoTeleportArea.Value) && ((int)val != 8 || !Plugin.IgnoreWrongBiome.Value) && ((int)val != 11 || !Plugin.IgnoreNotInDungeon.Value))
		{
			return;
		}
		___m_placementStatus = (PlacementStatus)0;
		if (!((Object)(object)___m_placementGhost == (Object)null))
		{
			Piece component = ___m_placementGhost.GetComponent<Piece>();
			if ((Object)(object)component != (Object)null)
			{
				component.SetInvalidPlacementHeightlight(false);
			}
		}
	}
}
[HarmonyPatch]
internal static class WearNTearSupportsPatch
{
	private static MethodBase TargetMethod()
	{
		return AccessTools.Method(typeof(WearNTear), "Awake", (Type[])null, (Type[])null);
	}

	[HarmonyPostfix]
	private static void Postfix(ref bool ___m_supports)
	{
		if (Plugin.MakeAllPiecesSupport.Value)
		{
			___m_supports = true;
		}
	}
}
[HarmonyPatch]
internal static class NoBuildLocationPatch
{
	private static MethodBase TargetMethod()
	{
		return AccessTools.Method(typeof(Location), "IsInsideNoBuildLocation", (Type[])null, (Type[])null);
	}

	[HarmonyPostfix]
	private static void Postfix(ref bool __result)
	{
		if (Plugin.IgnoreNoBuildZone.Value)
		{
			__result = false;
		}
	}
}