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 PavedRoadNoLevel v1.0.9
plugins\PavedRoadNoLevel.dll
Decompiled a week agousing System; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using Jotunn; using Jotunn.Managers; using Jotunn.Utils; using PavedRoadNoLevel.Configs; using PavedRoadNoLevel.Helpers; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("PavedRoadNoLevel")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("PavedRoadNoLevel")] [assembly: AssemblyCopyright("Copyright © 2021")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("e3243d22-4307-4008-ba36-9f326008cde5")] [assembly: AssemblyFileVersion("0.0.1.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.1.0")] namespace PavedRoadNoLevel { [BepInPlugin("DeathWizsh.PavedRoadNoLevel", "Paved Road No Level", "1.0.9")] [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] internal class PavedRoadNoLevel : BaseUnityPlugin { public const string PluginGUID = "DeathWizsh.PavedRoadNoLevel"; public const string PluginName = "Paved Road No Level"; public const string PluginVersion = "1.0.9"; public static string configFileName = "DeathWizsh.PavedRoadNoLevel.cfg"; public static string configFileFullPath; public static PavedRoadNoLevel Instance; public CraftingStation stonecutterPiece; private bool firstPatch = true; public void Awake() { Instance = this; PluginConfig.Init(); if (PluginConfig.configEnable.Value) { PrefabManager.OnVanillaPrefabsAvailable += PatchOriginal; } } private void PatchOriginal() { try { GameObject prefab = PrefabManager.Instance.GetPrefab("paved_road_v2"); GameObject prefab2 = PrefabManager.Instance.GetPrefab("cultivate_v2"); if (firstPatch) { Piece component = prefab.GetComponent<Piece>(); stonecutterPiece = component.m_craftingStation; firstPatch = false; } TerrainToolHelper.SetSmooth(prefab, value: false); TerrainToolHelper.SetSmooth(prefab2, value: false); TerrainToolHelper.SetStonecutter(prefab, value: false); } catch (Exception ex) { Logger.LogError((object)("Could not patch original: " + ex)); } } private void UnpatchOriginal() { try { GameObject prefab = PrefabManager.Instance.GetPrefab("paved_road_v2"); GameObject prefab2 = PrefabManager.Instance.GetPrefab("cultivate_v2"); TerrainToolHelper.SetSmooth(prefab, value: true); TerrainToolHelper.SetSmooth(prefab2, value: true); TerrainToolHelper.SetStonecutter(prefab, value: true); } catch (Exception ex) { Logger.LogError((object)("Could not unpatch original: " + ex)); } } public void ApplyConfigChanges() { if (PluginConfig.configEnable.Value) { PatchOriginal(); } else { UnpatchOriginal(); } } static PavedRoadNoLevel() { string configPath = Paths.ConfigPath; char directorySeparatorChar = Path.DirectorySeparatorChar; configFileFullPath = configPath + directorySeparatorChar + configFileName; } } } namespace PavedRoadNoLevel.Helpers { internal class TerrainToolHelper { public static void SetSmooth(GameObject prefab, bool value) { if ((Object)(object)prefab == (Object)null) { throw new Exception("Prefab is null"); } TerrainOp component = prefab.GetComponent<TerrainOp>(); if ((Object)(object)component == (Object)null) { throw new Exception("Could not find terrain op componenent"); } component.m_settings.m_smooth = value; } public static void SetStonecutter(GameObject prefab, bool value) { if ((Object)(object)prefab == (Object)null) { throw new Exception("Prefab is null"); } Piece component = prefab.GetComponent<Piece>(); if ((Object)(object)component == (Object)null) { throw new Exception("Could not find piece componenent"); } component.m_allowAltGroundPlacement = value; component.m_craftingStation = (PluginConfig.configRequireStoncutter.Value ? PavedRoadNoLevel.Instance.stonecutterPiece : null); } } } namespace PavedRoadNoLevel.Configs { internal static class PluginConfig { public static string sectionGeneral = "General"; public static ConfigEntry<bool> configEnable; public static ConfigEntry<bool> configRequireStoncutter; private static int entryCount = 1000; private static FileSystemWatcher configWatcher; public static void Init() { InitGeneralConfig(); } public static void InitGeneralConfig() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Expected O, but got Unknown //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Expected O, but got Unknown //IL_005f: Expected O, but got Unknown //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Expected O, but got Unknown //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Expected O, but got Unknown //IL_00ec: Expected O, but got Unknown try { ((BaseUnityPlugin)PavedRoadNoLevel.Instance).Config.SaveOnConfigSet = false; configEnable = ((BaseUnityPlugin)PavedRoadNoLevel.Instance).Config.Bind<bool>(new ConfigDefinition(sectionGeneral, "Enable"), true, new ConfigDescription("Enable this mod", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = false, Order = HandleOrder() } })); configEnable.SettingChanged += delegate { PavedRoadNoLevel.Instance.ApplyConfigChanges(); }; ((BaseUnityPlugin)PavedRoadNoLevel.Instance).Config.SaveOnConfigSet = true; configRequireStoncutter = ((BaseUnityPlugin)PavedRoadNoLevel.Instance).Config.Bind<bool>(new ConfigDefinition(sectionGeneral, "Stonecutter requirement"), true, new ConfigDescription("Enable the Stonecutter as a requirement (to pave roads)", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = false, Order = HandleOrder() } })); configRequireStoncutter.SettingChanged += delegate { PavedRoadNoLevel.Instance.ApplyConfigChanges(); }; configWatcher = new FileSystemWatcher(Paths.ConfigPath, PavedRoadNoLevel.configFileName); configWatcher.Changed += OnConfigFileChange; configWatcher.Created += OnConfigFileChange; configWatcher.Renamed += OnConfigFileChange; configWatcher.IncludeSubdirectories = true; configWatcher.SynchronizingObject = ThreadingHelper.SynchronizingObject; configWatcher.EnableRaisingEvents = true; } catch (Exception ex) { Logger.LogError((object)("Could not initialise the config & events: " + ex)); } } private static void OnConfigFileChange(object sender, FileSystemEventArgs e) { if (!File.Exists(PavedRoadNoLevel.configFileFullPath)) { return; } try { ((BaseUnityPlugin)PavedRoadNoLevel.Instance).Config.Reload(); } catch (Exception ex) { Logger.LogError((object)("Something went wrong while reloading the config, please check if the file exists and the entries are valid! " + ex)); } } private static int HandleOrder() { entryCount--; if (entryCount >= 0) { return entryCount; } return 0; } } }