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.26
plugins\ValheimVisualEnhanced\ValheimVisualEnhanced.dll
Decompiled a week 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.Bootstrap; 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.26.0")] [assembly: AssemblyInformationalVersion("0.5.26+2fe87371e922a92df10afe46be864704454eaf18")] [assembly: AssemblyProduct("ValheimVisualEnhanced")] [assembly: AssemblyTitle("ValheimVisualEnhanced")] [assembly: AssemblyVersion("0.5.26.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.26")] [BepInProcess("valheim.exe")] public class ValheimVisualEnhancedPlugin : BaseUnityPlugin { private CloudShadowsConfig _settings; private CloudShadowsPostEffect _postEffect; private EnvironmentPaletteController _environmentPalette; private MeadowsFirefliesEffect _meadowsFireflies; private PlainsFirefliesEffect _plainsFireflies; private WinterSeasonState _winterSeason; 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 {((BaseUnityPlugin)this).Info.Metadata.Version} 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); _winterSeason = new WinterSeasonState(((BaseUnityPlugin)this).Logger); _meadowsFireflies = new MeadowsFirefliesEffect(((BaseUnityPlugin)this).Logger, _settings, _winterSeason); _plainsFireflies = new PlainsFirefliesEffect(((BaseUnityPlugin)this).Logger, _settings, _winterSeason); _postEffect = new CloudShadowsPostEffect(((BaseUnityPlugin)this).Logger, directoryName, _settings, _winterSeason); ((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(); HandleFireflySpriteCapture(); } 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(); _winterSeason?.Update(); _postEffect?.Tick(); _meadowsFireflies?.Tick(); _plainsFireflies?.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(); cloudShadowsRuntimeSnapshot.PlainsFireflies = _plainsFireflies?.CreateSnapshot(); cloudShadowsRuntimeSnapshot.WinterSeason = _winterSeason?.CreateSnapshot(); } CloudShadowsDiagnostics.WriteDump(((BaseUnityPlugin)this).Logger, directoryName, cloudShadowsRuntimeSnapshot); } catch (Exception exception) { LogError("Valheim Visual Enhanced diagnostic shortcut handler failed", exception); } } private void HandleFireflySpriteCapture() { try { if (_settings == null || !_settings.CaptureFireflySpriteOnce) { return; } string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location); if (string.IsNullOrEmpty(directoryName)) { _settings.CompleteFireflySpriteCapture(); ((BaseUnityPlugin)this).Logger.LogWarning((object)"Valheim Visual Enhanced sprite capture skipped: the plugin directory is unknown"); return; } string path = Path.Combine(directoryName, "valheim-firefly-sprite.png"); string text = _meadowsFireflies?.TryCaptureNativeSprite(path); if (text == null) { text = _plainsFireflies?.TryCaptureNativeSprite(path); } if (text == null) { text = "neither swarm has loaded its native particle material; enable a firefly section and visit the biome first"; } _settings.CompleteFireflySpriteCapture(); ((BaseUnityPlugin)this).Logger.LogInfo((object)("Valheim Visual Enhanced firefly sprite capture: " + text)); } catch (Exception exception) { LogError("Valheim Visual Enhanced firefly sprite capture failed", exception); _settings?.CompleteFireflySpriteCapture(); } } 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; PlainsFirefliesEffect plainsFireflies = _plainsFireflies; CloudShadowsConfig settings = _settings; _postEffect = null; _environmentPalette = null; _meadowsFireflies = null; _plainsFireflies = null; _settings = null; _hasObservedEnabled = false; _hasObservedEnvironmentPaletteEnabled = false; try { meadowsFireflies?.Dispose(); } catch (Exception exception) { LogError("Valheim Visual Enhanced Meadows fireflies cleanup failed", exception); } try { plainsFireflies?.Dispose(); } catch (Exception exception2) { LogError("Valheim Visual Enhanced Plains fireflies cleanup failed", exception2); } try { environmentPalette?.Dispose(); } catch (Exception exception3) { LogError("Valheim Visual Enhanced environment palette cleanup failed", exception3); } try { postEffect?.Dispose(); } catch (Exception exception4) { LogError("Valheim Visual Enhanced post-effect cleanup failed", exception4); } try { settings?.Dispose(); } catch (Exception exception5) { LogError("Valheim Visual Enhanced config cleanup failed", exception5); } } 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 static class CausticsLayerB { internal const float TransformM00 = -0.819152f; internal const float TransformM01 = -0.573576f; internal const float TransformM10 = -0.573576f; internal const float TransformM11 = 0.819152f; internal const float Scale = 1.17f; internal const float WindDriftMultiplier = 0.82f; internal static Vector2 TransformVector(Vector2 worldOffset) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001e: 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_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) return new Vector2(-0.819152f * worldOffset.x + -0.573576f * worldOffset.y, -0.573576f * worldOffset.x + 0.819152f * worldOffset.y) * 1.17f; } } internal enum CloudMaskQuality { Low512 = 0x200, Balanced1024 = 0x400, High2048 = 0x800 } internal enum FireflySpriteMode { Pixel, SoftGlow, NativeThistle } 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 KeyCode DiagnosticDumpDefaultKey = (KeyCode)291; 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 PlainsFirefliesSection = "Plains 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> _causticsInterferenceEntry; private readonly ConfigEntry<float> _causticsDistortionEntry; 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<FireflySpriteMode> _meadowsFirefliesSpriteEntry; private readonly ConfigEntry<float> _meadowsFirefliesSpriteScaleEntry; private readonly ConfigEntry<bool> _plainsFirefliesEnabledEntry; private readonly ConfigEntry<int> _plainsFirefliesParticleCountEntry; private readonly ConfigEntry<int> _plainsFirefliesSwarmCountEntry; private readonly ConfigEntry<float> _plainsFirefliesRadiusMetersEntry; private readonly ConfigEntry<float> _plainsFirefliesBrightnessEntry; private readonly ConfigEntry<FireflySpriteMode> _plainsFirefliesSpriteEntry; private readonly ConfigEntry<float> _plainsFirefliesSpriteScaleEntry; private readonly ConfigEntry<bool> _captureFireflySpriteOnceEntry; private readonly ConfigEntry<bool> _autoDisableAtNightEntry; private readonly ConfigEntry<bool> _autoFadeAtLowSunEntry; private readonly ConfigEntry<bool> _autoDisableInRainEntry; private readonly ConfigEntry<bool> _autoDisableInSnowEntry; private readonly ConfigEntry<float> _winterCloudShadowStrengthEntry; private readonly ConfigEntry<bool> _autoDisableInMistlandsAndAshlandsEntry; private readonly ConfigEntry<bool> _autoDisableUnderRoofEntry; private readonly ConfigEntry<bool> _autoDisableMeadowsFirefliesUnderRoofEntry; private bool _applyingConfigMigration; private (bool Enabled, int ParticleCount, float RadiusMeters, float Brightness, FireflySpriteMode Sprite, float SpriteScale) _lastFirefliesSettings; private (bool Enabled, int ParticleCount, int SwarmCount, float RadiusMeters, float Brightness, FireflySpriteMode Sprite, float SpriteScale) _lastPlainsFirefliesSettings; private (float CloudSizeMeters, float CloudCoverage, float EdgeSoftness, float ShadowStrength, bool DebugMaskView) _lastCloudSettings; private (float CausticsPatternSizeMeters, float CausticsMaximumDepthMeters, float CausticsDrawDistanceMeters, bool CausticsFlowingMotion, float CausticsInterference, float CausticsDistortion, bool DebugMaskView) _lastCausticsSettings; internal bool Enabled { get; private set; } internal bool DebugMaskView { 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 CausticsInterference { get; private set; } internal float CausticsDistortion { 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 FireflySpriteMode MeadowsFirefliesSprite { get; private set; } internal float MeadowsFirefliesSpriteScale { get; private set; } internal bool PlainsFirefliesEnabled { get; private set; } internal int PlainsFirefliesParticleCount { get; private set; } internal int PlainsFirefliesSwarmCount { get; private set; } internal float PlainsFirefliesRadiusMeters { get; private set; } internal float PlainsFirefliesBrightness { get; private set; } internal FireflySpriteMode PlainsFirefliesSprite { get; private set; } internal float PlainsFirefliesSpriteScale { get; private set; } internal bool CaptureFireflySpriteOnce { get; private set; } internal bool AutoDisableAtNight { get; private set; } internal bool AutoFadeAtLowSun { get; private set; } internal bool AutoDisableInRain { get; private set; } internal bool AutoDisableInSnow { get; private set; } internal float WinterCloudShadowStrength { get; private set; } internal bool AutoDisableInMistlandsAndAshlands { get; private set; } internal bool AutoDisableUnderRoof { get; private set; } internal bool AutoDisableMeadowsFirefliesUnderRoof { get; private set; } internal int Revision { get; private set; } internal int FirefliesRevision { get; private set; } internal int PlainsFirefliesRevision { get; private set; } internal int CloudsRevision { get; private set; } internal int CausticsRevision { get; private set; } internal CloudShadowsConfig(ConfigFile config) { //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_06b8: Unknown result type (might be due to invalid IL or missing references) //IL_06e2: Unknown result type (might be due to invalid IL or missing references) //IL_070c: Unknown result type (might be due to invalid IL or missing references) //IL_0736: Unknown result type (might be due to invalid IL or missing references) //IL_0760: Unknown result type (might be due to invalid IL or missing references) //IL_078a: Unknown result type (might be due to invalid IL or missing references) //IL_07b4: Unknown result type (might be due to invalid IL or missing references) //IL_07de: 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)); _captureFireflySpriteOnceEntry = config.Bind<bool>("General", "CaptureFireflySpriteOnce", false, CreateDescription("General", "Diagnostic. Set to true and the next frame copies the sprite the NativeThistle mode draws into valheim-firefly-sprite.png beside the mod DLL, then sets this back to false. Use it to settle what Valheim's own particle looks like instead of guessing.", null, -80)); _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", new KeyboardShortcut((KeyCode)291, Array.Empty<KeyCode>()), CreateDescription("Hotkeys", "Writes the complete diagnostic dump, which is how a missing effect is diagnosed. Bound to F10 by default because the whole support flow depends on being able to produce one.", 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 how much direct directional light cloud cover removes.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 2f), 180)); _cloudSizeMetersEntry = config.Bind<float>("Cloud Shadows", "CloudSizeMeters", 75f, 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.5f, 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. This changes how sharp a shadow edge is and how much GPU memory and bandwidth the mask costs. It does not make small cloud fragments appear: those are limited by how much direct light a faint shadow can remove, not by resolution.", 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", 1.8f, CreateDescription("Water Caustic Lighting", "Controls the brightness of underwater caustic lighting. Values above 1 increase the effect beyond its baseline 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)); _causticsInterferenceEntry = config.Bind<float>("Water Caustic Lighting", "Interference", 0.6f, CreateDescription("Water Caustic Lighting", "Blends the two caustic layers from a simple overlay toward an interference network. Higher values keep the bright lines only where both layers focus, so crossings become narrow and bright instead of two full-strength patterns laid on top of each other. Set to 0 for the previous overlay.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), 142)); _causticsDistortionEntry = config.Bind<float>("Water Caustic Lighting", "Distortion", 0.5f, CreateDescription("Water Caustic Lighting", "Stirs the caustic pattern with a slow, irregular distortion so it deforms as it moves instead of sliding. Set to 0 for the previous smooth motion; this also skips the extra texture sample entirely.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), 141)); _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.Emberfall, 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", 24f, 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 firefly sprites without adding lights or bloom. A soft sprite spreads the same alpha over a wider halo, so it reads dimmer than the hard pixel at an equal value.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), 150)); _meadowsFirefliesSpriteEntry = config.Bind<FireflySpriteMode>("Meadows Fireflies", "Sprite", FireflySpriteMode.SoftGlow, CreateDescription("Meadows Fireflies", "How each firefly is drawn. SoftGlow is a small bright core with a soft halo, close to how Valheim's own particles look. Pixel is the hard one-pixel dot earlier versions used. NativeThistle draws the sprite from the game's Thistle particle instead of one the mod makes.", null, 148)); _meadowsFirefliesSpriteScaleEntry = config.Bind<float>("Meadows Fireflies", "SpriteScale", 3f, CreateDescription("Meadows Fireflies", "Multiplies each firefly sprite. 1 is the original 14-24 mm dot, which leaves a soft halo only a pixel or two wide on screen, so the soft modes need a larger value to read at all. The default 3 puts a Meadows firefly at roughly 4-7 cm.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 6f), 146)); _plainsFirefliesEnabledEntry = config.Bind<bool>("Plains Fireflies", "Enabled", true, CreateDescription("Plains Fireflies", "Shows orange fireflies that travel in small drifting groups at night in the Plains. They are a separate effect from the yellow Meadows fireflies and keep their own settings.", null, 180)); _plainsFirefliesParticleCountEntry = config.Bind<int>("Plains Fireflies", "ParticleCount", 40, CreateDescription("Plains Fireflies", "Sets the total number of Plains fireflies across all their groups. This is capped at a deliberately small value to keep the effect inexpensive.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(8, 64), 170)); _plainsFirefliesSwarmCountEntry = config.Bind<int>("Plains Fireflies", "SwarmCount", 4, CreateDescription("Plains Fireflies", "How many separate groups the Plains fireflies split into. Fewer groups means each one is denser and reads more clearly as a swarm; more groups means more to notice as you travel.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 8), 165)); _plainsFirefliesRadiusMetersEntry = config.Bind<float>("Plains Fireflies", "RadiusMeters", 20f, CreateDescription("Plains Fireflies", "Sets the radius around the player within which the groups may travel.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(6f, 40f), 160)); _plainsFirefliesBrightnessEntry = config.Bind<float>("Plains Fireflies", "Brightness", 0.9f, CreateDescription("Plains Fireflies", "Controls the alpha of the orange firefly sprites without adding lights or bloom.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), 150)); _plainsFirefliesSpriteEntry = config.Bind<FireflySpriteMode>("Plains Fireflies", "Sprite", FireflySpriteMode.SoftGlow, CreateDescription("Plains Fireflies", "How each Plains firefly is drawn. SoftGlow is a small bright core with a soft halo, close to how Valheim's own particles look. Pixel is the hard one-pixel dot the first Plains swarm shipped with. NativeThistle draws the sprite from the game's Thistle particle instead of one the mod makes.", null, 148)); _plainsFirefliesSpriteScaleEntry = config.Bind<float>("Plains Fireflies", "SpriteScale", 3f, CreateDescription("Plains Fireflies", "Multiplies each Plains firefly sprite. 1 is the original 15-26 mm dot. Raising it widens the halo but also the distance at which a swarm still reads as separate dots rather than one blob.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 6f), 146)); _autoDisableAtNightEntry = config.Bind<bool>("Automation", "AutoDisableAtNight", true, CreateDescription("Automation", "Smoothly fades cloud shadows out while it is night.", null, 110)); _autoFadeAtLowSunEntry = config.Bind<bool>("Automation", "AutoFadeAtLowSun", true, CreateDescription("Automation", "Fades cloud shadows out as the sun approaches the horizon, so dawn and dusk keep slow, wide, soft shadows instead of stretched fast ones. The fade begins around 15 degrees of elevation and completes around 5 degrees. Disable to keep full-strength cloud shadows right down to the horizon.", null, 106)); _autoDisableInRainEntry = config.Bind<bool>("Automation", "AutoDisableInRain", true, CreateDescription("Automation", "Smoothly fades cloud shadows out during rain and wet storms.", null, 105)); _autoDisableInSnowEntry = config.Bind<bool>("Automation", "AutoDisableInSnow", true, CreateDescription("Automation", "Smoothly fades cloud shadows out while Valheim is snowing, which covers mountain and Deep North snow storms.", null, 104)); _winterCloudShadowStrengthEntry = config.Bind<float>("Automation", "WinterCloudShadowStrength", 0.3f, CreateDescription("Automation", "How much cloud-shadow strength remains in winter while the optional RustyMods Seasonality or shudnal Seasons mod reports winter. 0.3 keeps a faint overcast pattern, 0 hides the shadows completely, and 1 ignores the season.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), 103)); _autoDisableInMistlandsAndAshlandsEntry = config.Bind<bool>("Automation", "AutoDisableInMistlandsAndAshlands", true, CreateDescription("Automation", "Smoothly fades cloud shadows out in the Mistlands and Ashlands. Caustics remain independent.", null, 102)); _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 the Meadows and Plains fireflies out under a roof or inside an interior. The key still says Meadows for compatibility with existing configurations; it governs both swarms.", 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; } internal void CompleteFireflySpriteCapture() { if (_captureFireflySpriteOnceEntry.Value) { _captureFireflySpriteOnceEntry.Value = false; } } 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; _causticsInterferenceEntry.SettingChanged += HandleSettingChanged; _causticsDistortionEntry.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; _meadowsFirefliesSpriteEntry.SettingChanged += HandleSettingChanged; _meadowsFirefliesSpriteScaleEntry.SettingChanged += HandleSettingChanged; _plainsFirefliesEnabledEntry.SettingChanged += HandleSettingChanged; _plainsFirefliesParticleCountEntry.SettingChanged += HandleSettingChanged; _plainsFirefliesSwarmCountEntry.SettingChanged += HandleSettingChanged; _plainsFirefliesRadiusMetersEntry.SettingChanged += HandleSettingChanged; _plainsFirefliesBrightnessEntry.SettingChanged += HandleSettingChanged; _plainsFirefliesSpriteEntry.SettingChanged += HandleSettingChanged; _plainsFirefliesSpriteScaleEntry.SettingChanged += HandleSettingChanged; _captureFireflySpriteOnceEntry.SettingChanged += HandleSettingChanged; _autoDisableAtNightEntry.SettingChanged += HandleSettingChanged; _autoFadeAtLowSunEntry.SettingChanged += HandleSettingChanged; _autoDisableInRainEntry.SettingChanged += HandleSettingChanged; _autoDisableInSnowEntry.SettingChanged += HandleSettingChanged; _winterCloudShadowStrengthEntry.SettingChanged += HandleSettingChanged; _autoDisableInMistlandsAndAshlandsEntry.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; _causticsInterferenceEntry.SettingChanged -= HandleSettingChanged; _causticsDistortionEntry.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; _meadowsFirefliesSpriteEntry.SettingChanged -= HandleSettingChanged; _meadowsFirefliesSpriteScaleEntry.SettingChanged -= HandleSettingChanged; _plainsFirefliesEnabledEntry.SettingChanged -= HandleSettingChanged; _plainsFirefliesParticleCountEntry.SettingChanged -= HandleSettingChanged; _plainsFirefliesSwarmCountEntry.SettingChanged -= HandleSettingChanged; _plainsFirefliesRadiusMetersEntry.SettingChanged -= HandleSettingChanged; _plainsFirefliesBrightnessEntry.SettingChanged -= HandleSettingChanged; _plainsFirefliesSpriteEntry.SettingChanged -= HandleSettingChanged; _plainsFirefliesSpriteScaleEntry.SettingChanged -= HandleSettingChanged; _captureFireflySpriteOnceEntry.SettingChanged -= HandleSettingChanged; _autoDisableAtNightEntry.SettingChanged -= HandleSettingChanged; _autoFadeAtLowSunEntry.SettingChanged -= HandleSettingChanged; _autoDisableInRainEntry.SettingChanged -= HandleSettingChanged; _autoDisableInSnowEntry.SettingChanged -= HandleSettingChanged; _winterCloudShadowStrengthEntry.SettingChanged -= HandleSettingChanged; _autoDisableInMistlandsAndAshlandsEntry.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_003a: Unknown result type (might be due to invalid IL or missing references) //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_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) //IL_025a: Unknown result type (might be due to invalid IL or missing references) Enabled = _enabledEntry.Value; DebugMaskView = _debugMaskViewEntry.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; CausticsInterference = _causticsInterferenceEntry.Value; CausticsDistortion = _causticsDistortionEntry.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; MeadowsFirefliesSprite = _meadowsFirefliesSpriteEntry.Value; MeadowsFirefliesSpriteScale = _meadowsFirefliesSpriteScaleEntry.Value; PlainsFirefliesEnabled = _plainsFirefliesEnabledEntry.Value; PlainsFirefliesParticleCount = _plainsFirefliesParticleCountEntry.Value; PlainsFirefliesSwarmCount = _plainsFirefliesSwarmCountEntry.Value; PlainsFirefliesRadiusMeters = _plainsFirefliesRadiusMetersEntry.Value; PlainsFirefliesBrightness = _plainsFirefliesBrightnessEntry.Value; PlainsFirefliesSprite = _plainsFirefliesSpriteEntry.Value; PlainsFirefliesSpriteScale = _plainsFirefliesSpriteScaleEntry.Value; CaptureFireflySpriteOnce = _captureFireflySpriteOnceEntry.Value; AutoDisableAtNight = _autoDisableAtNightEntry.Value; AutoFadeAtLowSun = _autoFadeAtLowSunEntry.Value; AutoDisableInRain = _autoDisableInRainEntry.Value; AutoDisableInSnow = _autoDisableInSnowEntry.Value; WinterCloudShadowStrength = _winterCloudShadowStrengthEntry.Value; AutoDisableInMistlandsAndAshlands = _autoDisableInMistlandsAndAshlandsEntry.Value; AutoDisableUnderRoof = _autoDisableUnderRoofEntry.Value; AutoDisableMeadowsFirefliesUnderRoof = _autoDisableMeadowsFirefliesUnderRoofEntry.Value; (bool, int, float, float, FireflySpriteMode, float) tuple = (MeadowsFirefliesEnabled, MeadowsFirefliesParticleCount, MeadowsFirefliesRadiusMeters, MeadowsFirefliesBrightness, MeadowsFirefliesSprite, MeadowsFirefliesSpriteScale); (bool, int, float, float, FireflySpriteMode, float) tuple2 = tuple; (bool, int, float, float, FireflySpriteMode, float) lastFirefliesSettings = _lastFirefliesSettings; if (tuple2.Item1 != lastFirefliesSettings.Item1 || tuple2.Item2 != lastFirefliesSettings.Item2 || tuple2.Item3 != lastFirefliesSettings.Item3 || tuple2.Item4 != lastFirefliesSettings.Item4 || tuple2.Item5 != lastFirefliesSettings.Item5 || tuple2.Item6 != lastFirefliesSettings.Item6) { _lastFirefliesSettings = tuple; FirefliesRevision++; } (bool, int, int, float, float, FireflySpriteMode, float) tuple3 = (PlainsFirefliesEnabled, PlainsFirefliesParticleCount, PlainsFirefliesSwarmCount, PlainsFirefliesRadiusMeters, PlainsFirefliesBrightness, PlainsFirefliesSprite, PlainsFirefliesSpriteScale); (bool, int, int, float, float, FireflySpriteMode, float) tuple4 = tuple3; (bool, int, int, float, float, FireflySpriteMode, float) lastPlainsFirefliesSettings = _lastPlainsFirefliesSettings; if (tuple4.Item1 != lastPlainsFirefliesSettings.Item1 || tuple4.Item2 != lastPlainsFirefliesSettings.Item2 || tuple4.Item3 != lastPlainsFirefliesSettings.Item3 || tuple4.Item4 != lastPlainsFirefliesSettings.Item4 || tuple4.Item5 != lastPlainsFirefliesSettings.Item5 || tuple4.Item6 != lastPlainsFirefliesSettings.Item6 || tuple4.Item7 != lastPlainsFirefliesSettings.Item7) { _lastPlainsFirefliesSettings = tuple3; PlainsFirefliesRevision++; } (float, float, float, float, bool) tuple5 = (CloudSizeMeters, CloudCoverage, EdgeSoftness, ShadowStrength, DebugMaskView); (float, float, float, float, bool) tuple6 = tuple5; (float, float, float, float, bool) lastCloudSettings = _lastCloudSettings; if (tuple6.Item1 != lastCloudSettings.Item1 || tuple6.Item2 != lastCloudSettings.Item2 || tuple6.Item3 != lastCloudSettings.Item3 || tuple6.Item4 != lastCloudSettings.Item4 || tuple6.Item5 != lastCloudSettings.Item5) { _lastCloudSettings = tuple5; CloudsRevision++; } (float, float, float, bool, float, float, bool) tuple7 = (CausticsPatternSizeMeters, CausticsMaximumDepthMeters, CausticsDrawDistanceMeters, CausticsFlowingMotion, CausticsInterference, CausticsDistortion, DebugMaskView); (float, float, float, bool, float, float, bool) tuple8 = tuple7; (float, float, float, bool, float, float, bool) lastCausticsSettings = _lastCausticsSettings; if (tuple8.Item1 != lastCausticsSettings.Item1 || tuple8.Item2 != lastCausticsSettings.Item2 || tuple8.Item3 != lastCausticsSettings.Item3 || tuple8.Item4 != lastCausticsSettings.Item4 || tuple8.Item5 != lastCausticsSettings.Item5 || tuple8.Item6 != lastCausticsSettings.Item6 || tuple8.Item7 != lastCausticsSettings.Item7) { _lastCausticsSettings = tuple7; CausticsRevision++; } 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" }; private const int TimestampedDumpRetention = 12; 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)); string text2 = Path.Combine(pluginDirectory, $"debug_output_{DateTime.UtcNow:yyyyMMdd'T'HHmmss'Z'}.txt"); File.WriteAllText(text2, contents, new UTF8Encoding(encoderShouldEmitUTF8Identifier: false)); logger.LogInfo((object)("Valheim Visual Enhanced debug dump also written to: " + text2)); PruneTimestampedDumps(pluginDirectory, logger); } catch (Exception exception2) { TryLogError(logger, "Could not write Valheim Visual Enhanced debug_output.txt", exception2); } } private static void PruneTimestampedDumps(string pluginDirectory, ManualLogSource logger) { try { string[] files = Directory.GetFiles(pluginDirectory, "debug_output_*Z.txt"); if (files.Length > 12) { Array.Sort(files, (IComparer<string>?)StringComparer.Ordinal); int num = files.Length - 12; for (int i = 0; i < num; i++) { File.Delete(files[i]); } } } catch (Exception exception) { TryLogError(logger, "Could not prune old Valheim Visual Enhanced timestamped dumps", exception); } } 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 unsafe static void AppendRuntimeState(StringBuilder dump, CloudShadowsRuntimeSnapshot snapshot) { //IL_040a: Unknown result type (might be due to invalid IL or missing references) //IL_047a: Unknown result type (might be due to invalid IL or missing references) //IL_047f: Unknown result type (might be due to invalid IL or missing references) //IL_04a0: Unknown result type (might be due to invalid IL or missing references) //IL_04d8: Unknown result type (might be due to invalid IL or missing references) //IL_04f4: Unknown result type (might be due to invalid IL or missing references) //IL_04f9: Unknown result type (might be due to invalid IL or missing references) //IL_0519: Unknown result type (might be due to invalid IL or missing references) //IL_07a7: Unknown result type (might be due to invalid IL or missing references) //IL_09d2: Unknown result type (might be due to invalid IL or missing references) //IL_0b12: 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("Sun downward component: " + FormatOptionalValue(snapshot.SunDownwardAmount)); dump.AppendLine("Sun elevation: " + FormatSunElevationDegrees(snapshot.SunDownwardAmount)); dump.AppendLine($"Auto-fade cloud shadows at low sun: {snapshot.AutoFadeAtLowSun}"); dump.AppendLine($"Wet weather: {snapshot.IsWetWeather}"); dump.AppendLine($"Auto-disable cloud shadows in rain: {snapshot.AutoDisableInRain}"); dump.AppendLine($"Snowing: {snapshot.IsSnowing}"); dump.AppendLine($"Snow buildup: {snapshot.SnowBuildup:R}"); dump.AppendLine("Current environment: " + (snapshot.CurrentEnvironmentName ?? "<none>")); dump.AppendLine($"Auto-disable cloud shadows in snow: {snapshot.AutoDisableInSnow}"); dump.AppendLine($"Winter season: {snapshot.IsWinterSeason}"); dump.AppendLine("Winter cloud shadow strength: " + $"{snapshot.WinterCloudShadowStrength:R}"); dump.AppendLine("Effective winter strength scale: " + $"{snapshot.WinterStrengthScale:R}"); WinterSeasonSnapshot winterSeason = snapshot.WinterSeason; if (winterSeason != null) { dump.AppendLine($"Seasonality loaded: {winterSeason.SeasonalityLoaded}"); dump.AppendLine($"Seasonality winter global key: {winterSeason.SeasonalityWinter}"); dump.AppendLine($"Seasons loaded: {winterSeason.SeasonsLoaded}"); dump.AppendLine("Seasons current season: " + (winterSeason.SeasonsCurrentSeason ?? "<none>")); dump.AppendLine($"Seasons winter: {winterSeason.SeasonsWinter}"); } else { dump.AppendLine("Season compatibility: <unavailable>"); } dump.AppendLine($"Cloud-shadow excluded biome: {snapshot.IsCloudShadowExcludedBiome}"); dump.AppendLine("Auto-disable cloud shadows in Mistlands and Ashlands: " + snapshot.AutoDisableInMistlandsAndAshlands); 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}"); Vector2 val = snapshot.CloudShadowAdvectionDirection; dump.AppendLine("Cloud-shadow advection direction: " + ((object)(*(Vector2*)(&val))/*cast due to .constrained prefix*/).ToString()); dump.AppendLine($"Smoothed caustics wind direction: {snapshot.SmoothedCausticsWindDirection}"); dump.AppendLine($"Smoothed caustics wind intensity: {snapshot.SmoothedCausticsWindIntensity:R}"); dump.AppendLine($"Cloud offset: {snapshot.CloudOffset}"); val = snapshot.CloudOffset; dump.AppendLine($"Cloud offset magnitude: {((Vector2)(ref val)).magnitude:R}"); 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 sprite mode: {meadowsFireflies.Sprite}"); dump.AppendLine("Meadows fireflies sprite in use (name, size, format, filtering): " + (meadowsFireflies.SpriteDescription ?? "<none>")); dump.AppendLine("Meadows fireflies native particle shader: " + (meadowsFireflies.NativeShaderName ?? "<none>")); dump.AppendLine($"Meadows fireflies sprite scale: {meadowsFireflies.SpriteScale:R}"); dump.AppendLine("Meadows fireflies sprite size meters: " + $"{meadowsFireflies.StartSizeMinimumMeters:R} to " + $"{meadowsFireflies.StartSizeMaximumMeters:R}"); dump.AppendLine("Meadows fireflies tint (a constant change is only verifiable " + $"here): {meadowsFireflies.Tint}"); dump.AppendLine("Meadows fireflies auto-disable under roof: " + meadowsFireflies.AutoDisableUnderRoof); dump.AppendLine($"Meadows fireflies wet weather: {meadowsFireflies.WetWeather}"); dump.AppendLine("Meadows fireflies state reason: " + meadowsFireflies.StateReason); } PlainsFirefliesSnapshot plainsFireflies = snapshot.PlainsFireflies; if (plainsFireflies == null) { dump.AppendLine("Plains fireflies: <unavailable>"); } else { dump.AppendLine($"Plains fireflies resources ready: {plainsFireflies.ResourcesReady}"); dump.AppendLine($"Plains fireflies active: {plainsFireflies.Active}"); dump.AppendLine($"Plains fireflies enabled: {plainsFireflies.Enabled}"); dump.AppendLine($"Plains fireflies particle count: {plainsFireflies.ParticleCount}"); dump.AppendLine("Plains fireflies placed particles (0 with an active swarm means every spawn point was rejected as sheltered): " + plainsFireflies.PlacedParticleCount); dump.AppendLine($"Plains fireflies swarm count: {plainsFireflies.SwarmCount}"); dump.AppendLine($"Plains fireflies radius meters: {plainsFireflies.RadiusMeters:R}"); dump.AppendLine($"Plains fireflies brightness: {plainsFireflies.Brightness:R}"); dump.AppendLine($"Plains fireflies sprite mode: {plainsFireflies.Sprite}"); dump.AppendLine("Plains fireflies sprite in use (name, size, format, filtering): " + (plainsFireflies.SpriteDescription ?? "<none>")); dump.AppendLine("Plains fireflies native particle shader: " + (plainsFireflies.NativeShaderName ?? "<none>")); dump.AppendLine($"Plains fireflies sprite scale: {plainsFireflies.SpriteScale:R}"); dump.AppendLine("Plains fireflies sprite size meters: " + $"{plainsFireflies.StartSizeMinimumMeters:R} to " + $"{plainsFireflies.StartSizeMaximumMeters:R}"); dump.AppendLine("Plains fireflies tint: " + $"{plainsFireflies.Tint}"); dump.AppendLine("Plains fireflies auto-disable under roof (shared with Meadows): " + plainsFireflies.AutoDisableUnderRoof); dump.AppendLine($"Plains fireflies wet weather: {plainsFireflies.WetWeather}"); dump.AppendLine("Plains fireflies state reason: " + plainsFireflies.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($"Caustics surface visible in view: {snapshot.CausticsSurfaceVisible}"); dump.AppendLine("Metres to the water plane along the lowest view ray: " + FormatOptionalValue(snapshot.CausticsMetresToWaterPlane)); 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 caustics settings revision: {renderer.AppliedCausticsRevision}"); dump.AppendLine($"Disposal pending: {renderer.DisposalPending}"); AppendDirectionalCookieState(dump, snapshot, renderer.DirectionalCookie); } private static void AppendDirectionalCookieState(StringBuilder dump, CloudShadowsRuntimeSnapshot runtime, 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 mask horizon fade: " + FormatOptionalValue(cookie.HorizonFade)); dump.AppendLine("Cloud mask sun downward component: " + FormatOptionalValue(cookie.SunDownwardAmount)); dump.AppendLine($"Applied cloud settings revision: {cookie.AppliedCloudsRevision}"); dump.AppendLine("Cloud shadow state reason: " + cookie.StateReason); dump.AppendLine("Cloud shadow visibility reason: " + ((runtime == null) ? "<runtime unavailable>" : GetCloudShadowStateReason(runtime, cookie))); } private static string GetCloudShadowStateReason(CloudShadowsRuntimeSnapshot runtime, CloudShadowsDirectionalCookieSnapshot cookie) { if (!runtime.WorldReady) { return "world is not ready"; } if (!runtime.Enabled) { return "disabled by General.Enabled"; } if (runtime.DebugMaskView) { return "showing the raw cloud mask instead of lighting"; } if (runtime.IsNight && runtime.AutoDisableAtNight) { return "disabled at night"; } if (runtime.IsWetWeather && runtime.AutoDisableInRain) { return "disabled in rain or a wet storm"; } if (runtime.IsSnowing && runtime.AutoDisableInSnow) { return "disabled while snow is accumulating"; } if (runtime.IsCloudShadowExcludedBiome && runtime.AutoDisableInMistlandsAndAshlands) { return "disabled in the Mistlands or Ashlands"; } if (runtime.IsUnderRoof && runtime.AutoDisableUnderRoof) { return "disabled under a roof or in a cave"; } if (!runtime.VisibilityTarget) { return "inactive while controller conditions are changing"; } if (runtime.WinterStrengthScale < 1f) { return "winter dims the shadows to " + $"{runtime.WinterStrengthScale:R} of full strength"; } if (runtime.EffectFade <= 0.001f) { return "visibility target is active; effect is fading in"; } if (cookie == null) { return "cloud mask controller is unavailable"; } if (!cookie.ResourcesReady) { return "cloud mask resources are unavailable"; } if (!cookie.GenerationBufferAttached) { return "cloud mask is waiting for a camera attachment"; } if (!runtime.CloudRenderRequested) { return "cloud rendering is not requested"; } if (!cookie.ScreenSpaceBufferAttached) { return "screen-space shadow buffer is not attached; check that the game has directional screen-space shadows enabled"; } if (cookie.HorizonFade < 0.999f) { return "the sun is inside the horizon fade ramp, at " + FormatOptionalValue(cookie.HorizonFade) + " of full strength"; } return "active"; } 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.Ad