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 Atlas v1.0.7
Atlas.dll
Decompiled a year agousing System; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using LethalLevelLoader; using LobbyCompatibility.Enums; using LobbyCompatibility.Features; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.Rendering; using UnityEngine.Rendering.HighDefinition; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Runtime")] [assembly: AssemblyCompany("Atlas")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Adds unique HDRI skyboxes/volumes to Lethal Company")] [assembly: AssemblyFileVersion("1.0.7.0")] [assembly: AssemblyInformationalVersion("1.0.7+b88c258f4eb2691d4c26991765afc105d9aaf48a")] [assembly: AssemblyProduct("Atlas")] [assembly: AssemblyTitle("Atlas")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.7.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.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 Atlas { internal static class LobbyCompatibility { internal static void Init() { PluginHelper.RegisterPlugin("dopadream.lethalcompany.atlas", Version.Parse("1.0.7"), (CompatibilityLevel)0, (VersionStrictness)0); } } public class ModConfig { internal static ConfigEntry<bool> configCanyonSky; internal static ConfigEntry<bool> configValleySky; internal static ConfigEntry<bool> configTundraSky; internal static ConfigEntry<bool> configCompanySky; internal static ConfigEntry<bool> configAmethystSky; internal static ConfigEntry<bool> configAmethystFog; internal static ConfigEntry<string> configMoonBlacklist; internal static ConfigEntry<string> configCanyonOverrides; internal static ConfigEntry<string> configValleyOverrides; internal static ConfigEntry<string> configTundraOverrides; internal static ConfigEntry<string> configCompanyOverrides; internal static ConfigEntry<string> configAmethystOverrides; internal static void Init(ConfigFile cfg) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Expected O, but got Unknown //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Expected O, but got Unknown //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Expected O, but got Unknown //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Expected O, but got Unknown //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Expected O, but got Unknown //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Expected O, but got Unknown //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Expected O, but got Unknown //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Expected O, but got Unknown //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Expected O, but got Unknown //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Expected O, but got Unknown //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Expected O, but got Unknown configCanyonSky = cfg.Bind<bool>("General", "Canyon Skies", true, new ConfigDescription("Adds a new HDRI volume to moons tagged with \"Canyon\"", (AcceptableValueBase)null, Array.Empty<object>())); configValleySky = cfg.Bind<bool>("General", "Valley Skies", true, new ConfigDescription("Adds a new HDRI volume to moons tagged with \"Valley\"", (AcceptableValueBase)null, Array.Empty<object>())); configTundraSky = cfg.Bind<bool>("General", "Tundra Skies", true, new ConfigDescription("Adds a new HDRI volume to moons tagged with \"Tundra\"", (AcceptableValueBase)null, Array.Empty<object>())); configCompanySky = cfg.Bind<bool>("General", "Company Skies", true, new ConfigDescription("Adds a new HDRI volume to moons tagged with \"Company\"", (AcceptableValueBase)null, Array.Empty<object>())); configAmethystSky = cfg.Bind<bool>("General", "Amethyst Skies", true, new ConfigDescription("Adds a new HDRI volume to moons tagged with \"Amethyst\"", (AcceptableValueBase)null, Array.Empty<object>())); configAmethystFog = cfg.Bind<bool>("General", "Amethyst Fog", true, new ConfigDescription("Adds extra fog to the new Amethyst sky, applies to both interior and exterior.", (AcceptableValueBase)null, Array.Empty<object>())); configMoonBlacklist = cfg.Bind<string>("Blacklist", "Moon Blacklist", "Experimentation, Artifice", new ConfigDescription("Planet names in this list will not have their skies overwritten. Must be separated by comma.", (AcceptableValueBase)null, Array.Empty<object>())); configCanyonOverrides = cfg.Bind<string>("Overrides", "Canyon", "", new ConfigDescription("Moon names in this list will forcefully load the Canyon profile. Must be separated by comma.", (AcceptableValueBase)null, Array.Empty<object>())); configValleyOverrides = cfg.Bind<string>("Overrides", "Valley", "", new ConfigDescription("Moon names in this list will forcefully load the Valley profile. Must be separated by comma.", (AcceptableValueBase)null, Array.Empty<object>())); configTundraOverrides = cfg.Bind<string>("Overrides", "Tundra", "", new ConfigDescription("Moon names in this list will forcefully load the Tundra profile. Must be separated by comma.", (AcceptableValueBase)null, Array.Empty<object>())); configCompanyOverrides = cfg.Bind<string>("Overrides", "Company", "", new ConfigDescription("Moon names in this list will forcefully load the Company profile. Must be separated by comma.", (AcceptableValueBase)null, Array.Empty<object>())); configAmethystOverrides = cfg.Bind<string>("Overrides", "Amethyst", "", new ConfigDescription("Moon names in this list will forcefully load the Amethyst profile. Must be separated by comma.", (AcceptableValueBase)null, Array.Empty<object>())); } } [BepInPlugin("dopadream.lethalcompany.atlas", "Atlas", "1.0.7")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { [HarmonyPatch] internal class AtlasPatches { [HarmonyPatch(typeof(RoundManager), "FinishGeneratingNewLevelClientRpc")] [HarmonyPostfix] private static void PostFinishGeneratingNewLevelClientRpc(RoundManager __instance) { ApplySky(); } } internal const string PLUGIN_GUID = "dopadream.lethalcompany.atlas"; internal const string PLUGIN_NAME = "Atlas"; internal const string PLUGIN_VERSION = "1.0.7"; internal const string LOBBY_COMPATIBILITY = "BMX.LobbyCompatibility"; internal static ManualLogSource Logger; internal static VolumeProfile canyonProfile; internal static VolumeProfile valleyProfile; internal static VolumeProfile tundraProfile; internal static VolumeProfile amethystProfile; internal static VolumeProfile companyProfile; internal static AssetBundle hdriSkies; private void Awake() { //IL_0040: Unknown result type (might be due to invalid IL or missing references) Logger = ((BaseUnityPlugin)this).Logger; if (Chainloader.PluginInfos.ContainsKey("BMX.LobbyCompatibility")) { Logger.LogInfo((object)"CROSS-COMPATIBILITY - Lobby Compatibility detected"); LobbyCompatibility.Init(); } ModConfig.Init(((BaseUnityPlugin)this).Config); new Harmony("dopadream.lethalcompany.atlas").PatchAll(); Logger.LogInfo((object)"Atlas v1.0.7 loaded"); } internal static void ApplySky() { Logger.LogDebug((object)"Starting ApplySky..."); string[] array = ModConfig.configMoonBlacklist.Value.Split(','); for (int i = 0; i < array.Length; i++) { array[i] = array[i].Trim(); } Logger.LogDebug((object)("Blacklist contains: " + string.Join(", ", array))); Volume[] array2 = Object.FindObjectsByType<Volume>((FindObjectsSortMode)0); Logger.LogDebug((object)$"Found {array2.Length} volumes."); if (Chainloader.PluginInfos.ContainsKey("imabatby.lethallevelloader")) { initLLL(array, array2); } else { initVanilla(array, array2); } Logger.LogDebug((object)"Finished ApplySky."); } private static void initLLL(string[] blackList, Volume[] volumes) { if (blackList == null || volumes == null) { Logger.LogError((object)"Blacklist or volumes array is null."); return; } if (blackList.Contains(LevelManager.CurrentExtendedLevel.NumberlessPlanetName)) { Logger.LogDebug((object)"Skipping volume change because current planet is in blacklist"); return; } if (volumes.Length == 0) { Logger.LogDebug((object)"Skipping volume change because no volumes could be found"); return; } HDRISky val2 = default(HDRISky); foreach (Volume val in volumes) { if ((Object)(object)val == (Object)null) { Logger.LogDebug((object)"Skipping volume because it's null."); continue; } if ((Object)(object)val.sharedProfile == (Object)null) { Logger.LogDebug((object)"Skipping volume because sharedProfile is null."); continue; } if (!val.sharedProfile.TryGet<HDRISky>(ref val2)) { Logger.LogDebug((object)"Skipping volume change because no HDRISky component could be found"); continue; } if ((Object)(object)hdriSkies == (Object)null) { try { Logger.LogDebug((object)"Loading asset bundle 'hdri_skies'..."); string text = Assembly.GetExecutingAssembly()?.Location; if (text == null) { Logger.LogError((object)"Failed to get assembly location."); break; } hdriSkies = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(text), "hdri_skies")); if ((Object)(object)hdriSkies == (Object)null) { Logger.LogError((object)"Failed to load asset bundle: AssetBundle is null."); break; } Logger.LogDebug((object)"Successfully loaded asset bundle."); } catch (Exception ex) { Logger.LogError((object)("Failed to load asset bundle 'hdri_skies': " + ex.Message)); break; } } ConfigEntry<string>[] array = new ConfigEntry<string>[5] { ModConfig.configCanyonOverrides, ModConfig.configValleyOverrides, ModConfig.configTundraOverrides, ModConfig.configCompanyOverrides, ModConfig.configAmethystOverrides }; int num = 0; while (true) { if (num < array.Length) { ConfigEntry<string> val3 = array[num]; if (!(val3.Value == "")) { string[] array2 = val3.Value.Split(','); for (int j = 0; j < array2.Length; j++) { array2[j] = array2[j].Trim(); } if (array2.Contains(LevelManager.CurrentExtendedLevel.NumberlessPlanetName)) { switch (((ConfigEntryBase)val3).Definition.Key) { case "Canyon": ChangeProfileIfAvailable("Canyon", val); break; case "Valley": ChangeProfileIfAvailable("Valley", val); break; case "Tundra": ChangeProfileIfAvailable("Tundra", val); break; case "Company": ChangeProfileIfAvailable("Company", val); break; case "Amethyst": ChangeProfileIfAvailable("Amethyst", val); break; default: goto IL_02b8; } break; } } goto IL_02b8; } object obj; if (val2 == null) { obj = null; } else { CubemapParameter hdriSky = val2.hdriSky; if (hdriSky == null) { obj = null; } else { Texture value = ((VolumeParameter<Texture>)(object)hdriSky).value; obj = ((value != null) ? ((Object)value).name : null); } } if ((string?)obj != "cedar_bridge_4k") { break; } ExtendedLevel currentExtendedLevel = LevelManager.CurrentExtendedLevel; if (((currentExtendedLevel != null) ? ((ExtendedContent)currentExtendedLevel).ContentTags : null) == null) { Logger.LogError((object)"ContentTags is null."); return; } foreach (ContentTag contentTag in ((ExtendedContent)LevelManager.CurrentExtendedLevel).ContentTags) { if (contentTag == null || ((Object)contentTag).name == null) { Logger.LogDebug((object)"Skipping tag because it's null."); continue; } string name = ((Object)contentTag).name; Logger.LogDebug((object)("Processing tag: " + name)); switch (name) { case "CanyonContentTag": { ConfigEntry<bool> configCanyonSky = ModConfig.configCanyonSky; if (configCanyonSky != null && configCanyonSky.Value) { ChangeProfileIfAvailable("Canyon", val); } break; } case "ValleyContentTag": { ConfigEntry<bool> configValleySky = ModConfig.configValleySky; if (configValleySky != null && configValleySky.Value) { ChangeProfileIfAvailable("Valley", val); } break; } case "TundraContentTag": { ConfigEntry<bool> configTundraSky = ModConfig.configTundraSky; if (configTundraSky != null && configTundraSky.Value) { ChangeProfileIfAvailable("Tundra", val); } break; } } if (LevelManager.CurrentExtendedLevel.NumberlessPlanetName == "Embrion" || name == "AmethystContentTag" || name == "AmythestContentTag") { ConfigEntry<bool> configAmethystSky = ModConfig.configAmethystSky; if (configAmethystSky != null && !configAmethystSky.Value) { return; } ChangeProfileIfAvailable("Amethyst", val); } if (LevelManager.CurrentExtendedLevel.NumberlessPlanetName == "Gordion" || name == "CompanyContentTag") { ConfigEntry<bool> configCompanySky = ModConfig.configCompanySky; if (configCompanySky != null && !configCompanySky.Value) { return; } ChangeProfileIfAvailable("Company", val); } } break; IL_02b8: num++; } } } private static void initVanilla(string[] blackList, Volume[] volumes) { //IL_058a: Unknown result type (might be due to invalid IL or missing references) Logger.LogDebug((object)"LLL missing! Falling back to vanilla moon support..."); string sceneName = StartOfRound.Instance.currentLevel.sceneName; if (blackList.Contains(GetNumberlessPlanetName(StartOfRound.Instance.currentLevel))) { Logger.LogDebug((object)"Skipping volume change because current planet is in blacklist"); return; } if (volumes == null || volumes.Length == 0) { Logger.LogDebug((object)"Skipping volume change because no volumes could be found"); return; } HDRISky val2 = default(HDRISky); HDRISky val4 = default(HDRISky); HDRISky val5 = default(HDRISky); HDRISky val6 = default(HDRISky); HDRISky val7 = default(HDRISky); foreach (Volume val in volumes) { if ((Object)(object)val?.sharedProfile == (Object)null) { Logger.LogDebug((object)"Skipping volume because it's null or sharedProfile is null."); } else if (val.sharedProfile.TryGet<HDRISky>(ref val2)) { if (((Object)((VolumeParameter<Texture>)(object)val2.hdriSky).value).name != "cedar_bridge_4k") { continue; } if ((Object)(object)hdriSkies == (Object)null) { try { Logger.LogDebug((object)"Loading asset bundle 'hdri_skies'..."); hdriSkies = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "hdri_skies")); Logger.LogDebug((object)"Successfully loaded asset bundle."); } catch (Exception ex) { Logger.LogError((object)("Failed to load asset bundle 'hdri_skies': " + ex.Message)); break; } } VolumeProfile val3 = (VolumeProfile)(sceneName switch { "Level7Offense" => ModConfig.configCanyonSky.Value ? LoadProfile(ref canyonProfile, "CanyonSky") : null, "Level2Assurance" => ModConfig.configCanyonSky.Value ? LoadProfile(ref canyonProfile, "CanyonSky") : null, "Level3Vow" => ModConfig.configValleySky.Value ? LoadProfile(ref valleyProfile, "ValleySky") : null, "Level4March" => ModConfig.configValleySky.Value ? LoadProfile(ref valleyProfile, "ValleySky") : null, "Level10Adamance" => ModConfig.configValleySky.Value ? LoadProfile(ref valleyProfile, "ValleySky") : null, "Level5Rend" => ModConfig.configTundraSky.Value ? LoadProfile(ref tundraProfile, "TundraSky") : null, "Level6Dine" => ModConfig.configTundraSky.Value ? LoadProfile(ref tundraProfile, "TundraSky") : null, "Level8Titan" => ModConfig.configTundraSky.Value ? LoadProfile(ref tundraProfile, "TundraSky") : null, "CompanyBuilding" => ModConfig.configCompanySky.Value ? LoadProfile(ref companyProfile, "CompanySky") : null, "Level11Embrion" => ModConfig.configAmethystSky.Value ? LoadProfile(ref amethystProfile, "AmethystSky") : null, _ => null, }); if (!((Object)val).name.StartsWith("Sky and Fog")) { continue; } if ((Object)(object)val3 != (Object)null && val.sharedProfile.TryGet<HDRISky>(ref val4) && val3.TryGet<HDRISky>(ref val5)) { Logger.LogDebug((object)("Applying " + ((Object)((VolumeParameter<Texture>)(object)val5.hdriSky).value).name + " to sky: " + ((Object)val4).name)); ((VolumeParameter<Texture>)(object)val4.hdriSky).value = ((VolumeParameter<Texture>)(object)val5.hdriSky).value; } if (GetNumberlessPlanetName(StartOfRound.Instance.currentLevel) == "Embrion" && (Object)(object)val3 != (Object)null) { ConfigEntry<bool> configAmethystSky = ModConfig.configAmethystSky; if (configAmethystSky != null && !configAmethystSky.Value) { break; } if (((Object)val).name.Equals("Sky and Fog Global Volume")) { Logger.LogDebug((object)("Applying profile to volume: " + ((Object)val).name)); val.sharedProfile = LoadProfile(ref amethystProfile, "AmethystSky"); } else if (((Object)val).name.Equals("Sky and Fog Global Volume (1)") && val.sharedProfile.TryGet<HDRISky>(ref val6) && LoadProfile(ref amethystProfile, "AmethystSky").TryGet<HDRISky>(ref val7)) { ((VolumeParameter<Texture>)(object)val6.hdriSky).value = ((VolumeParameter<Texture>)(object)val7.hdriSky).value; val6.distortionMode.value = val7.distortionMode.value; } } if (GetNumberlessPlanetName(StartOfRound.Instance.currentLevel) == "Gordion") { ConfigEntry<bool> configCompanySky = ModConfig.configCompanySky; if (configCompanySky != null && !configCompanySky.Value) { break; } if (((Object)val).name.Equals("Sky and Fog Global Volume")) { Logger.LogDebug((object)("Applying profile to volume: " + ((Object)val).name)); val.sharedProfile = LoadProfile(ref companyProfile, "CompanySky"); } } } else { Logger.LogDebug((object)"Skipping volume change because no HDRISky component could be found"); } } } internal static void ChangeProfileIfAvailable(string TagName, Volume volume) { //IL_01f1: Unknown result type (might be due to invalid IL or missing references) HDRISky val = default(HDRISky); if (!((Object)(object)volume?.sharedProfile == (Object)null) && volume.sharedProfile.TryGet<HDRISky>(ref val)) { Logger.LogDebug((object)("Applying profile to volume: " + ((Object)volume).name)); VolumeProfile val2 = (VolumeProfile)(TagName switch { "Canyon" => LoadProfile(ref canyonProfile, "CanyonSky"), "Valley" => LoadProfile(ref valleyProfile, "ValleySky"), "Tundra" => LoadProfile(ref tundraProfile, "TundraSky"), "Amethyst" => LoadProfile(ref amethystProfile, "AmethystSky"), "Company" => LoadProfile(ref companyProfile, "CompanySky"), _ => null, }); HDRISky val3 = default(HDRISky); if ((Object)(object)val2 == (Object)null) { Logger.LogDebug((object)("No profile found for tag: " + TagName)); } else if ((TagName == "Amethyst" || TagName == "Company") && ((Object)volume).name == "Sky and Fog Global Volume") { volume.sharedProfile = val2; } else if (!val2.TryGet<HDRISky>(ref val3) || (Object)(object)((VolumeParameter<Texture>)(object)val3?.hdriSky)?.value == (Object)null) { Logger.LogDebug((object)("Skipping profile application for tag: " + TagName + " due to missing HDRISky.")); } else if (((Object)volume).name == "Sky and Fog Global Volume" || ((Object)volume).name == "Sky and Fog Global Volume (1)") { Logger.LogDebug((object)(((Object)((VolumeParameter<Texture>)(object)val.hdriSky).value).name + " replaced with " + ((Object)((VolumeParameter<Texture>)(object)val3.hdriSky).value).name)); ((VolumeParameter<Texture>)(object)val.hdriSky).value = ((VolumeParameter<Texture>)(object)val3.hdriSky).value; val.distortionMode.value = val3.distortionMode.value; ((VolumeParameter<float>)(object)((SkySettings)val).rotation).value = ((VolumeParameter<float>)(object)((SkySettings)val3).rotation).value; } } } internal static string GetNumberlessPlanetName(SelectableLevel selectableLevel) { if ((Object)(object)selectableLevel != (Object)null) { return new string(selectableLevel.PlanetName.SkipWhile((char c) => !char.IsLetter(c)).ToArray()); } return string.Empty; } private static VolumeProfile LoadProfile(ref VolumeProfile profile, string assetName) { if ((Object)(object)profile == (Object)null) { try { Logger.LogDebug((object)("Loading profile '" + assetName + "' from asset bundle...")); profile = hdriSkies.LoadAsset<VolumeProfile>(assetName); Logger.LogDebug((object)("Successfully loaded profile '" + assetName + "'.")); } catch (Exception ex) { Logger.LogError((object)("Failed to load asset '" + assetName + "' from bundle 'hdri_skies': " + ex.Message)); } } Fog val = default(Fog); if (((Object)profile).name.StartsWith("Amethyst") && !ModConfig.configAmethystFog.Value && profile.TryGet<Fog>(ref val)) { ((VolumeComponent)val).active = false; } return profile; } } public static class PluginInfo { public const string PLUGIN_GUID = "Atlas"; public const string PLUGIN_NAME = "Atlas"; public const string PLUGIN_VERSION = "1.0.7"; } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }