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.8
plugins/PavedRoadNoLevel.dll
Decompiled a month 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.Helpers; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [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.8")] [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.8"; private static string configFileName = "DeathWizsh.PavedRoadNoLevel.cfg"; private static string configFileFullPath; public static PavedRoadNoLevel Instance; public ConfigEntry<bool> configEnable; public ConfigEntry<bool> configRequireStoncutter; public CraftingStation stonecutterPiece; private bool firstPatch = true; public void Awake() { Instance = this; InitConfig(); if (configEnable.Value) { PrefabManager.OnVanillaPrefabsAvailable += PatchOriginal; } } public void OnDestroy() { ((BaseUnityPlugin)this).Config.Save(); } 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)); } } private void ApplyConfigChanges() { if (configEnable.Value) { PatchOriginal(); } else { UnpatchOriginal(); } } private void InitConfig() { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Expected O, but got Unknown //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Expected O, but got Unknown //IL_004c: Expected O, but got Unknown //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Expected O, but got Unknown //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Expected O, but got Unknown //IL_00b3: Expected O, but got Unknown try { ((BaseUnityPlugin)this).Config.SaveOnConfigSet = false; configEnable = ((BaseUnityPlugin)this).Config.Bind<bool>(new ConfigDefinition("General", "Enable"), true, new ConfigDescription("Enable this mod", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = false } })); configEnable.SettingChanged += delegate { ApplyConfigChanges(); }; ((BaseUnityPlugin)this).Config.SaveOnConfigSet = true; configRequireStoncutter = ((BaseUnityPlugin)this).Config.Bind<bool>(new ConfigDefinition("General", "Stonecutter requirement"), true, new ConfigDescription("Enable the Stonecutter as a requirement (to pave roads)", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = false } })); configRequireStoncutter.SettingChanged += delegate { ApplyConfigChanges(); }; FileSystemWatcher fileSystemWatcher = new FileSystemWatcher(Paths.ConfigPath, configFileName); fileSystemWatcher.Changed += OnConfigFileChange; fileSystemWatcher.Created += OnConfigFileChange; fileSystemWatcher.Renamed += OnConfigFileChange; fileSystemWatcher.IncludeSubdirectories = true; fileSystemWatcher.SynchronizingObject = ThreadingHelper.SynchronizingObject; fileSystemWatcher.EnableRaisingEvents = true; } catch (Exception ex) { Logger.LogError((object)("Could not initialise the config & events: " + ex)); } } private void OnConfigFileChange(object sender, FileSystemEventArgs e) { if (!File.Exists(configFileFullPath)) { return; } try { ((BaseUnityPlugin)this).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)); } } 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 = (PavedRoadNoLevel.Instance.configRequireStoncutter.Value ? PavedRoadNoLevel.Instance.stonecutterPiece : null); } } }