Decompiled source of SkyCustomLevelSizes Skydorm v0.0.2

plugins/SkyChangeModuleSize.dll

Decompiled a month ago
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using Newtonsoft.Json;
using UnityEngine;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("SkyChangeModuleSize")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SkyChangeModuleSize")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("74eb5aae-2b80-4e14-b616-24649964c125")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
[BepInPlugin("com.skychangemodulesize", "SkyChange Module Width", "0.0.2")]
public class SkyChangeModuleSize : BaseUnityPlugin
{
	public class ModuleWidthConfig
	{
		public float ModuleWidthSize = 3f;
	}

	private void Awake()
	{
		SceneManager.sceneLoaded += OnSceneLoaded;
		((BaseUnityPlugin)this).Logger.LogInfo((object)"SkyChangeModuleSize loaded.");
	}

	private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
	{
		if (((Scene)(ref scene)).name == "Main")
		{
			ApplyCustomModuleWidth();
		}
	}

	private void ApplyCustomModuleWidth()
	{
		try
		{
			if (!((Object)(object)RunManager.instance.levelCurrent != (Object)null))
			{
				return;
			}
			string name = ((Object)RunManager.instance.levelCurrent).name;
			string searchPattern = name + "Size.json";
			string text = Directory.GetFiles(Paths.PluginPath, searchPattern, SearchOption.AllDirectories).FirstOrDefault();
			if (!string.IsNullOrEmpty(text))
			{
				string text2 = File.ReadAllText(text);
				ModuleWidthConfig moduleWidthConfig = JsonConvert.DeserializeObject<ModuleWidthConfig>(text2);
				if (moduleWidthConfig != null)
				{
					LevelGenerator.ModuleWidth = moduleWidthConfig.ModuleWidthSize;
				}
			}
			else
			{
				Debug.LogWarning((object)("[SkyModuleSize] No File " + name + " found. Use Standard for level (3x3)."));
				LevelGenerator.ModuleWidth = 3f;
			}
		}
		catch (Exception arg)
		{
			((BaseUnityPlugin)this).Logger.LogError((object)$"[SkyModuleSize] Error setting ModuleWidth: {arg}");
		}
	}
}