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 OakwoodStations v1.1.0
plugins\Oakwood.OakwoodStations\Oakwood.OakwoodStations.dll
Decompiled 3 days 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(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyCompany("Oakwood.OakwoodStations")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.1.0.0")] [assembly: AssemblyInformationalVersion("1.1.0")] [assembly: AssemblyProduct("Oakwood.OakwoodStations")] [assembly: AssemblyTitle("Oakwood.OakwoodStations")] [assembly: AssemblyVersion("1.1.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [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 Oakwood.OakwoodStations { [BepInPlugin("org.oakwood.oakwoodstations", "OakwoodStations", "1.1.0")] public sealed class OakwoodStationsPlugin : BaseUnityPlugin { [HarmonyPatch(typeof(CraftingStation), "Start")] private static class CraftingStationStartPatch { private static void Postfix(CraftingStation __instance) { ApplyStationSettings(__instance); } } [HarmonyPatch(typeof(CraftingStation), "GetStationBuildRange")] private static class CraftingStationRangePatch { private static void Prefix(CraftingStation __instance) { ApplyStationSettings(__instance); } } [HarmonyPatch(typeof(StationExtension), "Awake")] private static class StationExtensionAwakePatch { private static void Postfix(StationExtension __instance) { ApplyExtensionSettings(__instance, ((Component)__instance).GetComponent<Piece>()); } } [HarmonyPatch(typeof(Piece), "Awake")] private static class PieceAwakePatch { private static void Postfix(Piece __instance) { if (IsTargetPiece(__instance)) { ApplyRules(__instance); } } } [HarmonyPatch(typeof(Player), "SetupPlacementGhost")] private static class SetupPlacementGhostPatch { private static void Postfix(Player __instance) { object? obj = AccessTools.Field(typeof(Player), "m_placementGhost")?.GetValue(__instance); GameObject val = (GameObject)((obj is GameObject) ? obj : null); if (!((Object)(object)val == (Object)null)) { Piece component = val.GetComponent<Piece>(); if ((Object)(object)component != (Object)null && IsTargetPiece(component)) { ApplyRules(component); } } } } [HarmonyPatch(typeof(Player), "UpdatePlacementGhost")] private static class UpdatePlacementGhostPatch { private static void Prefix(Player __instance) { object? obj = AccessTools.Field(typeof(Player), "m_placementGhost")?.GetValue(__instance); GameObject val = (GameObject)((obj is GameObject) ? obj : null); if ((Object)(object)val == (Object)null) { return; } Piece component = val.GetComponent<Piece>(); if ((Object)(object)component != (Object)null && IsTargetPiece(component)) { component.m_clipEverything = _allowClipping.Value; component.m_clipGround = _allowClipping.Value; component.m_allowRotatedOverlap = _allowClipping.Value; if (_allowClipping.Value) { component.m_noClipping = false; } StationExtension component2 = ((Component)component).GetComponent<StationExtension>(); if ((Object)(object)component2 != (Object)null) { ApplyExtensionSettings(component2, component); } CraftingStation component3 = ((Component)component).GetComponent<CraftingStation>(); if ((Object)(object)component3 != (Object)null) { ApplyStationSettings(component3); } } } } public const string PluginGuid = "org.oakwood.oakwoodstations"; public const string PluginName = "OakwoodStations"; public const string PluginVersion = "1.1.0"; private static ConfigEntry<float> _buildRange; private static ConfigEntry<float> _buildRangePerUpgrade; private static ConfigEntry<float> _upgradeRange; private static ConfigEntry<float> _upgradeSpacing; private static ConfigEntry<bool> _noPlacementRestrictions; private static ConfigEntry<bool> _allowClipping; private static ConfigEntry<KeyboardShortcut> _toggleClippingKey; private static ConfigEntry<bool> _allowStackingSupport; private static ConfigEntry<bool> _applyToCraftingStations; private static ConfigEntry<bool> _applyToUpgrades; private static ConfigEntry<bool> _applyToSmeltersAndKilns; private static ConfigEntry<bool> _applyToFermenters; private static ConfigEntry<bool> _applyToBeehives; private static ConfigEntry<bool> _applyToSapExtractors; private static ConfigEntry<bool> _applyToCookingStationsAndOvens; private static ConfigEntry<bool> _applyToOtherProcessors; private static ConfigEntry<bool> _applyToFurniture; private readonly Harmony _harmony = new Harmony("org.oakwood.oakwoodstations"); private void Awake() { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Expected O, but got Unknown //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Expected O, but got Unknown //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Expected O, but got Unknown //IL_014b: Unknown result type (might be due to invalid IL or missing references) _buildRange = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Build range", 20f, new ConfigDescription("The base build range of crafting stations.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(5f, 50f), Array.Empty<object>())); _buildRangePerUpgrade = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Build range increase per upgrade", 4f, new ConfigDescription("How much each upgrade increases a crafting station's build range.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 50f), Array.Empty<object>())); _upgradeRange = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Upgrade range", 10f, new ConfigDescription("Maximum distance at which upgrades still connect to a crafting station.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(5f, 50f), Array.Empty<object>())); _upgradeSpacing = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Space requirement between upgrades", 0f, new ConfigDescription("Minimum required spacing between upgrades when placing them (vanilla default is 2).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), Array.Empty<object>())); _noPlacementRestrictions = ((BaseUnityPlugin)this).Config.Bind<bool>("Placement", "No placement restrictions", true, "Remove placement surface/environment restrictions (ground-only, not on wood/floors, tilted surfaces, water, dungeons, snow, biome limits, and blocking radius) for enabled piece types."); _allowClipping = ((BaseUnityPlugin)this).Config.Bind<bool>("Placement", "Allow clipping", true, "Allow enabled piece types to clip into and overlap terrain, structures, and other stations or processors. Can be toggled live with the hotkey."); _toggleClippingKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Placement", "Toggle clipping key", new KeyboardShortcut((KeyCode)61, Array.Empty<KeyCode>()), "Hotkey to toggle Allow clipping on or off in-game."); _allowStackingSupport = ((BaseUnityPlugin)this).Config.Bind<bool>("Placement", "Allow stacking support", true, "Mark enabled pieces as structural supports so stacked stations, upgrades, processors, and furniture stay supported."); _applyToCraftingStations = ((BaseUnityPlugin)this).Config.Bind<bool>("Targets", "Apply to crafting stations", true, "Apply range, placement, clipping, and stacking rules to crafting stations (Workbench, Forge, Stonecutter, Artisan Table, Black Forge, Galdr Table, Cauldron, etc.)."); _applyToUpgrades = ((BaseUnityPlugin)this).Config.Bind<bool>("Targets", "Apply to upgrades", true, "Apply upgrade range, spacing, placement, clipping, and stacking rules to crafting station upgrades (StationExtension)."); _applyToSmeltersAndKilns = ((BaseUnityPlugin)this).Config.Bind<bool>("Targets", "Apply to smelters and kilns", true, "Apply placement, clipping, and stacking rules to Smelters, Blast Furnaces, Charcoal Kilns, Windmills, Spinning Wheels, and Eitr Refineries (Smelter)."); _applyToFermenters = ((BaseUnityPlugin)this).Config.Bind<bool>("Targets", "Apply to fermenters", true, "Apply placement, clipping, and stacking rules to Fermenters."); _applyToBeehives = ((BaseUnityPlugin)this).Config.Bind<bool>("Targets", "Apply to beehives", true, "Apply placement, clipping, and stacking rules to Beehives."); _applyToSapExtractors = ((BaseUnityPlugin)this).Config.Bind<bool>("Targets", "Apply to sap extractors", true, "Apply placement, clipping, and stacking rules to Sap Extractors (SapCollector)."); _applyToCookingStationsAndOvens = ((BaseUnityPlugin)this).Config.Bind<bool>("Targets", "Apply to cooking stations and ovens", true, "Apply placement, clipping, and stacking rules to Cooking Stations and Stone Ovens."); _applyToOtherProcessors = ((BaseUnityPlugin)this).Config.Bind<bool>("Targets", "Apply to other processors", true, "Apply placement, clipping, and stacking rules to remaining processing buildables (Incinerator / Obliterator and Windmill)."); _applyToFurniture = ((BaseUnityPlugin)this).Config.Bind<bool>("Targets", "Apply to furniture", true, "Apply placement, clipping, and stacking rules to all Furniture build pieces (PieceCategory.Furniture)."); _harmony.PatchAll(typeof(CraftingStationStartPatch)); _harmony.PatchAll(typeof(CraftingStationRangePatch)); _harmony.PatchAll(typeof(StationExtensionAwakePatch)); _harmony.PatchAll(typeof(PieceAwakePatch)); _harmony.PatchAll(typeof(SetupPlacementGhostPatch)); _harmony.PatchAll(typeof(UpdatePlacementGhostPatch)); ((BaseUnityPlugin)this).Logger.LogInfo((object)"OakwoodStations v1.1.0 loaded (standalone)."); } private void Update() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) KeyboardShortcut value = _toggleClippingKey.Value; if (((KeyboardShortcut)(ref value)).IsDown() && (Object)(object)Player.m_localPlayer != (Object)null) { _allowClipping.Value = !_allowClipping.Value; ((Character)Player.m_localPlayer).Message((MessageType)1, "OakwoodStations clipping: " + (_allowClipping.Value ? "ON" : "OFF"), 0, (Sprite)null, false); } } private void OnDestroy() { _harmony.UnpatchSelf(); } private static bool IsTargetPiece(Piece? piece) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Invalid comparison between Unknown and I4 if ((Object)(object)piece == (Object)null) { return false; } if (_applyToFurniture.Value && (int)piece.m_category == 4) { return true; } GameObject gameObject = ((Component)piece).gameObject; if (_applyToCraftingStations.Value && (Object)(object)gameObject.GetComponent<CraftingStation>() != (Object)null) { return true; } if (_applyToUpgrades.Value && (Object)(object)gameObject.GetComponent<StationExtension>() != (Object)null) { return true; } if (_applyToSmeltersAndKilns.Value && (Object)(object)gameObject.GetComponent<Smelter>() != (Object)null) { return true; } if (_applyToFermenters.Value && (Object)(object)gameObject.GetComponent<Fermenter>() != (Object)null) { return true; } if (_applyToBeehives.Value && (Object)(object)gameObject.GetComponent<Beehive>() != (Object)null) { return true; } if (_applyToSapExtractors.Value && (Object)(object)gameObject.GetComponent<SapCollector>() != (Object)null) { return true; } if (_applyToCookingStationsAndOvens.Value && (Object)(object)gameObject.GetComponent<CookingStation>() != (Object)null) { return true; } if (_applyToOtherProcessors.Value && ((Object)(object)gameObject.GetComponent<Incinerator>() != (Object)null || (Object)(object)gameObject.GetComponent<Windmill>() != (Object)null)) { return true; } return false; } private static void ApplyStationSettings(CraftingStation station) { if (_applyToCraftingStations.Value) { station.m_rangeBuild = _buildRange.Value; station.m_extraRangePerLevel = _buildRangePerUpgrade.Value; } } private static void ApplyExtensionSettings(StationExtension extension, Piece? piece) { if (_applyToUpgrades.Value) { extension.m_maxStationDistance = _upgradeRange.Value; if ((Object)(object)piece != (Object)null) { piece.m_spaceRequirement = _upgradeSpacing.Value; } } } private static void ApplyRules(Piece piece) { //IL_005b: Unknown result type (might be due to invalid IL or missing references) StationExtension component = ((Component)piece).GetComponent<StationExtension>(); if (_noPlacementRestrictions.Value) { piece.m_groundOnly = false; piece.m_cultivatedGroundOnly = false; piece.m_vegetationGroundOnly = false; piece.m_notOnWood = false; piece.m_notOnTiltingSurface = false; piece.m_notOnFloor = false; piece.m_noInWater = false; piece.m_inCeilingOnly = false; piece.m_allowedInDungeons = true; piece.m_allowedInDeepSnow = true; piece.m_onlyInBiome = (Biome)0; piece.m_blockRadius = 0f; if ((Object)(object)component == (Object)null || !_applyToUpgrades.Value) { piece.m_spaceRequirement = 0f; } } if ((Object)(object)component != (Object)null) { ApplyExtensionSettings(component, piece); } CraftingStation component2 = ((Component)piece).GetComponent<CraftingStation>(); if ((Object)(object)component2 != (Object)null) { ApplyStationSettings(component2); } if (_allowClipping.Value) { piece.m_clipGround = true; piece.m_clipEverything = true; piece.m_noClipping = false; piece.m_allowRotatedOverlap = true; } else { piece.m_clipEverything = false; } if (_allowStackingSupport.Value) { WearNTear component3 = ((Component)piece).GetComponent<WearNTear>(); if ((Object)(object)component3 != (Object)null) { component3.m_supports = true; } } } } }