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 ValheimVisualEnhanced v0.5.7
plugins/ValheimVisualEnhanced/ValheimVisualEnhanced.dll
Decompiled 2 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using CloudShadows; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.Rendering; using UnityEngine.SceneManagement; [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("ValheimVisualEnhanced")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.5.7.0")] [assembly: AssemblyInformationalVersion("0.5.7+7fbb0c79423edaa152e4543abbce714abfa24e7f")] [assembly: AssemblyProduct("ValheimVisualEnhanced")] [assembly: AssemblyTitle("ValheimVisualEnhanced")] [assembly: AssemblyVersion("0.5.7.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [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 ValheimVisualEnhanced { [BepInPlugin("dev.local.valheimvisualenhanced", "Valheim Visual Enhanced", "0.5.7")] [BepInProcess("valheim.exe")] public class ValheimVisualEnhancedPlugin : BaseUnityPlugin { private CloudShadowsConfig _settings; private CloudShadowsPostEffect _postEffect; private EnvironmentPaletteController _environmentPalette; private MeadowsFirefliesEffect _meadowsFireflies; private CloudShadowsErrorLimiter _errorLimiter; private bool _lastEnabled; private bool _hasObservedEnabled; private bool _lastEnvironmentPaletteEnabled; private bool _hasObservedEnvironmentPaletteEnabled; private void Awake() { _errorLimiter = new CloudShadowsErrorLimiter(((BaseUnityPlugin)this).Logger); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Valheim Visual Enhanced 0.5.7 loaded"); try { string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location); _settings = new CloudShadowsConfig(((BaseUnityPlugin)this).Config); _lastEnabled = _settings.Enabled; _hasObservedEnabled = true; _lastEnvironmentPaletteEnabled = _settings.EnvironmentPaletteEnabled; _hasObservedEnvironmentPaletteEnabled = true; _environmentPalette = new EnvironmentPaletteController(((BaseUnityPlugin)this).Logger, _settings); _meadowsFireflies = new MeadowsFirefliesEffect(((BaseUnityPlugin)this).Logger, _settings); _postEffect = new CloudShadowsPostEffect(((BaseUnityPlugin)this).Logger, directoryName, _settings); ((BaseUnityPlugin)this).Logger.LogDebug((object)"Valheim Visual Enhanced render initialization deferred until a world is loaded"); } catch (Exception exception) { LogError("Valheim Visual Enhanced post-effect initialization failed", exception); } } private void Update() { HandlePostEffect(); HandleDiagnosticDump(); } private void HandlePostEffect() { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) try { KeyboardShortcut val; if (_settings != null) { val = _settings.ToggleEnabledShortcut; if (((KeyboardShortcut)(ref val)).IsDown()) { _settings.ToggleEnabled(); ((BaseUnityPlugin)this).Logger.LogInfo((object)$"Valheim Visual Enhanced shortcut: Enabled={_settings.Enabled}"); } } if (_settings != null) { val = _settings.ToggleDebugMaskShortcut; if (((KeyboardShortcut)(ref val)).IsDown()) { _settings.ToggleDebugMaskView(); ((BaseUnityPlugin)this).Logger.LogInfo((object)$"Valheim Visual Enhanced shortcut: DebugMaskView={_settings.DebugMaskView}"); } } if (_settings != null) { val = _settings.ToggleEnvironmentPaletteShortcut; if (((KeyboardShortcut)(ref val)).IsDown()) { _settings.ToggleEnvironmentPalette(); ((BaseUnityPlugin)this).Logger.LogInfo((object)("Valheim Visual Enhanced shortcut: " + $"EnhancedEnvironment={_settings.EnvironmentPaletteEnabled}")); } } ShowEnabledNotificationIfChanged(); ShowEnvironmentPaletteNotificationIfChanged(); _postEffect?.Tick(); _meadowsFireflies?.Tick(); } catch (Exception exception) { LogError("Valheim Visual Enhanced post-effect hotkey handler failed", exception); } } private void HandleDiagnosticDump() { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) try { if (_settings == null) { return; } KeyboardShortcut diagnosticDumpShortcut = _settings.DiagnosticDumpShortcut; if (!((KeyboardShortcut)(ref diagnosticDumpShortcut)).IsDown()) { return; } Scene activeScene = SceneManager.GetActiveScene(); if (!((Scene)(ref activeScene)).IsValid() || !((Scene)(ref activeScene)).isLoaded) { ((BaseUnityPlugin)this).Logger.LogWarning((object)"Valheim Visual Enhanced debug dump skipped: the active scene is not loaded"); return; } string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location); CloudShadowsRuntimeSnapshot cloudShadowsRuntimeSnapshot = _postEffect?.CreateDiagnosticsSnapshot(); if (cloudShadowsRuntimeSnapshot != null) { cloudShadowsRuntimeSnapshot.EnvironmentPalette = _environmentPalette?.CreateSnapshot(); cloudShadowsRuntimeSnapshot.MeadowsFireflies = _meadowsFireflies?.CreateSnapshot(); } CloudShadowsDiagnostics.WriteDump(((BaseUnityPlugin)this).Logger, directoryName, cloudShadowsRuntimeSnapshot); } catch (Exception exception) { LogError("Valheim Visual Enhanced diagnostic shortcut handler failed", exception); } } private void ShowEnabledNotificationIfChanged() { if (_settings == null) { return; } bool enabled = _settings.Enabled; if (!_hasObservedEnabled) { _lastEnabled = enabled; _hasObservedEnabled = true; } else if (_lastEnabled != enabled) { _lastEnabled = enabled; MessageHud instance = MessageHud.instance; if (!((Object)(object)instance == (Object)null)) { instance.ShowMessage((MessageType)1, enabled ? "Cloud shadows enabled" : "Cloud shadows disabled", 0, (Sprite)null, false, true); } } } private void ShowEnvironmentPaletteNotificationIfChanged() { if (_settings == null) { return; } bool environmentPaletteEnabled = _settings.EnvironmentPaletteEnabled; if (!_hasObservedEnvironmentPaletteEnabled) { _lastEnvironmentPaletteEnabled = environmentPaletteEnabled; _hasObservedEnvironmentPaletteEnabled = true; } else if (_lastEnvironmentPaletteEnabled != environmentPaletteEnabled) { _lastEnvironmentPaletteEnabled = environmentPaletteEnabled; MessageHud instance = MessageHud.instance; if (!((Object)(object)instance == (Object)null)) { instance.ShowMessage((MessageType)1, environmentPaletteEnabled ? "Enhanced Environment enabled" : "Enhanced Environment disabled", 0, (Sprite)null, false, true); } } } private void OnDestroy() { CloudShadowsPostEffect postEffect = _postEffect; EnvironmentPaletteController environmentPalette = _environmentPalette; MeadowsFirefliesEffect meadowsFireflies = _meadowsFireflies; CloudShadowsConfig settings = _settings; _postEffect = null; _environmentPalette = null; _meadowsFireflies = null; _settings = null; _hasObservedEnabled = false; _hasObservedEnvironmentPaletteEnabled = false; try { meadowsFireflies?.Dispose(); } catch (Exception exception) { LogError("Valheim Visual Enhanced Meadows fireflies cleanup failed", exception); } try { environmentPalette?.Dispose(); } catch (Exception exception2) { LogError("Valheim Visual Enhanced environment palette cleanup failed", exception2); } try { postEffect?.Dispose(); } catch (Exception exception3) { LogError("Valheim Visual Enhanced post-effect cleanup failed", exception3); } try { settings?.Dispose(); } catch (Exception exception4) { LogError("Valheim Visual Enhanced config cleanup failed", exception4); } } private void LogError(string context, Exception exception) { CloudShadowsErrorLimiter errorLimiter = _errorLimiter; if (errorLimiter != null) { errorLimiter.LogError(context, exception); return; } try { ((BaseUnityPlugin)this).Logger.LogError((object)$"{context}: {exception}"); } catch { } } } } namespace CloudShadows { internal enum CloudMaskQuality { Low512 = 0x200, Balanced1024 = 0x400, High2048 = 0x800 } internal enum EnhancedEnvironmentPreset { GoldenSaga, VerdantWilds, Frostbound, Emberfall, AuroraVeil, Custom } internal enum LegacyFantasyEnvironmentPreset { GoldenSaga, VerdantWilds, Frostbound, Custom } internal sealed class CloudShadowsConfig : IDisposable { private sealed class PaletteColorEntries { private readonly ConfigEntry<float> _redEntry; private readonly ConfigEntry<float> _greenEntry; private readonly ConfigEntry<float> _blueEntry; internal Color Value => new Color(_redEntry.Value / 255f, _greenEntry.Value / 255f, _blueEntry.Value / 255f, 1f); internal PaletteColorEntries(ConfigEntry<float> redEntry, ConfigEntry<float> greenEntry, ConfigEntry<float> blueEntry) { _redEntry = redEntry; _greenEntry = greenEntry; _blueEntry = blueEntry; } internal void MigrateLegacyValues(ConfigFile config, string name) { MigrateLegacySetting<float>(config, "Fantasy Environment", name + "Red", _redEntry); MigrateLegacySetting<float>(config, "Fantasy Environment", name + "Green", _greenEntry); MigrateLegacySetting<float>(config, "Fantasy Environment", name + "Blue", _blueEntry); } internal void Subscribe(EventHandler handler) { _redEntry.SettingChanged += handler; _greenEntry.SettingChanged += handler; _blueEntry.SettingChanged += handler; } internal void Unsubscribe(EventHandler handler) { _redEntry.SettingChanged -= handler; _greenEntry.SettingChanged -= handler; _blueEntry.SettingChanged -= handler; } } private const int CurrentConfigSchemaVersion = 4; private const string GeneralSection = "General"; private const string HotkeysSection = "Hotkeys"; private const string CloudShadowsSection = "Cloud Shadows"; private const string WaterCausticLightingSection = "Water Caustic Lighting"; private const string EnvironmentPaletteSection = "Enhanced Environment"; private const string LegacyEnvironmentPaletteSection = "Fantasy Environment"; private const string MeadowsFirefliesSection = "Meadows Fireflies"; private const string AutomationSection = "Automation"; private static readonly ConfigDescription LegacyMigrationDescription = new ConfigDescription("Legacy Enhanced Environment setting used only during migration.", (AcceptableValueBase)null, new object[0]); private readonly ConfigFile _config; private readonly bool _hasLegacyEnvironmentPaletteSection; private readonly ConfigEntry<bool> _enabledEntry; private readonly ConfigEntry<bool> _debugMaskViewEntry; private readonly ConfigEntry<int> _configSchemaVersionEntry; private readonly ConfigEntry<bool> _leaveRequestedDepthModeEntry; private readonly ConfigEntry<KeyboardShortcut> _toggleEnabledShortcutEntry; private readonly ConfigEntry<KeyboardShortcut> _diagnosticDumpShortcutEntry; private readonly ConfigEntry<KeyboardShortcut> _toggleDebugMaskShortcutEntry; private readonly ConfigEntry<KeyboardShortcut> _toggleEnvironmentPaletteShortcutEntry; private readonly ConfigEntry<float> _shadowStrengthEntry; private readonly ConfigEntry<float> _cloudSizeMetersEntry; private readonly ConfigEntry<float> _edgeSoftnessEntry; private readonly ConfigEntry<float> _cloudCoverageEntry; private readonly ConfigEntry<float> _shadowDrawDistanceEntry; private readonly ConfigEntry<CloudMaskQuality> _cloudMaskQualityEntry; private readonly ConfigEntry<float> _windSpeedMultiplierEntry; private readonly ConfigEntry<bool> _migrateLegacyCloudCoverageEntry; private readonly ConfigEntry<bool> _causticsEnabledEntry; private readonly ConfigEntry<float> _causticsIntensityEntry; private readonly ConfigEntry<float> _causticsPatternSizeMetersEntry; private readonly ConfigEntry<float> _causticsAnimationSpeedEntry; private readonly ConfigEntry<bool> _causticsFlowingMotionEntry; private readonly ConfigEntry<float> _causticsMaximumDepthMetersEntry; private readonly ConfigEntry<float> _causticsDrawDistanceMetersEntry; private readonly ConfigEntry<bool> _environmentPaletteEnabledEntry; private readonly ConfigEntry<float> _environmentPaletteStrengthEntry; private readonly ConfigEntry<EnhancedEnvironmentPreset> _environmentPalettePresetEntry; private readonly ConfigEntry<bool> _environmentPaletteOverrideSunAngleEntry; private readonly ConfigEntry<float> _environmentPaletteSunAngleEntry; private readonly PaletteColorEntries _morningSunColorEntries; private readonly PaletteColorEntries _morningFogColorEntries; private readonly PaletteColorEntries _daySunColorEntries; private readonly PaletteColorEntries _dayFogColorEntries; private readonly PaletteColorEntries _eveningSunColorEntries; private readonly PaletteColorEntries _eveningFogColorEntries; private readonly PaletteColorEntries _nightSunColorEntries; private readonly PaletteColorEntries _nightFogColorEntries; private readonly ConfigEntry<bool> _meadowsFirefliesEnabledEntry; private readonly ConfigEntry<int> _meadowsFirefliesParticleCountEntry; private readonly ConfigEntry<float> _meadowsFirefliesRadiusMetersEntry; private readonly ConfigEntry<float> _meadowsFirefliesBrightnessEntry; private readonly ConfigEntry<bool> _autoDisableAtNightEntry; private readonly ConfigEntry<bool> _autoDisableInRainEntry; private readonly ConfigEntry<bool> _autoDisableUnderRoofEntry; private readonly ConfigEntry<bool> _autoDisableMeadowsFirefliesUnderRoofEntry; private bool _applyingConfigMigration; internal bool Enabled { get; private set; } internal bool DebugMaskView { get; private set; } internal int ConfigSchemaVersion { get; private set; } internal bool LeaveRequestedDepthModeForCompatibility { get; private set; } internal KeyboardShortcut ToggleEnabledShortcut { get; private set; } internal KeyboardShortcut DiagnosticDumpShortcut { get; private set; } internal KeyboardShortcut ToggleDebugMaskShortcut { get; private set; } internal KeyboardShortcut ToggleEnvironmentPaletteShortcut { get; private set; } internal float ShadowStrength { get; private set; } internal float CloudSizeMeters { get; private set; } internal float EdgeSoftness { get; private set; } internal float CloudCoverage { get; private set; } internal float ShadowDrawDistance { get; private set; } internal CloudMaskQuality CloudMaskQuality { get; private set; } internal int CloudMaskResolution => (int)CloudMaskQuality; internal float WindSpeedMultiplier { get; private set; } internal bool CausticsEnabled { get; private set; } internal float CausticsIntensity { get; private set; } internal float CausticsPatternSizeMeters { get; private set; } internal float CausticsAnimationSpeed { get; private set; } internal bool CausticsFlowingMotion { get; private set; } internal float CausticsMaximumDepthMeters { get; private set; } internal float CausticsDrawDistanceMeters { get; private set; } internal bool EnvironmentPaletteEnabled { get; private set; } internal float EnvironmentPaletteStrength { get; private set; } internal EnhancedEnvironmentPreset EnvironmentPalettePreset { get; private set; } internal bool EnvironmentPaletteOverrideSunAngle { get; private set; } internal float EnvironmentPaletteSunAngle { get; private set; } internal Color EnvironmentPaletteMorningSunColor { get; private set; } internal Color EnvironmentPaletteMorningFogColor { get; private set; } internal Color EnvironmentPaletteDaySunColor { get; private set; } internal Color EnvironmentPaletteDayFogColor { get; private set; } internal Color EnvironmentPaletteEveningSunColor { get; private set; } internal Color EnvironmentPaletteEveningFogColor { get; private set; } internal Color EnvironmentPaletteNightSunColor { get; private set; } internal Color EnvironmentPaletteNightFogColor { get; private set; } internal bool MeadowsFirefliesEnabled { get; private set; } internal int MeadowsFirefliesParticleCount { get; private set; } internal float MeadowsFirefliesRadiusMeters { get; private set; } internal float MeadowsFirefliesBrightness { get; private set; } internal bool AutoDisableAtNight { get; private set; } internal bool AutoDisableInRain { get; private set; } internal bool AutoDisableUnderRoof { get; private set; } internal bool AutoDisableMeadowsFirefliesUnderRoof { get; private set; } internal int Revision { get; private set; } internal CloudShadowsConfig(ConfigFile config) { //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_0609: Unknown result type (might be due to invalid IL or missing references) //IL_0633: Unknown result type (might be due to invalid IL or missing references) //IL_065d: Unknown result type (might be due to invalid IL or missing references) //IL_0687: Unknown result type (might be due to invalid IL or missing references) //IL_06b1: Unknown result type (might be due to invalid IL or missing references) //IL_06db: Unknown result type (might be due to invalid IL or missing references) //IL_0705: Unknown result type (might be due to invalid IL or missing references) //IL_072f: Unknown result type (might be due to invalid IL or missing references) if (config == null) { throw new ArgumentNullException("config"); } _config = config; _hasLegacyEnvironmentPaletteSection = HasConfigSection(config.ConfigFilePath, "Fantasy Environment"); _enabledEntry = config.Bind<bool>("General", "Enabled", true, CreateDescription("General", "Enables or disables cloud shadows.", null, 200)); _debugMaskViewEntry = config.Bind<bool>("General", "DebugMaskView", false, CreateDescription("General", "Shows the raw cloud pattern as a black-and-white mask.", null, 190)); _configSchemaVersionEntry = config.Bind<int>("General", "ConfigSchemaVersion", 4, CreateDescription("General", "Tracks configuration migrations. Do not edit manually.", null, -100)); _leaveRequestedDepthModeEntry = config.Bind<bool>("General", "LeaveRequestedDepthModeForCompatibility", false, CreateDescription("General", "Leaves a Depth texture request on the main camera after disabling Valheim Visual Enhanced. Enable only if another visual mod relies on it.", null, -90)); _toggleEnabledShortcutEntry = config.Bind<KeyboardShortcut>("Hotkeys", "ToggleEnabled", KeyboardShortcut.Empty, CreateDescription("Hotkeys", "Toggles cloud shadows. No shortcut is assigned by default.", null, 180)); _diagnosticDumpShortcutEntry = config.Bind<KeyboardShortcut>("Hotkeys", "WriteDiagnosticDump", KeyboardShortcut.Empty, CreateDescription("Hotkeys", "Writes the complete diagnostic dump. No shortcut is assigned by default.", null, 170)); _toggleDebugMaskShortcutEntry = config.Bind<KeyboardShortcut>("Hotkeys", "ToggleDebugMaskView", KeyboardShortcut.Empty, CreateDescription("Hotkeys", "Toggles the raw cloud-mask view. No shortcut is assigned by default.", null, 160)); _toggleEnvironmentPaletteShortcutEntry = config.Bind<KeyboardShortcut>("Hotkeys", "ToggleEnhancedEnvironment", KeyboardShortcut.Empty, CreateDescription("Hotkeys", "Toggles Enhanced Environment. No shortcut is assigned by default.", null, 150)); _shadowStrengthEntry = config.Bind<float>("Cloud Shadows", "ShadowStrength", 1.45f, CreateDescription("Cloud Shadows", "Controls the visibility and darkness of cloud shadows.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 2f), 180)); _cloudSizeMetersEntry = config.Bind<float>("Cloud Shadows", "CloudSizeMeters", 85f, CreateDescription("Cloud Shadows", "Controls the approximate size of one cloud shadow patch in meters.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(20f, 300f), 170)); _edgeSoftnessEntry = config.Bind<float>("Cloud Shadows", "EdgeSoftness", 0.035f, CreateDescription("Cloud Shadows", "Controls the softness and blur of cloud shadow edges.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.01f, 0.5f), 160)); _cloudCoverageEntry = config.Bind<float>("Cloud Shadows", "CloudCoverage", 0.4f, CreateDescription("Cloud Shadows", "Controls how much of the world is covered by cloud shadows. 0 disables coverage; 1 gives maximum coverage.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), 150)); _shadowDrawDistanceEntry = config.Bind<float>("Cloud Shadows", "ShadowDrawDistance", 365f, CreateDescription("Cloud Shadows", "Sets the approximate projected radius of the cloud shadow mask. Shadows fade smoothly near the limit.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(100f, 2000f), 140)); _cloudMaskQualityEntry = config.Bind<CloudMaskQuality>("Cloud Shadows", "MaskQuality", CloudMaskQuality.Low512, CreateDescription("Cloud Shadows", "Controls the cloud-mask resolution. Higher quality uses more GPU memory and bandwidth.", null, 135)); _windSpeedMultiplierEntry = config.Bind<float>("Cloud Shadows", "WindSpeedMultiplier", 0.8f, CreateDescription("Cloud Shadows", "Multiplies the cloud shadow drift speed from the game wind.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 3f), 120)); _migrateLegacyCloudCoverageEntry = config.Bind<bool>("Cloud Shadows", "MigrateLegacyCloudCoverageOnce", false, CreateDescription("Cloud Shadows", "When set to true, inverts CloudCoverage once for a configuration created before direct coverage semantics. It resets itself after migration.", null, -100)); _causticsEnabledEntry = config.Bind<bool>("Water Caustic Lighting", "Enabled", true, CreateDescription("Water Caustic Lighting", "Enables underwater caustic lighting independently of cloud shadows.", null, 180)); _causticsIntensityEntry = config.Bind<float>("Water Caustic Lighting", "Intensity", 1f, CreateDescription("Water Caustic Lighting", "Controls the brightness of underwater caustic lighting. Values above 1 increase the effect beyond its default intensity.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 3f), 170)); _causticsPatternSizeMetersEntry = config.Bind<float>("Water Caustic Lighting", "PatternSizeMeters", 8f, CreateDescription("Water Caustic Lighting", "Controls the approximate size of the caustic pattern in meters.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(2f, 20f), 160)); _causticsAnimationSpeedEntry = config.Bind<float>("Water Caustic Lighting", "AnimationSpeed", 1f, CreateDescription("Water Caustic Lighting", "Controls how quickly the caustic pattern ripples.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 3f), 150)); _causticsFlowingMotionEntry = config.Bind<bool>("Water Caustic Lighting", "FlowingMotion", true, CreateDescription("Water Caustic Lighting", "Adds a world-space flow and changing filament thickness to make caustics feel less repetitive. Disable for the original 0.2.0 motion.", null, 145)); _causticsMaximumDepthMetersEntry = config.Bind<float>("Water Caustic Lighting", "MaximumDepthMeters", 10f, CreateDescription("Water Caustic Lighting", "Sets the maximum water depth reached by caustic lighting.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(2f, 40f), 140)); _causticsDrawDistanceMetersEntry = config.Bind<float>("Water Caustic Lighting", "DrawDistanceMeters", 45f, CreateDescription("Water Caustic Lighting", "Sets the maximum camera distance for caustic lighting.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(20f, 250f), 130)); _environmentPaletteEnabledEntry = config.Bind<bool>("Enhanced Environment", "Enabled", false, CreateDescription("Enhanced Environment", "Applies a configurable enhanced color grade to Valheim's morning, day, evening, and night lighting. Biome and weather behavior remain authored by the active Valheim environment.", null, 180)); _environmentPaletteStrengthEntry = config.Bind<float>("Enhanced Environment", "Strength", 0.65f, CreateDescription("Enhanced Environment", "Blends the configured palette with each environment's original colors. Set to 0 for the unmodified Valheim colors.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), 170)); _environmentPalettePresetEntry = config.Bind<EnhancedEnvironmentPreset>("Enhanced Environment", "Preset", EnhancedEnvironmentPreset.GoldenSaga, CreateDescription("Enhanced Environment", "Selects a complete environment palette. GoldenSaga is warm and cinematic, VerdantWilds is lush and green, Frostbound is cool and crystalline, Emberfall is fiery and high-contrast, AuroraVeil is vivid teal and violet, and Custom uses the RGB settings below.", null, 168)); _environmentPaletteOverrideSunAngleEntry = config.Bind<bool>("Enhanced Environment", "OverrideSunAngle", false, CreateDescription("Enhanced Environment", "When enabled, adjusts the daily sun path using SunAngle. Leave disabled to preserve Valheim's original sun position.", null, 165)); _environmentPaletteSunAngleEntry = config.Bind<float>("Enhanced Environment", "SunAngle", 78f, CreateDescription("Enhanced Environment", "Sets the daily sun-path elevation when OverrideSunAngle is enabled. 0 is horizon-level and 90 is directly overhead.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 90f), 160)); _morningSunColorEntries = BindPaletteColor(config, "MorningSun", new Color(1f, 0.72156864f, 0.38039216f), 150); _morningFogColorEntries = BindPaletteColor(config, "MorningFog", new Color(46f / 51f, 46f / 85f, 0.4117647f), 147); _daySunColorEntries = BindPaletteColor(config, "DaySun", new Color(1f, 46f / 51f, 38f / 51f), 144); _dayFogColorEntries = BindPaletteColor(config, "DayFog", new Color(23f / 51f, 53f / 85f, 0.6156863f), 141); _eveningSunColorEntries = BindPaletteColor(config, "EveningSun", new Color(49f / 51f, 0.38039216f, 39f / 85f), 138); _eveningFogColorEntries = BindPaletteColor(config, "EveningFog", new Color(25f / 51f, 0.23921569f, 0.5019608f), 135); _nightSunColorEntries = BindPaletteColor(config, "NightSun", new Color(0.3019608f, 0.41960785f, 0.78039217f), 132); _nightFogColorEntries = BindPaletteColor(config, "NightFog", new Color(11f / 85f, 0.2f, 0.4f), 129); _meadowsFirefliesEnabledEntry = config.Bind<bool>("Meadows Fireflies", "Enabled", true, CreateDescription("Meadows Fireflies", "Shows a small number of subtle yellow fireflies outdoors in the Meadows at night.", null, 180)); _meadowsFirefliesParticleCountEntry = config.Bind<int>("Meadows Fireflies", "ParticleCount", 36, CreateDescription("Meadows Fireflies", "Sets the maximum number of fireflies. This is capped at a deliberately small value to keep the effect inexpensive.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(12, 64), 170)); _meadowsFirefliesRadiusMetersEntry = config.Bind<float>("Meadows Fireflies", "RadiusMeters", 16f, CreateDescription("Meadows Fireflies", "Sets the radius around the player in which fireflies appear.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(6f, 30f), 160)); _meadowsFirefliesBrightnessEntry = config.Bind<float>("Meadows Fireflies", "Brightness", 0.85f, CreateDescription("Meadows Fireflies", "Controls the alpha of the yellow one-pixel firefly sprites without adding lights or bloom.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), 150)); _autoDisableAtNightEntry = config.Bind<bool>("Automation", "AutoDisableAtNight", true, CreateDescription("Automation", "Smoothly fades cloud shadows out while it is night.", null, 110)); _autoDisableInRainEntry = config.Bind<bool>("Automation", "AutoDisableInRain", true, CreateDescription("Automation", "Smoothly fades cloud shadows out during rain and wet storms.", null, 105)); _autoDisableUnderRoofEntry = config.Bind<bool>("Automation", "AutoDisableUnderRoof", true, CreateDescription("Automation", "Smoothly fades cloud shadows out under a roof or inside a cave.", null, 100)); _autoDisableMeadowsFirefliesUnderRoofEntry = config.Bind<bool>("Automation", "AutoDisableMeadowsFirefliesUnderRoof", true, CreateDescription("Automation", "Smoothly fades Meadows fireflies out under a roof or inside an interior.", null, 95)); ApplyRequestedConfigMigration(); SubscribeToChanges(); RefreshCache(); } internal void ToggleEnabled() { _enabledEntry.Value = !_enabledEntry.Value; } internal void ToggleDebugMaskView() { _debugMaskViewEntry.Value = !_debugMaskViewEntry.Value; } internal void ToggleEnvironmentPalette() { _environmentPaletteEnabledEntry.Value = !_environmentPaletteEnabledEntry.Value; } public void Dispose() { UnsubscribeFromChanges(); } private static ConfigDescription CreateDescription(string category, string description, AcceptableValueBase acceptableValues, int order) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown return new ConfigDescription(description, acceptableValues, new object[1] { new ConfigurationManagerAttributes { Order = order, Category = category, IsAdvanced = false } }); } private static PaletteColorEntries BindPaletteColor(ConfigFile config, string name, Color defaultColor, int order) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) return new PaletteColorEntries(config.Bind<float>("Enhanced Environment", name + "Red", defaultColor.r * 255f, CreateDescription("Enhanced Environment", "Red channel for the " + FormatPaletteColorName(name) + " color.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 255f), order)), config.Bind<float>("Enhanced Environment", name + "Green", defaultColor.g * 255f, CreateDescription("Enhanced Environment", "Green channel for the " + FormatPaletteColorName(name) + " color.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 255f), order - 1)), config.Bind<float>("Enhanced Environment", name + "Blue", defaultColor.b * 255f, CreateDescription("Enhanced Environment", "Blue channel for the " + FormatPaletteColorName(name) + " color.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 255f), order - 2))); } private static string FormatPaletteColorName(string name) { if (string.IsNullOrEmpty(name)) { return "palette"; } return name.Replace("Morning", "morning ").Replace("Evening", "evening ").Replace("Night", "night ") .Replace("Sun", "sun") .Replace("Fog", "fog") .Trim() .ToLowerInvariant(); } private void SubscribeToChanges() { _enabledEntry.SettingChanged += HandleSettingChanged; _debugMaskViewEntry.SettingChanged += HandleSettingChanged; _configSchemaVersionEntry.SettingChanged += HandleSettingChanged; _leaveRequestedDepthModeEntry.SettingChanged += HandleSettingChanged; _toggleEnabledShortcutEntry.SettingChanged += HandleSettingChanged; _diagnosticDumpShortcutEntry.SettingChanged += HandleSettingChanged; _toggleDebugMaskShortcutEntry.SettingChanged += HandleSettingChanged; _toggleEnvironmentPaletteShortcutEntry.SettingChanged += HandleSettingChanged; _shadowStrengthEntry.SettingChanged += HandleSettingChanged; _cloudSizeMetersEntry.SettingChanged += HandleSettingChanged; _edgeSoftnessEntry.SettingChanged += HandleSettingChanged; _cloudCoverageEntry.SettingChanged += HandleSettingChanged; _shadowDrawDistanceEntry.SettingChanged += HandleSettingChanged; _cloudMaskQualityEntry.SettingChanged += HandleSettingChanged; _windSpeedMultiplierEntry.SettingChanged += HandleSettingChanged; _migrateLegacyCloudCoverageEntry.SettingChanged += HandleSettingChanged; _causticsEnabledEntry.SettingChanged += HandleSettingChanged; _causticsIntensityEntry.SettingChanged += HandleSettingChanged; _causticsPatternSizeMetersEntry.SettingChanged += HandleSettingChanged; _causticsAnimationSpeedEntry.SettingChanged += HandleSettingChanged; _causticsFlowingMotionEntry.SettingChanged += HandleSettingChanged; _causticsMaximumDepthMetersEntry.SettingChanged += HandleSettingChanged; _causticsDrawDistanceMetersEntry.SettingChanged += HandleSettingChanged; _environmentPaletteEnabledEntry.SettingChanged += HandleSettingChanged; _environmentPaletteStrengthEntry.SettingChanged += HandleSettingChanged; _environmentPalettePresetEntry.SettingChanged += HandleSettingChanged; _environmentPaletteOverrideSunAngleEntry.SettingChanged += HandleSettingChanged; _environmentPaletteSunAngleEntry.SettingChanged += HandleSettingChanged; _morningSunColorEntries.Subscribe(HandleSettingChanged); _morningFogColorEntries.Subscribe(HandleSettingChanged); _daySunColorEntries.Subscribe(HandleSettingChanged); _dayFogColorEntries.Subscribe(HandleSettingChanged); _eveningSunColorEntries.Subscribe(HandleSettingChanged); _eveningFogColorEntries.Subscribe(HandleSettingChanged); _nightSunColorEntries.Subscribe(HandleSettingChanged); _nightFogColorEntries.Subscribe(HandleSettingChanged); _meadowsFirefliesEnabledEntry.SettingChanged += HandleSettingChanged; _meadowsFirefliesParticleCountEntry.SettingChanged += HandleSettingChanged; _meadowsFirefliesRadiusMetersEntry.SettingChanged += HandleSettingChanged; _meadowsFirefliesBrightnessEntry.SettingChanged += HandleSettingChanged; _autoDisableAtNightEntry.SettingChanged += HandleSettingChanged; _autoDisableInRainEntry.SettingChanged += HandleSettingChanged; _autoDisableUnderRoofEntry.SettingChanged += HandleSettingChanged; _autoDisableMeadowsFirefliesUnderRoofEntry.SettingChanged += HandleSettingChanged; } private void UnsubscribeFromChanges() { _enabledEntry.SettingChanged -= HandleSettingChanged; _debugMaskViewEntry.SettingChanged -= HandleSettingChanged; _configSchemaVersionEntry.SettingChanged -= HandleSettingChanged; _leaveRequestedDepthModeEntry.SettingChanged -= HandleSettingChanged; _toggleEnabledShortcutEntry.SettingChanged -= HandleSettingChanged; _diagnosticDumpShortcutEntry.SettingChanged -= HandleSettingChanged; _toggleDebugMaskShortcutEntry.SettingChanged -= HandleSettingChanged; _toggleEnvironmentPaletteShortcutEntry.SettingChanged -= HandleSettingChanged; _shadowStrengthEntry.SettingChanged -= HandleSettingChanged; _cloudSizeMetersEntry.SettingChanged -= HandleSettingChanged; _edgeSoftnessEntry.SettingChanged -= HandleSettingChanged; _cloudCoverageEntry.SettingChanged -= HandleSettingChanged; _shadowDrawDistanceEntry.SettingChanged -= HandleSettingChanged; _cloudMaskQualityEntry.SettingChanged -= HandleSettingChanged; _windSpeedMultiplierEntry.SettingChanged -= HandleSettingChanged; _migrateLegacyCloudCoverageEntry.SettingChanged -= HandleSettingChanged; _causticsEnabledEntry.SettingChanged -= HandleSettingChanged; _causticsIntensityEntry.SettingChanged -= HandleSettingChanged; _causticsPatternSizeMetersEntry.SettingChanged -= HandleSettingChanged; _causticsAnimationSpeedEntry.SettingChanged -= HandleSettingChanged; _causticsFlowingMotionEntry.SettingChanged -= HandleSettingChanged; _causticsMaximumDepthMetersEntry.SettingChanged -= HandleSettingChanged; _causticsDrawDistanceMetersEntry.SettingChanged -= HandleSettingChanged; _environmentPaletteEnabledEntry.SettingChanged -= HandleSettingChanged; _environmentPaletteStrengthEntry.SettingChanged -= HandleSettingChanged; _environmentPalettePresetEntry.SettingChanged -= HandleSettingChanged; _environmentPaletteOverrideSunAngleEntry.SettingChanged -= HandleSettingChanged; _environmentPaletteSunAngleEntry.SettingChanged -= HandleSettingChanged; _morningSunColorEntries.Unsubscribe(HandleSettingChanged); _morningFogColorEntries.Unsubscribe(HandleSettingChanged); _daySunColorEntries.Unsubscribe(HandleSettingChanged); _dayFogColorEntries.Unsubscribe(HandleSettingChanged); _eveningSunColorEntries.Unsubscribe(HandleSettingChanged); _eveningFogColorEntries.Unsubscribe(HandleSettingChanged); _nightSunColorEntries.Unsubscribe(HandleSettingChanged); _nightFogColorEntries.Unsubscribe(HandleSettingChanged); _meadowsFirefliesEnabledEntry.SettingChanged -= HandleSettingChanged; _meadowsFirefliesParticleCountEntry.SettingChanged -= HandleSettingChanged; _meadowsFirefliesRadiusMetersEntry.SettingChanged -= HandleSettingChanged; _meadowsFirefliesBrightnessEntry.SettingChanged -= HandleSettingChanged; _autoDisableAtNightEntry.SettingChanged -= HandleSettingChanged; _autoDisableInRainEntry.SettingChanged -= HandleSettingChanged; _autoDisableUnderRoofEntry.SettingChanged -= HandleSettingChanged; _autoDisableMeadowsFirefliesUnderRoofEntry.SettingChanged -= HandleSettingChanged; } private void HandleSettingChanged(object sender, EventArgs eventArgs) { if (!_applyingConfigMigration) { ApplyRequestedConfigMigration(); RefreshCache(); } } private void ApplyRequestedConfigMigration() { bool flag = _configSchemaVersionEntry.Value < 3; bool flag2 = _configSchemaVersionEntry.Value < 4; if (!flag && !flag2 && !_migrateLegacyCloudCoverageEntry.Value) { return; } _applyingConfigMigration = true; try { if (flag2) { MigrateLegacyEnhancedEnvironmentSettings(); } if (flag) { _environmentPaletteEnabledEntry.Value = false; } if (_migrateLegacyCloudCoverageEntry.Value) { _cloudCoverageEntry.Value = 1f - _cloudCoverageEntry.Value; _migrateLegacyCloudCoverageEntry.Value = false; } _configSchemaVersionEntry.Value = 4; } finally { _applyingConfigMigration = false; } } private void MigrateLegacyEnhancedEnvironmentSettings() { if (_hasLegacyEnvironmentPaletteSection) { MigrateLegacySetting<KeyboardShortcut>(_config, "Hotkeys", "ToggleFantasyEnvironment", _toggleEnvironmentPaletteShortcutEntry); MigrateLegacySetting<bool>(_config, "Fantasy Environment", "Enabled", _environmentPaletteEnabledEntry); MigrateLegacySetting<float>(_config, "Fantasy Environment", "Strength", _environmentPaletteStrengthEntry); MigrateLegacyPreset(); MigrateLegacySetting<bool>(_config, "Fantasy Environment", "OverrideSunAngle", _environmentPaletteOverrideSunAngleEntry); MigrateLegacySetting<float>(_config, "Fantasy Environment", "SunAngle", _environmentPaletteSunAngleEntry); _morningSunColorEntries.MigrateLegacyValues(_config, "MorningSun"); _morningFogColorEntries.MigrateLegacyValues(_config, "MorningFog"); _daySunColorEntries.MigrateLegacyValues(_config, "DaySun"); _dayFogColorEntries.MigrateLegacyValues(_config, "DayFog"); _eveningSunColorEntries.MigrateLegacyValues(_config, "EveningSun"); _eveningFogColorEntries.MigrateLegacyValues(_config, "EveningFog"); _nightSunColorEntries.MigrateLegacyValues(_config, "NightSun"); _nightFogColorEntries.MigrateLegacyValues(_config, "NightFog"); } } private void MigrateLegacyPreset() { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown ConfigDefinition val = new ConfigDefinition("Fantasy Environment", "Preset"); if (Enum.TryParse<EnhancedEnvironmentPreset>(_config.Bind<LegacyFantasyEnvironmentPreset>(val, LegacyFantasyEnvironmentPreset.GoldenSaga, LegacyMigrationDescription).Value.ToString(), ignoreCase: true, out var result)) { _environmentPalettePresetEntry.Value = result; } _config.Remove(val); } private static void MigrateLegacySetting<T>(ConfigFile config, string section, string key, ConfigEntry<T> target) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown ConfigDefinition val = new ConfigDefinition(section, key); ConfigEntry<T> val2 = config.Bind<T>(val, target.Value, LegacyMigrationDescription); target.Value = val2.Value; config.Remove(val); } private static bool HasConfigSection(string configFilePath, string sectionName) { try { if (!File.Exists(configFilePath)) { return false; } string b = "[" + sectionName + "]"; string[] array = File.ReadAllLines(configFilePath); for (int i = 0; i < array.Length; i++) { if (string.Equals(array[i].Trim(), b, StringComparison.OrdinalIgnoreCase)) { return true; } } } catch (IOException) { } catch (UnauthorizedAccessException) { } return false; } private void RefreshCache() { //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Unknown result type (might be due to invalid IL or missing references) Enabled = _enabledEntry.Value; DebugMaskView = _debugMaskViewEntry.Value; ConfigSchemaVersion = _configSchemaVersionEntry.Value; LeaveRequestedDepthModeForCompatibility = _leaveRequestedDepthModeEntry.Value; ToggleEnabledShortcut = _toggleEnabledShortcutEntry.Value; DiagnosticDumpShortcut = _diagnosticDumpShortcutEntry.Value; ToggleDebugMaskShortcut = _toggleDebugMaskShortcutEntry.Value; ToggleEnvironmentPaletteShortcut = _toggleEnvironmentPaletteShortcutEntry.Value; ShadowStrength = _shadowStrengthEntry.Value; CloudSizeMeters = _cloudSizeMetersEntry.Value; EdgeSoftness = _edgeSoftnessEntry.Value; CloudCoverage = _cloudCoverageEntry.Value; ShadowDrawDistance = _shadowDrawDistanceEntry.Value; CloudMaskQuality = _cloudMaskQualityEntry.Value; WindSpeedMultiplier = _windSpeedMultiplierEntry.Value; CausticsEnabled = _causticsEnabledEntry.Value; CausticsIntensity = _causticsIntensityEntry.Value; CausticsPatternSizeMeters = _causticsPatternSizeMetersEntry.Value; CausticsAnimationSpeed = _causticsAnimationSpeedEntry.Value; CausticsFlowingMotion = _causticsFlowingMotionEntry.Value; CausticsMaximumDepthMeters = _causticsMaximumDepthMetersEntry.Value; CausticsDrawDistanceMeters = _causticsDrawDistanceMetersEntry.Value; EnvironmentPaletteEnabled = _environmentPaletteEnabledEntry.Value; EnvironmentPaletteStrength = _environmentPaletteStrengthEntry.Value; EnvironmentPalettePreset = _environmentPalettePresetEntry.Value; EnvironmentPaletteOverrideSunAngle = _environmentPaletteOverrideSunAngleEntry.Value; EnvironmentPaletteSunAngle = _environmentPaletteSunAngleEntry.Value; EnvironmentPaletteMorningSunColor = _morningSunColorEntries.Value; EnvironmentPaletteMorningFogColor = _morningFogColorEntries.Value; EnvironmentPaletteDaySunColor = _daySunColorEntries.Value; EnvironmentPaletteDayFogColor = _dayFogColorEntries.Value; EnvironmentPaletteEveningSunColor = _eveningSunColorEntries.Value; EnvironmentPaletteEveningFogColor = _eveningFogColorEntries.Value; EnvironmentPaletteNightSunColor = _nightSunColorEntries.Value; EnvironmentPaletteNightFogColor = _nightFogColorEntries.Value; MeadowsFirefliesEnabled = _meadowsFirefliesEnabledEntry.Value; MeadowsFirefliesParticleCount = _meadowsFirefliesParticleCountEntry.Value; MeadowsFirefliesRadiusMeters = _meadowsFirefliesRadiusMetersEntry.Value; MeadowsFirefliesBrightness = _meadowsFirefliesBrightnessEntry.Value; AutoDisableAtNight = _autoDisableAtNightEntry.Value; AutoDisableInRain = _autoDisableInRainEntry.Value; AutoDisableUnderRoof = _autoDisableUnderRoofEntry.Value; AutoDisableMeadowsFirefliesUnderRoof = _autoDisableMeadowsFirefliesUnderRoofEntry.Value; Revision++; } } internal static class CloudShadowsDiagnostics { private const string BeginMarker = "===== VALHEIM VISUAL ENHANCED DEBUG BEGIN ====="; private const string EndMarker = "===== VALHEIM VISUAL ENHANCED DEBUG END ====="; private const int CameraLimit = 10; private const int LightLimit = 20; private const int ObjectLimit = 150; private const int ShaderLimit = 200; private const int MaterialLimit = 200; private const int RendererSampleLimit = 200; private const int RendererDetailLimit = 30; private static readonly string[] ObjectKeywords = new string[11] { "cloud", "sky", "sun", "fog", "weather", "env", "atmosphere", "shadow", "terrain", "landscape", "ground" }; private static readonly string[] ShaderKeywords = new string[12] { "terrain", "sky", "cloud", "shadow", "nature", "grass", "rock", "water", "fog", "sun", "environment", "atmosphere" }; private static readonly string[] MaterialKeywords = new string[13] { "terrain", "sky", "cloud", "shadow", "nature", "grass", "rock", "water", "fog", "sun", "environment", "atmosphere", "landscape" }; internal static void WriteDump(ManualLogSource logger, string pluginDirectory, CloudShadowsRuntimeSnapshot runtimeSnapshot) { StringBuilder stringBuilder = new StringBuilder(65536); stringBuilder.AppendLine("===== VALHEIM VISUAL ENHANCED DEBUG BEGIN ====="); try { AppendSection(stringBuilder, "A. General information", AppendGeneralInformation); AppendSection(stringBuilder, "B. Valheim Visual Enhanced runtime", delegate(StringBuilder section) { AppendRuntimeState(section, runtimeSnapshot); }); AppendSection(stringBuilder, "C. Cameras", AppendCameras); AppendSection(stringBuilder, "D. RenderSettings", AppendRenderSettings); AppendSection(stringBuilder, "E. Lights", AppendLights); AppendSection(stringBuilder, "F. Related objects", AppendRelatedObjects); AppendSection(stringBuilder, "G. Shaders", AppendShaders); AppendSection(stringBuilder, "H. Materials", AppendMaterials); AppendSection(stringBuilder, "I. Renderers in active scene", AppendRenderers); } catch (Exception exception) { AppendException(stringBuilder, "Unexpected top-level diagnostic error", exception); } finally { stringBuilder.AppendLine("===== VALHEIM VISUAL ENHANCED DEBUG END ====="); } string contents = stringBuilder.ToString(); try { if (string.IsNullOrWhiteSpace(pluginDirectory)) { throw new InvalidOperationException("The plugin directory could not be determined"); } Directory.CreateDirectory(pluginDirectory); string text = Path.Combine(pluginDirectory, "debug_output.txt"); File.WriteAllText(text, contents, new UTF8Encoding(encoderShouldEmitUTF8Identifier: false)); logger.LogInfo((object)("Valheim Visual Enhanced debug dump written to: " + text)); } catch (Exception exception2) { TryLogError(logger, "Could not write Valheim Visual Enhanced debug_output.txt", exception2); } } private static void AppendSection(StringBuilder dump, string title, Action<StringBuilder> appendSection) { dump.AppendLine(); dump.AppendLine("--- " + title + " ---"); try { appendSection(dump); } catch (Exception exception) { AppendException(dump, "Section " + title + " failed", exception); } } private static void AppendGeneralInformation(StringBuilder dump) { AppendSafeValue(dump, "Current time", () => DateTime.Now.ToString("O")); AppendSafeValue(dump, "Application version", () => Application.version); AppendSafeValue(dump, "Unity version", () => Application.unityVersion); AppendSafeValue(dump, "Graphics API", () => SystemInfo.graphicsDeviceType); AppendSafeValue(dump, "Graphics device version", () => SystemInfo.graphicsDeviceVersion); AppendSafeValue(dump, "Active scene", () => FormatScene(SceneManager.GetActiveScene())); Camera mainCamera = null; try { mainCamera = Camera.main; dump.AppendLine($"Camera.main exists: {(Object)(object)mainCamera != (Object)null}"); } catch (Exception exception) { AppendException(dump, "Camera.main lookup failed", exception); } if (!((Object)(object)mainCamera == (Object)null)) { AppendSafeValue(dump, "Main camera name", () => ((Object)mainCamera).name); AppendSafeValue(dump, "Main camera position", () => ((Component)mainCamera).transform.position); AppendSafeValue(dump, "Main camera rotation (Euler)", delegate { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) Quaternion rotation = ((Component)mainCamera).transform.rotation; return ((Quaternion)(ref rotation)).eulerAngles; }); AppendSafeValue(dump, "Main camera fieldOfView", () => mainCamera.fieldOfView); AppendSafeValue(dump, "Main camera nearClipPlane", () => mainCamera.nearClipPlane); AppendSafeValue(dump, "Main camera farClipPlane", () => mainCamera.farClipPlane); AppendSafeValue(dump, "Main camera clearFlags", () => mainCamera.clearFlags); AppendSafeValue(dump, "Main camera has targetTexture", () => (Object)(object)mainCamera.targetTexture != (Object)null); AppendSafeValue(dump, "Main camera targetTexture", () => GetObjectName((Object)(object)mainCamera.targetTexture)); AppendSafeValue(dump, "Main camera cullingMask", () => FormatMask(mainCamera.cullingMask)); AppendSafeValue(dump, "Main camera cameraType", () => mainCamera.cameraType); AppendSafeValue(dump, "Main camera renderingPath", () => mainCamera.renderingPath); AppendSafeValue(dump, "Main camera actualRenderingPath", () => mainCamera.actualRenderingPath); AppendSafeValue(dump, "Main camera depthTextureMode", () => mainCamera.depthTextureMode); AppendSafeValue(dump, "Main camera allowHDR", () => mainCamera.allowHDR); AppendSafeValue(dump, "Main camera pixel size", () => $"{mainCamera.pixelWidth}x{mainCamera.pixelHeight}"); AppendSafeValue(dump, "Main camera commandBufferCount", () => mainCamera.commandBufferCount); } } private static void AppendRuntimeState(StringBuilder dump, CloudShadowsRuntimeSnapshot snapshot) { //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Unknown result type (might be due to invalid IL or missing references) //IL_029b: Unknown result type (might be due to invalid IL or missing references) //IL_02b7: Unknown result type (might be due to invalid IL or missing references) //IL_0585: Unknown result type (might be due to invalid IL or missing references) if (snapshot == null) { dump.AppendLine("<runtime controller unavailable>"); return; } dump.AppendLine($"World ready: {snapshot.WorldReady}"); dump.AppendLine($"Enabled: {snapshot.Enabled}"); dump.AppendLine($"Debug mask view: {snapshot.DebugMaskView}"); dump.AppendLine($"Visibility target: {snapshot.VisibilityTarget}"); dump.AppendLine($"Night: {snapshot.IsNight}"); dump.AppendLine($"Wet weather: {snapshot.IsWetWeather}"); dump.AppendLine($"Auto-disable cloud shadows in rain: {snapshot.AutoDisableInRain}"); dump.AppendLine($"Under roof: {snapshot.IsUnderRoof}"); dump.AppendLine($"Effect fade: {snapshot.EffectFade:R}"); dump.AppendLine($"Caustics visibility target: {snapshot.CausticsVisibilityTarget}"); dump.AppendLine($"Caustics fade: {snapshot.CausticsFade:R}"); dump.AppendLine($"Caustics phase: {snapshot.CausticsPhase:R}"); dump.AppendLine($"Cloud render requested: {snapshot.CloudRenderRequested}"); dump.AppendLine($"Full-screen post pass requested: {snapshot.PostEffectRequested}"); dump.AppendLine($"Render requested: {snapshot.RenderRequested}"); dump.AppendLine($"Camera.onPreRender subscribed: {snapshot.PreRenderSubscribed}"); dump.AppendLine($"Settings revision: {snapshot.SettingsRevision}"); dump.AppendLine($"Target wind direction: {snapshot.TargetWindDirection}"); dump.AppendLine($"Target wind speed: {snapshot.TargetWindSpeed:R}"); dump.AppendLine($"Target wind intensity: {snapshot.TargetWindIntensity:R}"); dump.AppendLine($"Smoothed wind speed: {snapshot.SmoothedWindSpeed:R}"); dump.AppendLine($"Smoothed caustics wind direction: {snapshot.SmoothedCausticsWindDirection}"); dump.AppendLine($"Smoothed caustics wind intensity: {snapshot.SmoothedCausticsWindIntensity:R}"); dump.AppendLine($"Cloud offset: {snapshot.CloudOffset}"); dump.AppendLine($"Caustics wind offsets (A.xy, B.zw): {snapshot.CausticsWindOffsets}"); EnvironmentPaletteSnapshot environmentPalette = snapshot.EnvironmentPalette; if (environmentPalette == null) { dump.AppendLine("Enhanced Environment palette: <unavailable>"); } else { dump.AppendLine("Enhanced Environment palette Harmony patch installed: " + $"{environmentPalette.PatchInstalled}"); dump.AppendLine($"Enhanced Environment palette enabled: {environmentPalette.Enabled}"); dump.AppendLine($"Enhanced Environment palette strength: {environmentPalette.Strength:R}"); dump.AppendLine($"Enhanced Environment palette preset: {environmentPalette.Preset}"); dump.AppendLine("Enhanced Environment palette overrides sun angle: " + $"{environmentPalette.OverrideSunAngle}"); dump.AppendLine($"Enhanced Environment palette sun angle: {environmentPalette.SunAngle:R}"); dump.AppendLine("Enhanced Environment palette last environment: " + (environmentPalette.LastEnvironmentName ?? "<none>")); } MeadowsFirefliesSnapshot meadowsFireflies = snapshot.MeadowsFireflies; if (meadowsFireflies == null) { dump.AppendLine("Meadows fireflies: <unavailable>"); } else { dump.AppendLine($"Meadows fireflies resources ready: {meadowsFireflies.ResourcesReady}"); dump.AppendLine($"Meadows fireflies active: {meadowsFireflies.Active}"); dump.AppendLine($"Meadows fireflies enabled: {meadowsFireflies.Enabled}"); dump.AppendLine($"Meadows fireflies particle count: {meadowsFireflies.ParticleCount}"); dump.AppendLine($"Meadows fireflies radius meters: {meadowsFireflies.RadiusMeters:R}"); dump.AppendLine($"Meadows fireflies brightness: {meadowsFireflies.Brightness:R}"); dump.AppendLine("Meadows fireflies auto-disable under roof: " + meadowsFireflies.AutoDisableUnderRoof); dump.AppendLine("Meadows fireflies state reason: " + meadowsFireflies.StateReason); } CloudShadowsRendererSnapshot renderer = snapshot.Renderer; if (renderer == null) { dump.AppendLine("Renderer: <unavailable>"); return; } dump.AppendLine($"Renderer resources ready: {renderer.ResourcesReady}"); dump.AppendLine("Bundle path: " + renderer.BundlePath); dump.AppendLine($"Bundle asset count: {renderer.BundleAssetCount}"); dump.AppendLine("Shader: " + renderer.ShaderName); dump.AppendLine("Runtime material: " + renderer.MaterialName); dump.AppendLine("Caustics texture: " + renderer.CausticsTextureName); dump.AppendLine("Caustics texture size: " + renderer.CausticsTextureSize); dump.AppendLine($"Caustics light color: {renderer.CausticsLightColor}"); dump.AppendLine($"Caustics light intensity: {renderer.CausticsLightIntensity:R}"); dump.AppendLine($"Caustics sun response: {renderer.CausticsSunResponse:R}"); dump.AppendLine($"Caustics enabled setting: {renderer.CausticsEnabled}"); dump.AppendLine($"Caustics intensity setting: {renderer.CausticsIntensity:R}"); dump.AppendLine("Caustics effective strength: " + $"{renderer.CausticsIntensity * snapshot.CausticsFade:R}"); dump.AppendLine($"Caustics pattern size meters setting: {renderer.CausticsPatternSizeMeters:R}"); dump.AppendLine($"Caustics animation speed setting: {renderer.CausticsAnimationSpeed:R}"); dump.AppendLine($"Caustics flowing motion setting: {renderer.CausticsFlowingMotion}"); dump.AppendLine($"Caustics maximum depth meters setting: {renderer.CausticsMaximumDepthMeters:R}"); dump.AppendLine($"Caustics draw distance meters setting: {renderer.CausticsDrawDistanceMeters:R}"); dump.AppendLine("Caustics state reason: " + GetCausticsStateReason(snapshot, renderer)); dump.AppendLine($"Full-screen post buffer attached: {renderer.CommandBufferAttached}"); dump.AppendLine("Attached camera: " + renderer.CameraName); dump.AppendLine("Attached camera actual rendering path: " + renderer.CameraRenderingPath); dump.AppendLine($"Attached camera HDR: {renderer.CameraAllowHdr}"); dump.AppendLine("Depth source: " + renderer.DepthSource); dump.AppendLine("Original depth mode: " + renderer.OriginalDepthMode); dump.AppendLine("Applied depth mode: " + renderer.AppliedDepthMode); dump.AppendLine("Current depth mode: " + renderer.CurrentDepthMode); dump.AppendLine($"Depth mode changed by Valheim Visual Enhanced: {renderer.DepthModeWasChanged}"); dump.AppendLine($"Camera commandBufferCount: {renderer.CameraCommandBufferCount}"); dump.AppendLine($"Last water level: {renderer.LastWaterLevel:R}"); dump.AppendLine($"Applied settings revision: {renderer.AppliedSettingsRevision}"); AppendDirectionalCookieState(dump, renderer.DirectionalCookie); } private static void AppendDirectionalCookieState(StringBuilder dump, CloudShadowsDirectionalCookieSnapshot cookie) { if (cookie == null) { dump.AppendLine("Cloud shadow mask: <unavailable>"); return; } dump.AppendLine($"Cloud shadow mask resources ready: {cookie.ResourcesReady}"); dump.AppendLine($"Cloud shadow mask available: {cookie.MaskAvailable}"); dump.AppendLine($"Cloud shadow lighting available: {cookie.LightingAvailable}"); dump.AppendLine("Cloud shadow generation buffer attached (AfterGBuffer): " + $"{cookie.GenerationBufferAttached}"); dump.AppendLine("Cloud shadow screen-space buffer attached (AfterScreenspaceMask): " + $"{cookie.ScreenSpaceBufferAttached}"); dump.AppendLine("Cloud shadow camera: " + cookie.CameraName); dump.AppendLine("Cloud shadow camera actual rendering path: " + cookie.CameraRenderingPath); dump.AppendLine("Cloud shadow directional light: " + cookie.LightName); dump.AppendLine("Cloud shadow directional light type: " + cookie.LightType); dump.AppendLine("Cloud shadow directional light shadows: " + cookie.LightShadows); dump.AppendLine("Cloud shadow mask texture: " + cookie.TextureName); dump.AppendLine("Cloud shadow mask texture size: " + cookie.TextureSize); dump.AppendLine("Cloud shadow mask texture format: " + cookie.TextureFormat); dump.AppendLine("Cloud shadow state reason: " + cookie.StateReason); } private static string GetCausticsStateReason(CloudShadowsRuntimeSnapshot runtime, CloudShadowsRendererSnapshot renderer) { //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) if (!runtime.WorldReady) { return "world is not ready"; } if (!renderer.CausticsEnabled) { return "disabled by Water Caustic Lighting.Enabled"; } if (renderer.CausticsIntensity <= 0f) { return "disabled because Intensity is zero"; } if (runtime.DebugMaskView) { return "suppressed by cloud debug-mask view"; } if (runtime.IsNight) { return "disabled at night"; } if (runtime.IsUnderRoof) { return "disabled under roof or in a cave"; } if (!runtime.CausticsVisibilityTarget) { return "inactive while controller conditions are changing"; } if (runtime.CausticsFade <= 0.001f) { return "visibility target is active; effect is fading in"; } if (!runtime.RenderRequested) { return "rendering is not requested"; } if (!renderer.ResourcesReady) { return "renderer resources are unavailable"; } if (!renderer.CommandBufferAttached) { return "renderer is waiting for a camera attachment"; } float num = Mathf.Max(renderer.CausticsLightColor.r, Mathf.Max(renderer.CausticsLightColor.g, renderer.CausticsLightColor.b)); if (renderer.CausticsLightIntensity <= 0f || num <= 0f) { return "directional light supplies no usable energy"; } return "active"; } private static void AppendCameras(StringBuilder dump) { //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) List<Camera> list = FindComponentsInLoadedScenes<Camera>(); dump.AppendLine($"Camera count in loaded scenes: {list.Count}"); dump.AppendLine($"First cameras (limit {10}):"); for (int i = 0; i < list.Count && i < 10; i++) { Camera val = list[i]; try { string arg = (((Object)(object)val.targetTexture == (Object)null) ? "<none>" : ((Object)val.targetTexture).name); dump.AppendLine($"[{i}] Name={((Object)val).name}; Type={val.cameraType}; " + $"Active={((Component)val).gameObject.activeInHierarchy}; Enabled={((Behaviour)val).enabled}; " + $"TargetTexture={arg}; ClearFlags={val.clearFlags}; " + "CullingMask=" + FormatMask(val.cullingMask) + "; " + $"RenderingPath={val.renderingPath}; " + $"ActualRenderingPath={val.actualRenderingPath}; " + $"DepthTextureMode={val.depthTextureMode}; HDR={val.allowHDR}; " + $"PixelSize={val.pixelWidth}x{val.pixelHeight}; " + $"CommandBufferCount={val.commandBufferCount}"); } catch (Exception exception) { AppendException(dump, $"Camera [{i}] could not be read", exception); } } } private static void AppendRenderSettings(StringBuilder dump) { Material skybox = null; try { skybox = RenderSettings.skybox; dump.AppendLine($"Skybox material exists: {(Object)(object)skybox != (Object)null}"); } catch (Exception exception) { AppendException(dump, "RenderSettings.skybox lookup failed", exception); } if ((Object)(object)skybox != (Object)null) { AppendSafeValue(dump, "Skybox material name", () => ((Object)skybox).name); AppendSafeValue(dump, "Skybox shader name", () => GetShaderName(skybox)); } AppendSafeValue(dump, "Ambient mode", () => RenderSettings.ambientMode); AppendSafeValue(dump, "Ambient intensity", () => RenderSettings.ambientIntensity); Light sun = null; try { sun = RenderSettings.sun; dump.AppendLine($"RenderSettings.sun exists: {(Object)(object)sun != (Object)null}"); } catch (Exception exception2) { AppendException(dump, "RenderSettings.sun lookup failed", exception2); } if ((Object)(object)sun != (Object)null) { AppendSafeValue(dump, "Sun light name", () => ((Object)sun).name); AppendSafeValue(dump, "Sun light type", () => sun.type); AppendSafeValue(dump, "Sun shadows enabled", () => (int)sun.shadows > 0); AppendSafeValue(dump, "Sun shadow mode", () => sun.shadows); AppendSafeValue(dump, "Sun shadowStrength", () => sun.shadowStrength); AppendSafeValue(dump, "Sun cookie", () => GetObjectName((Object)(object)sun.cookie)); AppendSafeValue(dump, "Sun cookieSize", () => sun.cookieSize); } AppendSafeValue(dump, "Fog enabled", () => RenderSettings.fog); AppendSafeValue(dump, "Fog color", () => RenderSettings.fogColor); AppendSafeValue(dump, "Fog mode", () => RenderSettings.fogMode); AppendSafeValue(dump, "Fog density", () => RenderSettings.fogDensity); AppendSafeValue(dump, "Fog start distance", () => RenderSettings.fogStartDistance); AppendSafeValue(dump, "Fog end distance", () => RenderSettings.fogEndDistance); AppendSafeValue(dump, "Default reflection mode", () => RenderSettings.defaultReflectionMode); } private static void AppendLights(StringBuilder dump) { //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Invalid comparison between Unknown and I4 //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) List<Light> list = FindComponentsInLoadedScenes<Light>(); dump.AppendLine($"Light count in loaded scenes: {list.Count}"); dump.AppendLine($"First lights (limit {20}):"); for (int i = 0; i < list.Count && i < 20; i++) { Light val = list[i]; try { dump.AppendLine($"[{i}] Name={((Object)val).name}; Type={val.type}; " + $"ShadowsEnabled={(int)val.shadows > 0}; ShadowMode={val.shadows}; " + $"ShadowStrength={val.shadowStrength}; Range={val.range}; Color={val.color}; " + $"Cookie={GetObjectName((Object)(object)val.cookie)}; CookieSize={val.cookieSize}; " + "CullingMask=" + FormatMask(val.cullingMask)); } catch (Exception exception) { AppendException(dump, $"Light [{i}] could not be read", exception); } } } private static void AppendRelatedObjects(StringBuilder dump) { //IL_0082: Unknown result type (might be due to invalid IL or missing references) GameObject[] array; try { array = Resources.FindObjectsOfTypeAll<GameObject>(); } catch (Exception exception) { AppendException(dump, "GameObject discovery failed", exception); return; } HashSet<int> hashSet = new HashSet<int>(); int num = 0; int num2 = 0; GameObject[] array2 = array; foreach (GameObject val in array2) { try { if ((Object)(object)val == (Object)null || !ContainsKeyword(((Object)val).name, ObjectKeywords)) { continue; } int instanceID = ((Object)val).GetInstanceID(); if (hashSet.Add(instanceID)) { num++; if (num2 < 150) { string arg = FormatScene(val.scene); string hierarchyPath = GetHierarchyPath(val.transform); string objectTypeSummary = GetObjectTypeSummary(val); dump.AppendLine($"[{num2}] Name={((Object)val).name}; Types={objectTypeSummary}; " + $"ActiveSelf={val.activeSelf}; Scene={arg}; Hierarchy={hierarchyPath}"); num2++; } } } catch (Exception exception2) { AppendException(dump, "A related GameObject could not be read", exception2); } } dump.AppendLine($"Unique matching objects: {num}; reported: {num2}; limit: {150}"); } private static void AppendShaders(StringBuilder dump) { Shader[] array; try { array = Resources.FindObjectsOfTypeAll<Shader>(); } catch (Exception exception) { AppendException(dump, "Shader discovery failed", exception); return; } HashSet<string> hashSet = new HashSet<string>(StringComparer.OrdinalIgnoreCase); Shader[] array2 = array; foreach (Shader val in array2) { try { if ((Object)(object)val != (Object)null && ContainsKeyword(((Object)val).name, ShaderKeywords)) { hashSet.Add(((Object)val).name); } } catch (Exception exception2) { AppendException(dump, "A shader could not be read", exception2); } } List<string> list = hashSet.OrderBy<string, string>((string name) => name, StringComparer.OrdinalIgnoreCase).ToList(); dump.AppendLine($"Unique matching shaders: {list.Count}; reported limit: {200}"); for (int num = 0; num < list.Count && num < 200; num++) { dump.AppendLine($"[{num}] {list[num]}"); } } private static void AppendMaterials(StringBuilder dump) { Material[] array; try { array = Resources.FindObjectsOfTypeAll<Material>(); } catch (Exception exception) { AppendException(dump, "Material discovery failed", exception); return; } Dictionary<string, string> dictionary = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); Material[] array2 = array; foreach (Material val in array2) { try { if (!((Object)(object)val == (Object)null) && ContainsKeyword(((Object)val).name, MaterialKeywords) && !dictionary.ContainsKey(((Object)val).name)) { dictionary.Add(((Object)val).name, GetShaderName(val)); } } catch (Exception exception2) { AppendException(dump, "A material could not be read", exception2); } } List<KeyValuePair<string, string>> list = dictionary.OrderBy<KeyValuePair<string, string>, string>((KeyValuePair<string, string> pair) => pair.Key, StringComparer.OrdinalIgnoreCase).ToList(); dump.AppendLine($"Unique matching materials: {list.Count}; reported limit: {200}"); for (int num = 0; num < list.Count && num < 200; num++) { KeyValuePair<string, string> keyValuePair = list[num]; dump.AppendLine($"[{num}] Name={keyValuePair.Key}; Shader={keyValuePair.Value}"); } } private static void AppendRenderers(StringBuilder dump) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) Scene activeScene; Renderer[] array; try { activeScene = SceneManager.GetActiveScene(); array = Resources.FindObjectsOfTypeAll<Renderer>(); } catch (Exception exception) { AppendException(dump, "Renderer discovery failed", exception); return; } List<Renderer> list = new List<Renderer>(200); int num = 0; Renderer[] array2 = array; foreach (Renderer val in array2) { try { if (IsComponentInScene((Component)(object)val, activeScene)) { num++; if (list.Count < 200) { list.Add(val); } } } catch (Exception exception2) { AppendException(dump, "A renderer could not be assigned to a scene", exception2); } } Dictionary<string, int> counts = new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase); Dictionary<string, int> counts2 = new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase); List<string> list2 = new List<string>(30); for (int j = 0; j < list.Count; j++) { Renderer val2 = list[j]; try { object obj = ((object)val2.sharedMaterials) ?? ((object)new Material[0]); List<string> list3 = new List<string>(); List<string> list4 = new List<string>(); Material[] array3 = (Material[])obj; foreach (Material val3 in array3) { if ((Object)(object)val3 == (Object)null) { list3.Add("<null>"); list4.Add("<none>"); continue; } string name = ((Object)val3).name; string shaderName = GetShaderName(val3); list3.Add(name); list4.Add(shaderName); IncrementCount(counts2, name); IncrementCount(counts, shaderName); } if (list2.Count < 30) { list2.Add($"[{j}] GameObject={((Object)((Component)val2).gameObject).name}; Layer={((Component)val2).gameObject.layer}; " + "RendererType=" + ((object)val2).GetType().FullName + "; Materials=[" + string.Join(", ", list3) + "]; Shaders=[" + string.Join(", ", list4) + "]"); } } catch (Exception exception3) { AppendException(dump, $"Renderer [{j}] could not be read", exception3); } } dump.AppendLine("Active scene: " + FormatScene(activeScene)); dump.AppendLine($"Renderer count in active scene: {num}"); dump.AppendLine($"Renderer sample size: {list.Count}; limit: {200}"); dump.AppendLine("Shader usage in sampled renderers:"); AppendCounts(dump, counts); dump.AppendLine("Material usage in sampled renderers:"); AppendCounts(dump, counts2); dump.AppendLine($"First renderer details (limit {30}):"); foreach (string item in list2) { dump.AppendLine(item); } } private static List<T> FindComponentsInLoadedScenes<T>() where T : Component { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) List<T> list = new List<T>(); T[] array; try { array = Resources.FindObjectsOfTypeAll<T>(); } catch { throw; } T[] array2 = array; foreach (T val in array2) { try { if (!((Object)(object)val != (Object)null)) { continue; } Scene scene = ((Component)val).gameObject.scene; if (((Scene)(ref scene)).IsValid()) { scene = ((Component)val).gameObject.scene; if (((Scene)(ref scene)).isLoaded) { list.Add(val); } } } catch { } } return list; } private static bool IsComponentInScene(Component component, Scene scene) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) try { int result; if ((Object)(object)component != (Object)null && ((Scene)(ref scene)).IsValid()) { Scene scene2 = component.gameObject.scene; if (((Scene)(ref scene2)).IsValid()) { result = ((component.gameObject.scene == scene) ? 1 : 0); goto IL_003b; } } result = 0; goto IL_003b; IL_003b: return (byte)result != 0; } catch { return false; } } private static string GetObjectTypeSummary(GameObject gameObject) { try { string componentTypeNames = GetComponentTypeNames(gameObject); if (!string.IsNullOrEmpty(componentTypeNames)) { return componentTypeNames; } Transform parent = gameObject.transform.parent; if ((Object)(object)parent != (Object)null) { string componentTypeNames2 = GetComponentTypeNames(((Component)parent).gameObject); if (!string.IsNullOrEmpty(componentTypeNames2)) { return "ParentComponents=" + componentTypeNames2; } } return ((object)gameObject).GetType().FullName; } catch (Exception exception) { return "<type lookup failed: " + FormatException(exception) + ">"; } } private static string GetComponentTypeNames(GameObject gameObject) { try { Component[] components = gameObject.GetComponents<Component>(); return string.Join(",", (from component in components where (Object)(object)component != (Object)null select ((object)component).GetType().FullName).Distinct<string>(StringComparer.Ordinal).Take(8)); } catch (Exception exception) { return "<component lookup failed: " + FormatException(exception) + ">"; } } private static string GetHierarchyPath(Transform transform) { try { Stack<string> stack = new Stack<string>(); Transform val = transform; int num = 0; while ((Object)(object)val != (Object)null && num < 64) { stack.Push(((Object)val).name); val = val.parent; num++; } string text = string.Join("/", stack.ToArray()); return ((Object)(object)val == (Object)null) ? text : (".../" + text); } catch (Exception exception) { return "<hierarchy lookup failed: " + FormatException(exception) + ">"; } } private static string FormatScene(Scene scene) { try { if (!((Scene)(ref scene)).IsValid()) { return "<no valid scene>"; } string arg = (string.IsNullOrEmpty(((Scene)(ref scene)).path) ? "<no path>" : ((Scene)(ref scene)).path); return $"Name={((Scene)(ref scene)).name}; Path={arg}; Loaded={((Scene)(ref scene)).isLoaded}"; } catch (Exception exception) { return "<scene lookup failed: " + FormatException(exception) + ">"; } } private static string GetObjectName(Object unityObject) { try { return (unityObject == (Object)null) ? "<none>" : unityObject.name; } catch (Exception exception) { return "<name lookup failed: " + FormatException(exception) + ">"; } } private static string GetShaderName(Material material) { try { return ((Object)(object)material == (Object)null || (Object)(object)material.shader == (Object)null) ? "<none>" : ((Object)material.shader).name; } catch (Exception exception) { return "<shader lookup failed: " + FormatException(exception) + ">"; } } private static bool ContainsKeyword(string value, IEnumerable<string> keywords) { try { if (string.IsNullOrEmpty(value)) { return false; } foreach (string keyword in keywords) { if (value.IndexOf(keyword, StringComparison.OrdinalIgnoreCase) >= 0) { return true; } } return false; } catch { return false; } } private static string FormatMask(int mask) { try { return $"{mask} (0x{(uint)mask:X8})"; } catch (Exception exception) { return "<mask formatting failed: " + FormatException(exception) + ">"; } } private static void IncrementCount(IDictionary<string, int> counts, string name) { try { string key = (string.IsNullOrEmpty(name) ? "<unnamed>" : name); counts[key] = ((!counts.TryGetValue(key, out var value)) ? 1 : (value + 1)); } catch { } } private static void AppendCounts(StringBuilder dump, IDictionary<string, int> counts) { try { if (counts.Count == 0) { dump.AppendLine("<none>"); return; } foreach (KeyValuePair<string, int> item in counts.OrderByDescending((KeyValuePair<string, int> pair) => pair.Value).ThenBy<KeyValuePair<string, int>, string>((KeyValuePair<string, int> pair) => pair.Key, StringComparer.OrdinalIgnoreCase)) { dump.AppendLine($"{item.Key}: {item.Value}"); } } catch (Exception exception) { AppendException(dump, "Count aggregation could not be written", exception); } } private static void AppendSafeValue(StringBuilder dump, string label, Func<object> getValue) { try { object obj = getValue(); dump.AppendLine(string.Format("{0}: {1}", label, obj ?? "<null>")); } catch (Exception exception) { AppendException(dump, label + " could not be read", exception); } } private static void AppendException(StringBuilder dump, string context, Exception exception) { try { dump.AppendLine("[ERROR] " + context + ": " + FormatException(exception)); } catch { } } private static string FormatException(Exception exception) { try { return (exception == null) ? "<unknown exception>" : (exception.GetType().Name + ": " + exception.Message); } catch { return "<exception formatting failed>"; } } private static void TryLogError(ManualLogSource logger, string context, Exception exception) { try { logger.LogError((object)(context + ": " + FormatException(exception))); } catch { } } } internal sealed class CloudShadowsDirectionalCookieSnapshot { internal bool ResourcesReady { get; set; } internal bool MaskAvailable { get; set; } internal bool LightingAvailable { get; set; } internal bool GenerationBufferAttached { get; set; } internal bool ScreenSpaceBufferAttached { get; set; } internal string CameraName { get; set; } internal string CameraRenderingPath { get; set; } internal string LightName { get; set; } internal string LightType { get; set; } internal string LightShadows { get; set; } internal string TextureName { get; set; } internal string TextureSize { get; set; } internal string TextureFormat { get; set; } internal string StateReason { get; set; } } internal sealed class CloudShadowsDirectionalCookie : IDisposable { private const float CloudPlaneHeightMeters = 1000f; private const float MaskFadeStartFraction = 0.4f; private const float MinimumMaskRadiusMeters = 1f; private const float MinimumLightVerticalComponent = 0.001f; private const float HorizonFadeStart = 0.08f; private const float HorizonFadeEnd = 0.2f; private const float ResourceRetryIntervalSeconds = 5f; private const string MaskTextureName = "CloudShadows Directional Mask"; private const string GenerationBufferName = "CloudShadows Mask Generation"; private const string ApplicationBufferName = "CloudShadows Screen-Space Shadow Mask"; private const int MaskGenerationPass = 1; private const int ScreenSpaceShadowPass = 2; private const CameraEvent GenerationCameraEvent = (CameraEvent)5; private const LightEvent ApplicationLightEvent = (LightEvent)3; private static readonly int CloudScaleId = Shader.PropertyToID("_CloudScale"); private static readonly int CloudCoverageId = Shader.PropertyToID("_CloudCoverage"); private static readonly int CloudSoftnessId = Shader.PropertyToID("_CloudSoftness"); private static readonly int ShadowStrengthId = Shader.PropertyToID("_ShadowStrength"); private static readonly int CloudOffsetId = Shader.PropertyToID("_CloudOffset"); private static readonly int CloudEffectFadeId = Shader.PropertyToID("_CloudEffectFade"); private static readonly int DebugMaskId = Shader.PropertyToID("_DebugMask"); private static readonly int MaskHorizonFadeId = Shader.PropertyToID("_CookieHorizonFade"); private static readonly int MaskFadeStartId = Shader.PropertyToID("_CookieFadeStart"); private static readonly int MaskFadeEndId = Shader.PropertyToID("_CookieFadeEnd"); private static readonly int MaskUvToCloudXzId = Shader.PropertyToID("_CookieUvToCloudXZ"); private static readonly int CloudMaskTextureId = Shader.PropertyToID("_CloudCookieTex"); private static readonly int CloudMaskWorldToUvId = Shader.PropertyToID("_CloudCookieWorldToUv"); private static readonly int FrustumCornersWsId = Shader.PropertyToID("_FrustumCornersWS"); private static readonly int CameraWsId = Shader.PropertyToID("_CameraWS"); private static readonly int UseDepthNormalsId = Shader.PropertyToID("_UseDepthNormals"); private readonly ManualLogSource _logger; private readonly CloudShadowsConfig _settings; private Material _material; private RenderTexture _texture; private Camera _camera; private Light _light; private CommandBuffer _generationBuffer; private CommandBuffer _applicationBuffer; private Matrix4x4 _worldToMaskUv = Matrix4x4.identity; private bool _unsupportedPathWarningWasLogged; private bool _shadowMaskWarningWasLogged; private bool _resourceWarningWasLogged; private bool _detachWarningWasLogged; private bool _r8FallbackWarningWasLogged; private bool _disposed; private int _lastAppliedSettingsRevision = -1; private float _nextResourceRetryTime; private string _stateReason = "inactive"; internal Texture Texture => (Texture)(object)_texture; internal Matrix4x4 WorldToCookieUv => _worldToMaskUv; internal bool MaskAvailable { get { if (!_disposed && (Object)(object)_texture != (Object)null && _texture.IsCreated() && (Object)(object)_camera != (Object)null) { return _generationBuffer != null; } return false; } } internal bool LightingAvailable { get { if (MaskAvailable && (Object)(object)_light != (Object)null) { return _applicationBuffer != null; } return false; } } internal bool HasAttachedBuffers { get { if (!((Object)(object)_camera != (Object)null) && !((Object)(object)_light != (Object)null) && _generationBuffer == null) { return _applicationBuffer != null; } return true; } } internal CloudShadowsDirectionalCookie(ManualLogSource logger, CloudShadowsConfig settings, Material material) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) _logger = logger; _settings = settings ?? throw new ArgumentNullException("settings"); _material = material ?? throw new ArgumentNullException("material"); } internal bool UpdateForCamera(Camera camera, bool cloudRenderRequested, float effectFade, Vector2 cloudOffset, Vector3 cameraPosition, float waterLevel, Matrix4x4 frustumCornersWs, bool useDepthNormals) { //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Invalid comparison between Unknown and I4 //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) if (_disposed) { return false; } if (!cloudRenderRequested) { if (HasAttachedBuffers && !Detach()) { return false; } _stateReason = "cloud rendering is not requested"; return false; } try { if (Time.unscaledTime < _nextResourceRetryTime) { return false; } if ((Object)(object)camera == (Object)null) { Detach(); _stateReason = "Camera.main is unavailable"; return false; } if ((int)camera.actualRenderingPath != 3) { Detach(); _stateReason = $"unsupported camera rendering path: {camera.actualRenderingPath}"; if (!_unsupportedPathWarningWasLogged) { LogWarning("CloudShadows screen-space shadow mask requires DeferredShading; cloud shadows are disabled for " + ((object)camera.actualRenderingPath/*cast due to .constrained prefix*/).ToString()); _unsupportedPathWarningWasLogged = true; } return false; } _unsupportedPathWarningWasLogged = false; Light directionalLight = GetDirectionalLight(); if ((Object)(object)directionalLight == (Object)null) { Detach(); _stateReason = "EnvMan.m_dirLight is unavailable or is not directional"; return false; } if ((Object)(object)_camera != (Object)null && (Object)(object)_camera != (Object)(object)camera && !Detach()) { return false; } if ((Object)(object)_light != (Object)(object)directionalLight) { if (!RemoveApplicationBuffer()) { return false; } _light = null; } float num = CalculateHorizonFade(directionalLight); if (!_settings.DebugMaskView && num <= 0f) { if (!Detach()) { return false; } _stateReason = "directional light is below the cloud-mask horizon"; return false; } EnsureTexture(); EnsureGenerationBuffer(camera); _light = directionalLight; float num2 = Mathf.Max(_settings.ShadowDrawDistance, 1f); float maskSize = num2 * 2f; UpdateMaterial(directionalLight, cameraPosition, waterLevel, num2, maskSize, effectFade, cloudOffset, frustumCornersWs, useDepthNormals, num); if (!HasScreenSpaceShadows(directionalLight)) { if (!RemoveApplicationBuffer()) { return false; } _light = directionalLight; _stateReason = "directional screen-space shadows are disabled"; if (!_shadowMaskWarningWasLogged) { LogWarning("CloudShadows cloud lighting is waiting because directional screen-space shadows are disabled"); _shadowMaskWarningWasLogged = true; } return MaskAvailable; } EnsureApplicationBuffer(directionalLight); _shadowMaskWarningWasLogged = false; _resourceWarningWasLogged = false; _nextResourceRetryTime = 0f; _stateReason = "active"; return MaskAvailable; } catch (Exception exception) { _nextResourceRetryTime = Time.unscaledTime + 5f; string text = (_stateReason = "update failed: " + FormatException(exception)); if (!_resourceWarningWasLogged) { LogWarning("CloudShadows screen-space shadow mask update failed: " + text); _resourceWarningWasLogged = true; } Detach(); _stateReason = text; return false; } } internal bool Detach() { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) bool num = RemoveApplicationBuffer(); bool flag = RemoveGenerationBuffer(); if (!num || !flag) { return false; } _camera = null; _light = null; _worldToMaskUv = Matrix4x4.identity; _stateReason = "inactive"; _detachWarningWasLogged = false; return true; } internal CloudShadowsDirectionalCookieSnapshot CreateSnapshot() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) string cameraRenderingPath = "<none>"; try { if ((Object)(object)_camera != (Object)null) { cameraRenderingPath = ((object)_camera.actualRenderingPath/*cast due to .constrained prefix*/).ToString(); } } catch (Exception exception) { cameraRenderingPath = "<unavailable: " + FormatException(exception) + ">"; } Light light = _light; return new CloudShadowsDirectionalCookieSnapshot { ResourcesReady = ((Object)(object)_material != (Object)null && (Object)(object)_texture != (Object)null && _texture.IsCreated()), MaskAvailable = MaskAvailable, LightingAvailable = LightingAvailable, GenerationBufferAttached = ((Object)(object)_camera != (Object)null && _generationBuffer != null), ScreenSpaceBufferAttached = ((Object)(object)light != (Object)null && _applicationBuffer != null), CameraName = GetObjectName((Object)(object)_camera), CameraRenderingPath = cameraRenderingPath, LightName = GetObjectName((Object)(object)light), LightType = (((Object)(object)light == (Object)null) ? "<none>" : ((object)light.type/*cast due to .constrained prefix*/).ToString()), LightShadows = (((Object)(object)light == (Object)null) ? "<none>" : ((object)light.shadows/*cast due to .constrained prefix*/).ToString()), TextureName = GetObjectName((Object)(object)_texture), TextureSize = (((Object)(object)_texture == (Object)null) ? "<none>" : $"{((Texture)_texture).width}x{((Texture)_texture).height}"), TextureFormat = (((Object)(object)_texture == (Object)null) ? "<none>" : ((object)_texture.format/*cast due to .constrained prefix*/).ToString()), StateReason = _stateReason }; } public void Dispose() { if (!_disposed) { if (!Detach()) { LogWarning("CloudShadows screen-space mask disposal kept resources alive because a camera or light command buffer could not be detached safely"); return; } _disposed = true; ReleaseTexture(); Material material = _material; _material = null; DestroyUnityObject((Object)(object)material); } } private void EnsureTexture() { //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0094: 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_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Expected O, but got Unknown //IL_00e8: Unknown result type (might be due to invalid IL or missing references) int cloudMaskResolution = _settings.CloudMaskResolution; if ((Object)(object)_texture != (Object)null && (((Texture)_texture).width != cloudMaskResolution || ((Texture)_texture).height != cloudMaskResolution)) { if (!RemoveGenerationBuffer()) { throw new InvalidOperationException("previous cloud mask generation buffer remains attached"); } _camera = null; ReleaseTexture(); } if ((Object)(object)_texture == (Object)null) { _texture = new RenderTexture(cloudMaskResolution, cloudMaskResolution, 0, GetMaskTextureFormat(), (RenderTextureReadWrite)1) { name = "CloudShadows Directional Mask", filterMode = (FilterMode)1, wrapMode = (TextureWrapMode)1, useMipMap = false, autoGenerateMips = false, antiAliasing = 1, hideFlags = (HideFlags)61 }; } if (!_texture.IsCreated()) { if (!_texture.Create()) { throw new InvalidOperationException("RenderTexture.Create returned false"); } RenderTexture active = RenderTexture.active; try { RenderTexture.active = _texture; GL.Clear(false, true, Color.black); } finally { RenderTexture.active = active; } _resourceWarningWasLogged = false; } } private void EnsureGenerationBuffer(Camera camera) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown //IL_005a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_camera == (Object)(object)camera && _generationBuffer != null) { return; } if (_generationBuffer != null) { if (!RemoveGenerationBuffer()) { throw new InvalidOperationException("previous cloud mask generation buffer remains attached"); } _camera = null; } CommandBuffer val = null; bool flag = false; try { val = new CommandBuffer { name = "CloudShadows Mask Generation" }; val.Blit((Texture)(object)Texture2D.whiteTexture, RenderTargetIdentifier.op_Implicit((Texture)(object)_texture), _material, 1); camera.AddCommandBuffer((CameraEvent)5, val); flag = true; _camera = camera; _generationBuffer = val; val = null; } catch { if (flag && val != null) { _camera = camera; _generationBuffer = val; val = null; RemoveGenerationBuffer(); } ReleaseCommandBuffer(val); throw; } } private void EnsureApplicationBuffer(Light light) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Expected O, but got Unknown //IL_004e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_light == (Object)(object)light && _applicationBuffer != null) { return; } if (_applicationBuffer != null && !RemoveApplicationBuffer()) { throw new InvalidOperationException("previous screen-space shadow command buffer remains attached"); } CommandBuffer val = null; bool flag = false; try { val = new CommandBuffer { name = "CloudShadows Screen-Space Shadow Mask" }; val.Blit((Texture)(object)Texture2D.whiteTexture, RenderTargetIdentifier.op_Implicit((BuiltinRenderTextureType)1), _material, 2); light.AddCommandBuffer((LightEvent)3, val); flag = true; _light = light; _applicationBuffer = val; val = null; } catch { if (flag && val != null) { _light = light; _applicationBuffer = val; val = null; RemoveApplicationBuffer(); } ReleaseCommandBuffer(val); throw; } } private void UpdateMaterial(Light light, Vector3 cameraPosition, float waterLevel, float maskRadius, float maskSize, float effectFade, Vector2 cloudOffset, Matrix4x4 frustumCornersWs, bool useDepthNormals, float horizonFade) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Un