Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of NoBuildRestriction v420.0.11
BuildRestrictionTweaks.dll
Decompiled 2 weeks agousing System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Microsoft.CodeAnalysis; 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("BuildRestrictionTweaks")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("BuildRestrictionTweaks")] [assembly: AssemblyTitle("BuildRestrictionTweaks")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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 BuildRestrictionTweaks { [BepInPlugin("aedenthorn.BuildRestrictionTweaks", "Build Restriction Tweaks", "1.0.0")] public sealed class BepInExPlugin : BaseUnityPlugin { [HarmonyPatch(typeof(Location), "IsInsideNoBuildLocation")] private static class NoBuildLocationPatch { private static void Postfix(ref bool __result) { if (IsEnabled && (AlwaysValid.Value || IgnoreBuildZone.Value)) { __result = false; } } } [HarmonyPatch(typeof(CraftingStation), "HaveBuildStationInRange")] private static class MissingStationPatch { private static void Postfix(ref CraftingStation __result) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Expected O, but got Unknown if (IsEnabled && (AlwaysValid.Value || IgnoreMissingStation.Value) && !((Object)(object)__result != (Object)null)) { if ((Object)(object)_dummyStationObject == (Object)null) { _dummyStationObject = new GameObject("NoBuildRestriction_DummyCraftingStation"); Object.DontDestroyOnLoad((Object)(object)_dummyStationObject); _dummyStationObject.AddComponent<CraftingStation>(); } __result = _dummyStationObject.GetComponent<CraftingStation>(); } } } [HarmonyPatch(typeof(Player), "UpdatePlacementGhost")] private static class PlacementGhostPatch { private static void Postfix(Player __instance, GameObject ___m_placementGhost) { if (IsEnabled && !((Object)(object)___m_placementGhost == (Object)null)) { int num = Convert.ToInt32(_placementStatusField.GetValue(__instance)); if ((num != 0 && num != 4 && AlwaysValid.Value) || (num == 1 && IgnoreInvalid.Value) || (num == 2 && IgnoreBlockedByPlayer.Value) || (num == 3 && IgnoreBuildZone.Value) || (num == 5 && IgnoreSpaceRestrictions.Value) || (num == 6 && IgnoreTeleportAreaRestrictions.Value) || (num == 7 && IgnoreMissingStationExtension.Value) || (num == 8 && IgnoreBiomeRestrictions.Value) || (num == 9 && IgnoreCultivationRestrictions.Value) || (num == 10 && IgnoreDirtRestrictions.Value) || (num == 11 && IgnoreDungeonRestrictions.Value)) { _placementStatusField.SetValue(__instance, Enum.ToObject(_placementStatusField.FieldType, 0)); _setGhostValidMethod.Invoke(__instance, new object[1] { true }); } } } } [HarmonyPatch(typeof(CraftingStation), "CheckUsable")] private static class NoRoofAndFirePatch { private static bool Prefix(ref bool __result) { if (!IsEnabled || NoRoofAndFire == null || !NoRoofAndFire.Value) { return true; } __result = true; return false; } } internal static ConfigEntry<bool> Enabled; internal static ConfigEntry<bool> AlwaysValid; internal static ConfigEntry<bool> IgnoreInvalid; internal static ConfigEntry<bool> IgnoreBlockedByPlayer; internal static ConfigEntry<bool> IgnoreBuildZone; internal static ConfigEntry<bool> IgnoreSpaceRestrictions; internal static ConfigEntry<bool> IgnoreTeleportAreaRestrictions; internal static ConfigEntry<bool> IgnoreMissingStation; internal static ConfigEntry<bool> IgnoreMissingStationExtension; internal static ConfigEntry<bool> IgnoreBiomeRestrictions; internal static ConfigEntry<bool> IgnoreCultivationRestrictions; internal static ConfigEntry<bool> IgnoreDirtRestrictions; internal static ConfigEntry<bool> IgnoreDungeonRestrictions; internal static ConfigEntry<bool> NoRoofAndFire; private static GameObject _dummyStationObject; private static FieldInfo _placementStatusField; private static MethodInfo _setGhostValidMethod; internal static bool IsEnabled { get { if (Enabled != null) { return Enabled.Value; } return false; } } private void Awake() { Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Enable this mod."); AlwaysValid = ((BaseUnityPlugin)this).Config.Bind<bool>("Options", "AlwaysValid", true, "Remove build placement restrictions except private player wards."); IgnoreBlockedByPlayer = ((BaseUnityPlugin)this).Config.Bind<bool>("Options", "ignoreBlockedbyPlayer", false, "Ignore player blocking build placement."); IgnoreInvalid = ((BaseUnityPlugin)this).Config.Bind<bool>("Options", "IgnoreInvalid", false, "Ignore miscellaneous invalid placement restrictions."); IgnoreBuildZone = ((BaseUnityPlugin)this).Config.Bind<bool>("Options", "ignoreBuildZone", false, "Ignore no-build zone restrictions."); IgnoreSpaceRestrictions = ((BaseUnityPlugin)this).Config.Bind<bool>("Options", "ignoreSpaceRestrictions", false, "Ignore required spacing around pieces."); IgnoreTeleportAreaRestrictions = ((BaseUnityPlugin)this).Config.Bind<bool>("Options", "ignoreTeleportAreaRestrictions", false, "Ignore teleport area restrictions."); IgnoreMissingStation = ((BaseUnityPlugin)this).Config.Bind<bool>("Options", "ignoreMissingStation", false, "Ignore missing crafting station requirements."); IgnoreMissingStationExtension = ((BaseUnityPlugin)this).Config.Bind<bool>("Options", "ignoreMissingStationExtension", false, "Ignore missing crafting station extension requirements."); IgnoreBiomeRestrictions = ((BaseUnityPlugin)this).Config.Bind<bool>("Options", "ignoreBiomeRestrictions", false, "Ignore biome restrictions."); IgnoreCultivationRestrictions = ((BaseUnityPlugin)this).Config.Bind<bool>("Options", "ignoreCultivationRestrictions", false, "Ignore cultivated ground requirements."); IgnoreDirtRestrictions = ((BaseUnityPlugin)this).Config.Bind<bool>("Options", "ignoreDirtRestrictions", false, "Ignore dirt requirements."); IgnoreDungeonRestrictions = ((BaseUnityPlugin)this).Config.Bind<bool>("Options", "ignoreDungeonRestrictions", false, "Ignore dungeon/interior restrictions."); NoRoofAndFire = ((BaseUnityPlugin)this).Config.Bind<bool>("Options", "NoRoofAndFire", true, "Use crafting stations without requiring a roof, shelter, or nearby fire."); if (Enabled.Value) { _placementStatusField = AccessTools.Field(typeof(Player), "m_placementStatus"); _setGhostValidMethod = AccessTools.Method(typeof(Player), "SetPlacementGhostValid", new Type[1] { typeof(bool) }, (Type[])null); if (_placementStatusField == null || _setGhostValidMethod == null) { ((BaseUnityPlugin)this).Logger.LogError((object)"Valheim placement methods were not found. Build restriction patches were not installed."); return; } Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "aedenthorn.BuildRestrictionTweaks"); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Build restrictions and optional no-roof/no-fire crafting patches are ready."); } } } }