Decompiled source of FogAndColdControl v1.1.6
plugins/Thanks.Fog&ColdControl.dll
Decompiled a month ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using ExitGames.Client.Photon; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; using Photon.Realtime; using TMPro; using UnityEngine; using UnityEngine.SceneManagement; using UnityEngine.UI; using Zorro.Core; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("Thanks.Fog&ColdControl")] [assembly: AssemblyDescription("Host-only PEAK fog and cold control mode with synced fog movement, compass rewards, HUD, and separate fog-cold and night-cold handling.")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Thanks")] [assembly: AssemblyProduct("Fog&ColdControl")] [assembly: AssemblyCopyright("Copyright (c) Thanks 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("f3d09c64-b194-4a16-9196-85106f2f0d01")] [assembly: AssemblyFileVersion("1.1.9.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.1.9.0")] [module: UnverifiableCode] [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 FogColdControl { [HarmonyPatch(typeof(Fog), "MakePlayerCold")] internal static class FogMakePlayerColdPatch { private static bool Prefix() { if (Plugin.ShouldSuppressFogColdDamage()) { return false; } Plugin.BeginLocalFogStatusSource(); return true; } private static Exception Finalizer(Exception __exception) { Plugin.EndLocalFogStatusSource(); return __exception; } } [HarmonyPatch(typeof(FogSphere), "SetSharderVars")] internal static class FogSphereSetShaderVarsPatch { private static void Prefix() { Plugin.BeginLocalFogStatusSource(); } private static Exception Finalizer(Exception __exception) { Plugin.EndLocalFogStatusSource(); return __exception; } } [HarmonyPatch(typeof(OrbFogHandler), "WaitToMove")] internal static class OrbFogHandlerWaitToMovePatch { private static bool Prefix(OrbFogHandler __instance) { return !Plugin.ShouldBlockVanillaOrbFogWait(__instance); } } [HarmonyPatch(typeof(OrbFogHandler), "Start")] internal static class OrbFogHandlerStartPatch { private static void Postfix(OrbFogHandler __instance) { Plugin.NotifyFogHandlerChanged(__instance); } } [HarmonyPatch(typeof(OrbFogHandler), "SetFogOrigin")] internal static class OrbFogHandlerSetFogOriginPatch { private static void Postfix(OrbFogHandler __instance) { Plugin.NotifyFogHandlerChanged(__instance); } } [HarmonyPatch(typeof(OrbFogHandler), "RPC_InitFog")] internal static class OrbFogHandlerRpcInitFogPatch { private static void Postfix(OrbFogHandler __instance) { Plugin.NotifyFogHandlerChanged(__instance); } } [HarmonyPatch(typeof(Ascents), "get_fogEnabled")] internal static class AscentsFogEnabledPatch { private static void Postfix(ref bool __result) { if (Plugin.ShouldForceFogCoverageEverywhere()) { __result = true; } } } [HarmonyPatch(typeof(Ascents), "get_isNightCold")] internal static class AscentsNightColdPatch { private static void Postfix(ref bool __result) { if (Plugin.ShouldDisableNightColdFeatureLocally()) { __result = false; } } } [HarmonyPatch(typeof(CharacterAfflictions), "AddStatus")] internal static class CharacterAfflictionsAddStatusPatch { private static bool Prefix(CharacterAfflictions __instance, STATUSTYPE statusType, ref bool __result) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) if (!Plugin.ShouldSuppressLocalFogSourceStatus(__instance, statusType)) { return true; } __result = false; return false; } } [HarmonyPatch(typeof(CharacterAfflictions), "RPC_ApplyStatusesFromFloatArray")] internal static class CharacterAfflictionsRpcApplyStatusesFromFloatArrayPatch { private static bool Prefix(CharacterAfflictions __instance, float[] data, PhotonMessageInfo info) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) return !Plugin.TryApplyHostManagedIncomingStatusSuppression(__instance, data, info); } } [HarmonyPatch(typeof(Campfire), "Light_Rpc")] internal static class CampfireLightRpcPatch { private static void Postfix(Campfire __instance) { Plugin.NotifyCampfireLit(__instance); } } [BepInPlugin("com.github.Thanks.FogClimb", "Fog&ColdControl", "1.1.9")] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class Plugin : BaseUnityPlugin { private enum ConfigKey { ModEnabled, FogColdSuppression, NightColdEnabled, FogSpeed, FogDelay, CompassEnabled, CompassHotkey, FogPauseHotkey, FogUiEnabled, CampfireLocatorUiEnabled, FogUiX, FogUiY, FogUiScale, FogUiEntrySpacing, FogUiLayout, FogUiBackgroundOpacity, FogStateUiEnabled, RunTimerUiEnabled, DayNightTimeUiEnabled, AltitudeUiEnabled, FogSpeedUiEnabled, CampfireDistanceUiEnabled, WeatherHazardUiEnabled, FogTimingUiEnabled, DirectStartUiEnabled, FogApproachUiEnabled, LavaApproachUiEnabled, NextBiomeUiEnabled } internal enum FogUiLayoutKind { Horizontal, Vertical } private enum VanillaProgressStartUiState { Hidden, Unavailable, Tracking } private enum FogUiIconKind { State, StateRunning, StateWaiting, StatePaused, StateArrived, StateSyncing, StateOff, StateLobby, StateIdle, Speed, Buffer, Delay, Timer, Campfire, Biome, Altitude, Lava, Petrify, Distance, Eta, Direct, Pause, FogHandling, Night, DayTime, NightTime, Wind, Snowstorm, Rain, Separator } private enum FogUiThemeKind { Day, Night, Fog } private sealed class FogUiEntryView { public RectTransform Root; public Image Icon; public TextMeshProUGUI Text; public RectTransform BarRoot; public Image BarBackground; public Image BarFill; public TextMeshProUGUI BarText; public string LastText = string.Empty; public FogUiIconKind LastIconKind; public Color LastIconColor = Color.clear; public Color LastTextColor = Color.clear; public float LastProgress = -1f; public Color LastBarFillColor = Color.clear; public Color LastBarBackgroundColor = Color.clear; public string LastBarText = string.Empty; public LayoutElement EntryLayoutElement; public LayoutElement TextLayoutElement; public float LastContentWidth = -1f; public bool LastHasProgressBar; public bool LastHasTextGradient; public Color LastGradientLeft = Color.clear; public Color LastGradientRight = Color.clear; } private sealed class ConfigFileEntryBlock { public ConfigKey Key; public bool HasKnownKey; public string SectionName = string.Empty; public List<string> Lines = new List<string>(); } private readonly struct FogUiDisplayEntry { public readonly FogUiIconKind Kind; public readonly Color IconColor; public readonly string Text; public readonly bool HasProgressBar; public readonly float Progress; public readonly Color BarFillColor; public readonly Color BarBackgroundColor; public readonly string BarText; public readonly bool HasTextGradient; public readonly Color TextGradientLeft; public readonly Color TextGradientRight; public FogUiDisplayEntry(FogUiIconKind kind, Color iconColor, string text) : this(kind, iconColor, text, hasProgressBar: false, 0f, Color.white, Color.clear, string.Empty, hasTextGradient: false, Color.white, Color.white) { }//IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) public FogUiDisplayEntry(FogUiIconKind kind, Color iconColor, string text, float progress, Color barFillColor, Color barBackgroundColor, string barText) : this(kind, iconColor, text, hasProgressBar: true, progress, barFillColor, barBackgroundColor, barText, hasTextGradient: false, Color.white, Color.white) { }//IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //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) public FogUiDisplayEntry(FogUiIconKind kind, Color iconColor, string text, Color gradientLeft, Color gradientRight) : this(kind, iconColor, text, hasProgressBar: false, 0f, Color.white, Color.clear, string.Empty, hasTextGradient: true, gradientLeft, gradientRight) { }//IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) private FogUiDisplayEntry(FogUiIconKind kind, Color iconColor, string text, bool hasProgressBar, float progress, Color barFillColor, Color barBackgroundColor, string barText, bool hasTextGradient, Color gradientLeft, Color gradientRight) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0036: 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) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) Kind = kind; IconColor = iconColor; Text = text ?? string.Empty; HasProgressBar = hasProgressBar; Progress = Mathf.Clamp01(progress); BarFillColor = barFillColor; BarBackgroundColor = barBackgroundColor; BarText = barText ?? string.Empty; HasTextGradient = hasTextGradient; TextGradientLeft = gradientLeft; TextGradientRight = gradientRight; } } public const string PluginGuid = "com.github.Thanks.FogClimb"; public const string PluginName = "Fog&ColdControl"; public const string PluginVersion = "1.1.9"; private const string PreferredConfigFileName = "Thanks.Fog&ColdControl.cfg"; private const string PreferredPluginFileName = "Thanks.Fog&ColdControl.dll"; private static readonly string[] LegacyConfigFileNames = new string[2] { "Thanks.FogClimb.cfg", "com.github.Thanks.FogClimb.cfg" }; private static readonly string[] LegacyPluginFileNames = new string[2] { "Thanks.FogClimb.dll", "com.github.Thanks.FogClimb.dll" }; private const float DefaultVanillaFogSpeed = 0.3f; private const float DefaultFogSpeed = 0.4f; private const float DefaultFogDelaySeconds = 900f; private const float MinFogSpeed = 0.3f; private const float MaxFogSpeed = 20f; private const float MinFogDelaySeconds = 20f; private const float MaxFogDelaySeconds = 1000f; private const float DefaultFogUiX = 60f; private const float DefaultFogUiY = 0f; private const float DefaultFogUiScale = 0.9f; private const float MinFogUiX = 0f; private const float MaxFogUiX = 3840f; private const float MinFogUiY = 0f; private const float MaxFogUiY = 2160f; private const float MinFogUiScale = 0.5f; private const float MaxFogUiScale = 2.5f; private const float DefaultFogUiEntrySpacing = 8f; private const float MinFogUiEntrySpacing = 0f; private const float MaxFogUiEntrySpacing = 40f; private const float DefaultFogUiBackgroundOpacity = 0f; private const float MinFogUiBackgroundOpacity = 0f; private const float MaxFogUiBackgroundOpacity = 1f; private const int FogUiBackgroundSpriteSize = 64; private const float FogUiBackgroundCornerRadiusX = 12f; private const float FogUiBackgroundCornerRadiusY = 10f; private const float FogUiBackgroundSliceBorderX = 12f; private const float FogUiBackgroundSliceBorderY = 10f; private const float FogUiVerticalContainerWidth = 176f; private const float FogUiVerticalMinHeight = 34f; private const float FogUiEntryHeight = 34f; private const float FogUiHorizontalWidth = 1180f; private const float FogUiHorizontalHeight = 34f; private const float FogUiBackgroundVerticalPadding = 2f; private const float FogHandlerSearchIntervalSeconds = 1f; private const float FogStateSyncIntervalSeconds = 0.18f; private const float FogStateSyncSizeThreshold = 0.35f; private const float RemoteStatusSyncIntervalSeconds = 0.25f; private const float LateGameRemoteStatusSyncIntervalSeconds = 0.1f; private const float CompassGrantSyncIntervalSeconds = 0.75f; private const float FogColdPerSecond = 0.0105f; private const float FogSporesPerSecond = 0.005f; private const float RemoteFogSuppressionSafetyMultiplier = 1.12f; private const float NightColdPerSecond = 0.008f; private const float StatusChunkSize = 0.025f; private const float StalledFogResumeDelayRatio = 0.02f; private const float MinStalledFogResumeDelaySeconds = 2f; private const float MaxStalledFogResumeDelaySeconds = 8f; private const float HiddenFogDelayBufferSeconds = 10f; private const float FogEtaMinSampleIntervalSeconds = 0.1f; private const float FogEtaMinSizeDelta = 0.05f; private const float FogEtaMinReliableRate = 0.02f; private const float FogEtaRateSmoothing = 0.15f; private const float FogEtaDangerWindowSeconds = 45f; private const float FogEtaWarningWindowSeconds = 90f; private const float FogEtaDisplayStepSeconds = 0.5f; private const float FogEtaIncreaseNoiseToleranceSeconds = 2f; private const float FogEtaMaxDisplayIncreasePerSecond = 1.5f; private const float FogEtaMaxExtraDisplayDecreasePerSecond = 3f; private const float FogDistanceDangerWindowUnits = 120f; private const float FogDistanceWarningWindowUnits = 300f; private const float FogDistanceEtaRefreshIntervalSeconds = 0.8f; private const float GuestFogSpeedDisplaySmoothing = 0.03f; private const float GuestFogSpeedStableTolerance = 0.001f; private const float GuestFogSpeedStableConfirmSeconds = 3f; private const float GuestFogSpeedDisplayStep = 0.1f; private const float GuestFogSpeedMinUpdateIntervalSeconds = 1.5f; private const int FogUiDelaySecondsIntegerDigits = 2; private const string FogUiDistanceLabelColor = "#79E2D0"; private const string FogUiDistanceValueColor = "#D9FFF5"; private const string FogUiDistanceWarningLabelColor = "#FFB864"; private const string FogUiDistanceWarningValueColor = "#FFE6BF"; private const float PeakFogMinStartSize = 650f; private const float PeakFogMaxStartSize = 1400f; private const float PeakVerticalFogStopHeight = 1800f; private const float FogArrivalStopSize = 30f; private const KeyCode HiddenNightTestHotkey = (KeyCode)91; private const float HiddenNightTestHoldSeconds = 5f; private const float FallbackNightTimeNormalized = 0.85f; private const float RemotePlayerJoinGraceSeconds = 8f; private const int MaxCompassGrantsPerPlayerPerSync = 1; private const float CampfireCompassGrantDelaySeconds = 0.9f; private const float FogUiWidth = 1180f; private const float FogUiRightPadding = 18f; private const float FogUiHeight = 34f; private const float FogUiHorizontalPadding = 10f; private const float FogUiIconSize = 20f; private const float FogUiIconVerticalOffset = 0f; private const float FogUiCompactEntrySpacing = 6f; private const float FogUiCompactWidthThreshold = 1040f; private const float FogUiEntryIconTextSpacing = 4f; private const float FogUiEntryWidthQuantum = 4f; private const float FogUiEntryTextSizeMultiplier = 0.9f; private const float FogUiEntryTextTrailingPadding = 2f; private const int FogUiUnitTextSizePercent = 78; private const float CampfireLocatorUiWidth = 420f; private const float CampfireLocatorUiHeight = 52f; private const float CampfireLocatorTopOffset = 54f; private const float CampfireLocatorLineWidth = 400f; private const float CampfireLocatorLineHeight = 2f; private const float CampfireLocatorDotSize = 22f; private const float CampfireLocatorDotSmoothing = 12f; private const float CampfireLocatorTickHeight = 8f; private const float CampfireLocatorTickWidth = 1.5f; private const float CampfireLocatorCenterTickHeight = 12f; private const float CampfireLocatorCenterTickWidth = 2.5f; private const float CampfireLocatorDistanceFontSize = 14f; private const float WeatherIncomingWarningSeconds = 5f; private const float FogUiWeatherGraceSeconds = 0.8f; private const float CompassLobbyNoticeRightOffset = 28f; private const float CompassLobbyNoticeDownOffset = 0f; private const float CompassLobbyNoticeWidth = 735f; private const float CompassLobbyNoticeHeight = 81f; private const float CompassLobbyNoticeFontSizeMultiplier = 1.2f; private const float CompassLobbyNoticeLineSpacing = 1.125f; private const string CompassLobbyNoticeKeyColor = "#FF3B30"; private const string FogUiSpeedLabelColor = "#8EC5FF"; private const string FogUiSpeedValueColor = "#D6F1FF"; private const string FogUiWaitLabelColor = "#F2C75C"; private const string FogUiWaitValueColor = "#FFE8A3"; private const string FogUiCountdownDangerLabelColor = "#FF6B5F"; private const string FogUiCountdownDangerValueColor = "#FFD0C8"; private const string FogUiDelayCountdownStartLabelColor = "#FF9A8A"; private const string FogUiDelayCountdownStartValueColor = "#FFD6D6"; private const string FogUiDelayCountdownEndLabelColor = "#FF5A4D"; private const string FogUiDelayCountdownEndValueColor = "#FFB0A8"; private const string FogUiStateLabelColor = "#A8E0A0"; private const string FogUiStateRunningColor = "#B5FFB8"; private const string FogUiStatePausedColor = "#FFA64D"; private const string FogUiStateWaitingColor = "#FFE08A"; private const string FogUiStateSyncingColor = "#A3D2FF"; private const string FogUiStateArrivedColor = "#7BD4FF"; private const string FogUiStateOffColor = "#FF6B6B"; private const string FogUiStateIdleColor = "#C8C8C8"; private const string FogUiHintLabelColor = "#B7C0CC"; private const string FogUiHintValueColor = "#E2EAF3"; private const string FogUiBiomeLabelColor = "#9FD7A6"; private const string FogUiBiomeValueColor = "#E0F5E2"; private const string FogUiCampfireLabelColor = "#FFB864"; private const string FogUiCampfireValueColor = "#FFE6BF"; private const string FogUiLavaLabelColor = "#FF7A3D"; private const string FogUiLavaValueColor = "#FFD1A6"; private const string FogUiNightEnabledColor = "#9FFFA8"; private const string FogUiNightDisabledColor = "#FFB3B3"; private const string FogUiDayTimeColor = "#FFE38A"; private const string FogUiNightTimeColor = "#AFC6FF"; private const string FogUiTimeBarEmptyColor = "#56606C"; private const string FogUiTimeBarTextColor = "#FFFFFF"; private const float FogUiTimeProgressBarWidth = 128f; private const float FogUiTimeProgressBarHeight = 17f; private const float FogUiEntryMaxWidth = 220f; private static readonly ushort CompassItemIdOverride = 0; private const string CompassNameKeyword = "Compass"; private const string ModConfigPluginGuid = "com.github.PEAKModding.PEAKLib.ModConfig"; private const string LegacyCanonicalConfigSectionName = "Fog"; private const string CanonicalBasicConfigSectionName = "Basic"; private const string CanonicalAdjustmentConfigSectionName = "Adjustments"; private const string ChineseBasicConfigSectionName = "基本"; private const string ChineseAdjustmentConfigSectionName = "调整"; private const string NetworkInstallStateKey = "FogClimb.Enabled"; private const int SimplifiedChineseLanguageIndex = 9; private static readonly BindingFlags InstanceBindingFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; private static readonly BindingFlags StaticBindingFlags = BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic; private static readonly FieldInfo ConfigEntryDescriptionField = typeof(ConfigEntryBase).GetField("<Description>k__BackingField", InstanceBindingFlags); private static readonly PropertyInfo ConfigFileEntriesProperty = typeof(ConfigFile).GetProperty("Entries", InstanceBindingFlags); private static readonly FieldInfo BasePluginConfigBackingField = typeof(BaseUnityPlugin).GetField("<Config>k__BackingField", InstanceBindingFlags); private static readonly FieldInfo OrbFogHandlerOriginsField = typeof(OrbFogHandler).GetField("origins", InstanceBindingFlags); private static readonly FieldInfo OrbFogHandlerSphereField = typeof(OrbFogHandler).GetField("sphere", InstanceBindingFlags); private static readonly FieldInfo CharacterAfflictionsCurrentStatusesField = typeof(CharacterAfflictions).GetField("currentStatuses", InstanceBindingFlags); private static readonly FieldInfo CharacterAfflictionsCurrentIncrementalStatusesField = typeof(CharacterAfflictions).GetField("currentIncrementalStatuses", InstanceBindingFlags); private static readonly FieldInfo CharacterAfflictionsCurrentDecrementalStatusesField = typeof(CharacterAfflictions).GetField("currentDecrementalStatuses", InstanceBindingFlags); private static readonly FieldInfo RunManagerRunStartedField = typeof(RunManager).GetField("runStarted", InstanceBindingFlags); private static readonly FieldInfo RunManagerTimerActiveField = typeof(RunManager).GetField("timerActive", InstanceBindingFlags); private static readonly int StatusTypeCount = Enum.GetNames(typeof(STATUSTYPE)).Length; private static readonly string[] DayNightTimeMemberCandidates = new string[6] { "timeOfDayNormalized", "currentTime", "time", "timeOfDay", "timeNormalized", "cycleTime" }; private static readonly string[] DayNightDayCountMemberCandidates = new string[7] { "dayCount", "dayIndex", "currentDay", "dayNumber", "daysPassed", "totalDays", "day" }; private static readonly ConfigKey[] BasicConfigFileOrder = new ConfigKey[5] { ConfigKey.FogColdSuppression, ConfigKey.NightColdEnabled, ConfigKey.FogSpeed, ConfigKey.FogDelay, ConfigKey.FogPauseHotkey }; private static readonly ConfigKey[] AdjustmentConfigFileOrder = new ConfigKey[23] { ConfigKey.ModEnabled, ConfigKey.FogUiEnabled, ConfigKey.CampfireLocatorUiEnabled, ConfigKey.FogStateUiEnabled, ConfigKey.RunTimerUiEnabled, ConfigKey.DayNightTimeUiEnabled, ConfigKey.AltitudeUiEnabled, ConfigKey.FogSpeedUiEnabled, ConfigKey.CampfireDistanceUiEnabled, ConfigKey.WeatherHazardUiEnabled, ConfigKey.FogTimingUiEnabled, ConfigKey.DirectStartUiEnabled, ConfigKey.FogApproachUiEnabled, ConfigKey.LavaApproachUiEnabled, ConfigKey.NextBiomeUiEnabled, ConfigKey.CompassEnabled, ConfigKey.CompassHotkey, ConfigKey.FogUiX, ConfigKey.FogUiY, ConfigKey.FogUiScale, ConfigKey.FogUiEntrySpacing, ConfigKey.FogUiLayout, ConfigKey.FogUiBackgroundOpacity }; private static readonly Color CampfireLocatorLineColor = new Color(1f, 1f, 1f, 0.95f); private static readonly Color CampfireLocatorDotColor = new Color(1f, 0.2f, 0.2f, 1f); private static int _localFogStatusSourceDepth; private Harmony _harmony; private OrbFogHandler _orbFogHandler; private FogSphere _fogSphere; private Fog _legacyFog; private bool _fogStateInitialized; private bool _initialDelayCompleted; private int _trackedFogOriginId = -1; private float _fogDelayTimer; private float _fogHiddenBufferTimer; private float _fogHandlerSearchTimer; private float _lastFogStateSyncTime = -0.18f; private float _lastRemoteStatusSyncTime = -0.25f; private float _lastCompassGrantSyncTime = -0.75f; private bool _lastHadFogAuthority; private bool _lastModEnabledState; private bool _lastFogUiEnabledState; private bool _lastCampfireLocatorUiEnabledState; private bool _lastDetectedChineseLanguage; private bool _isRefreshingLanguage; private bool _pendingConfigFileLocalizationRefresh; private bool _pendingConfigFileLocalizationSave; private bool _pendingConfigFileOrderRefresh; private float _lastFogUiX; private float _lastFogUiY; private float _lastFogUiScale; private FogUiLayoutKind _lastFogUiLayout; private bool _hasAdvertisedInstallState; private bool _lastAdvertisedInstallState; private string _lastObservedRoomKey = string.Empty; private float _hiddenNightTestHoldTimer; private bool _hiddenNightTestTriggeredThisHold; private bool _fogPaused; private readonly HashSet<int> _grantedCampfireCompassIds = new HashSet<int>(); private readonly HashSet<int> _restoredCheckpointCampfireIds = new HashSet<int>(); private readonly Dictionary<int, int> _playerCompassGrantCounts = new Dictionary<int, int>(); private readonly Dictionary<int, float> _remoteFogSuppressionDebt = new Dictionary<int, float>(); private readonly Dictionary<int, float> _remoteFogSporesSuppressionDebt = new Dictionary<int, float>(); private readonly Dictionary<int, float> _remotePlayerFirstSeenTimes = new Dictionary<int, float>(); private readonly Dictionary<int, int> _remotePlayerCompassBaselineCounts = new Dictionary<int, int>(); private readonly Dictionary<int, float> _pendingCampfireCompassGrantTimes = new Dictionary<int, float>(); private Item _compassItem; private RectTransform _fogUiRect; private TextMeshProUGUI _fogUiText; private string _lastFogUiRenderedText = string.Empty; private bool _fogUiLayoutDirty; private int _lastFogUiEntryLayoutCount = -1; private float _lastFogUiResolvedWidth = -1f; private RectTransform _fogUiEntriesRect; private Image _fogUiBackgroundImage; private Sprite _fogUiBackgroundSprite; private bool _fogUiThemeInitialized; private FogUiThemeKind _fogUiThemeKind; private readonly List<FogUiEntryView> _fogUiEntryViews = new List<FogUiEntryView>(); private readonly List<FogUiDisplayEntry> _fogUiDisplayEntries = new List<FogUiDisplayEntry>(9); private readonly Dictionary<FogUiIconKind, Sprite> _fogUiIconSprites = new Dictionary<FogUiIconKind, Sprite>(); private Sprite _campfireLocatorDotSprite; private Sprite _campfireLocatorLineSprite; private Sprite _nativeCampfireIconSprite; private Sprite _nativePoisonIconSprite; private Sprite _nativeHotIconSprite; private Sprite _nativeDrowsyIconSprite; private Sprite _nativePetrifyIconSprite; private Sprite _nativeAltitudeIconSprite; private float _lastNativeIconAttemptTime = -999f; private StormVisual[] _cachedStormVisuals; private float _lastStormVisualScanTime = -999f; private WindChillZone _weatherUiShownZone; private FogUiIconKind _weatherUiShownKind = FogUiIconKind.Wind; private string _weatherUiShownColorHex = "#A8D8F0"; private float _weatherUiShownRemaining; private bool _weatherUiShownIsWarning; private float _weatherUiGraceUntil = -1f; private float _lastLavaDiagLogTime = -999f; private static readonly bool EnableDebugDiagnostics = false; private static LavaRising _cachedSceneLavaRising; private static Segment _cachedSceneLavaSegment = (Segment)0; private static bool _cachedSceneLavaValid; private static float _cachedSceneLavaScanTime = -999f; private float _pendingWeatherStateBroadcastTime = -1f; private int _weatherStateBroadcastRetryCount; private RectTransform _campfireLocatorUiRect; private RectTransform _campfireLocatorDotRect; private Image _campfireLocatorDotImage; private TextMeshProUGUI _campfireLocatorDistanceText; private float _campfireLocatorCurrentDotX; private RectTransform _compassLobbyNoticeRect; private TextMeshProUGUI _compassLobbyNoticeText; private string _lastCompassLobbyNoticeText = string.Empty; private float _fogUiStateAnimTime; private bool _initialCompassGranted; private int _totalCompassGrantCount; private bool _hasSyncedFogStateSnapshot; private int _lastSyncedFogOriginId = -1; private float _lastSyncedFogSize = float.NaN; private bool _lastSyncedFogIsMoving; private bool _lastSyncedFogHasArrived; private int _delayedFogOriginId = -1; private int _pendingSyntheticFogSegmentId = -1; private int _activeSyntheticFogSegmentId = -1; private Vector3 _syntheticFogPoint; private float _syntheticFogStartSize; private int _fogEtaTrackedOriginId = -1; private float _fogEtaLastObservedSize = float.NaN; private float _fogEtaLastObservedTime = -1f; private float _fogEtaEstimatedUnitsPerSecond; private bool _fogEtaHasReliableRate; private float _fogEtaLastAppliedHandlerSpeed = -1f; private float _fogEtaLastRateResetTime = -999f; private float _lastAdvertisedFogSpeed = -1f; private float _lastFogSpeedAdvertiseTime = -999f; private float _syncedHostFogSpeed = -1f; private float _guestAppliedFogSpeed = -1f; private float _fogDistanceEtaLastRefreshTime = -1f; private bool _fogDistanceEtaHasSnapshot; private bool _fogDistanceEtaHasEta; private float _fogDistanceEtaRemainingDistance; private float _fogDistanceEtaSeconds; private int _guestFogSpeedDisplayOriginId = -1; private float _guestFogSpeedDisplayValue; private float _guestFogSpeedStableCandidate; private float _guestFogSpeedStableSince = -1f; private bool _guestFogSpeedHasDisplay; private float _guestFogSpeedLastUpdateTime = -1f; private float _lastGuestFogDiagLogTime = -999f; private float _lastHostFogSyncDiagLogTime = -999f; private float _lastInstallAdvertiseDiagLogTime = -999f; private bool _windChillFieldDiagLogged; private static FieldInfo _stormVisualZoneField; private static FieldInfo _windChillDirectionField; private static FieldInfo _windChillUntilSwitchField; internal static ConfigEntry<bool> CompassEnabled { get; private set; } internal static ConfigEntry<KeyCode> CompassHotkey { get; private set; } internal static ConfigEntry<bool> ModEnabled { get; private set; } internal static ConfigEntry<bool> FogColdSuppression { get; private set; } internal static ConfigEntry<bool> NightColdEnabled { get; private set; } internal static ConfigEntry<float> FogSpeed { get; private set; } internal static ConfigEntry<float> FogDelay { get; private set; } internal static ConfigEntry<KeyCode> FogPauseHotkey { get; private set; } internal static ConfigEntry<bool> FogUiEnabled { get; private set; } internal static ConfigEntry<bool> CampfireLocatorUiEnabled { get; private set; } internal static ConfigEntry<float> FogUiX { get; private set; } internal static ConfigEntry<float> FogUiY { get; private set; } internal static ConfigEntry<float> FogUiScale { get; private set; } internal static ConfigEntry<float> FogUiEntrySpacing { get; private set; } internal static ConfigEntry<FogUiLayoutKind> FogUiLayout { get; private set; } internal static ConfigEntry<float> FogUiBackgroundOpacity { get; private set; } internal static ConfigEntry<bool> FogStateUiEnabled { get; private set; } internal static ConfigEntry<bool> RunTimerUiEnabled { get; private set; } internal static ConfigEntry<bool> DayNightTimeUiEnabled { get; private set; } internal static ConfigEntry<bool> AltitudeUiEnabled { get; private set; } internal static ConfigEntry<bool> FogSpeedUiEnabled { get; private set; } internal static ConfigEntry<bool> CampfireDistanceUiEnabled { get; private set; } internal static ConfigEntry<bool> WeatherHazardUiEnabled { get; private set; } internal static ConfigEntry<bool> FogTimingUiEnabled { get; private set; } internal static ConfigEntry<bool> DirectStartUiEnabled { get; private set; } internal static ConfigEntry<bool> FogApproachUiEnabled { get; private set; } internal static ConfigEntry<bool> LavaApproachUiEnabled { get; private set; } internal static ConfigEntry<bool> NextBiomeUiEnabled { get; private set; } internal static Plugin Instance { get; private set; } private void TryGrantInitialCompassIfNeeded() { if (!_initialCompassGranted && !((Object)(object)_orbFogHandler == (Object)null) && _orbFogHandler.currentID == 0 && _initialDelayCompleted && _orbFogHandler.isMoving && !HasRemotePlayersInJoinGracePeriod()) { _initialCompassGranted = true; GrantCompassToAllPlayers("initial-delay-ended"); } } private bool TryResolveCompassItem() { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown //IL_007e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_compassItem != (Object)null) { return true; } if (TryResolveCompassItemOverride(out var item)) { _compassItem = item; return true; } ItemDatabase instance = SingletonAsset<ItemDatabase>.Instance; if ((Object)instance == (Object)null || ((DatabaseAsset<ItemDatabase, Item>)(object)instance).Objects == null) { return false; } List<string> list = new List<string>(); foreach (Item @object in ((DatabaseAsset<ItemDatabase, Item>)(object)instance).Objects) { if ((Object)(object)@object == (Object)null) { continue; } CompassPointer componentInChildren = ((Component)@object).GetComponentInChildren<CompassPointer>(true); if (!((Object)(object)componentInChildren == (Object)null) && (int)componentInChildren.compassType == 0) { list.Add(DescribeCompassItem(@object)); if (LooksLikeStandardCompassItem(@object)) { _compassItem = @object; ((BaseUnityPlugin)this).Logger.LogInfo((object)("[Fog&ColdControl] Using normal compass item: " + DescribeCompassItem(@object))); return true; } } } if (list.Count > 0) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("[Fog&ColdControl] Failed to identify the standard compass automatically. Set CompassItemIdOverride manually. Candidates: " + string.Join(", ", list))); } return false; } private bool TryResolveCompassItemOverride(out Item item) { item = null; if (CompassItemIdOverride <= 0) { return false; } Item val = default(Item); if (!ItemDatabase.TryGetItem(CompassItemIdOverride, ref val) || (Object)(object)val == (Object)null) { ((BaseUnityPlugin)this).Logger.LogWarning((object)string.Format("[{0}] CompassItemIdOverride={1} is invalid.", "Fog&ColdControl", CompassItemIdOverride)); return false; } item = val; ((BaseUnityPlugin)this).Logger.LogInfo((object)("[Fog&ColdControl] Using compass item override: " + DescribeCompassItem(item))); return true; } private static bool LooksLikeStandardCompassItem(Item item) { if ((Object)(object)item == (Object)null) { return false; } string obj = ((Object)item).name ?? string.Empty; string text = item.UIData?.itemName ?? string.Empty; if (obj.IndexOf("Compass", StringComparison.OrdinalIgnoreCase) < 0) { return text.IndexOf("Compass", StringComparison.OrdinalIgnoreCase) >= 0; } return true; } private static string DescribeCompassItem(Item item) { if ((Object)(object)item == (Object)null) { return "<null>"; } string arg = item.UIData?.itemName ?? string.Empty; return $"{((Object)item).name} (itemID={item.itemID}, uiName={arg})"; } private void GrantCompassToAllPlayers(string reason) { if (IsModFeatureEnabled() && HasFogAuthority() && IsCompassFeatureEnabled()) { _totalCompassGrantCount++; ((BaseUnityPlugin)this).Logger.LogDebug((object)string.Format("[{0}] Queued compass grant #{1} ({2}).", "Fog&ColdControl", _totalCompassGrantCount, reason)); SyncCompassGrantsToPlayers(force: true, reason); } } private void SyncCompassGrantsToPlayersIfNeeded() { if (IsModFeatureEnabled() && HasFogAuthority() && IsCompassFeatureEnabled() && _totalCompassGrantCount > 0 && !(Time.unscaledTime - _lastCompassGrantSyncTime < 0.75f)) { SyncCompassGrantsToPlayers(force: false, "periodic-sync"); } } private void SyncCompassGrantsToPlayers(bool force, string reason) { if (!IsModFeatureEnabled() || !HasFogAuthority() || !IsCompassFeatureEnabled() || _totalCompassGrantCount <= 0) { return; } if (!TryResolveCompassItem()) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("[Fog&ColdControl] Failed to resolve compass item while syncing grants (" + reason + ").")); return; } _lastCompassGrantSyncTime = Time.unscaledTime; HashSet<int> activePlayerKeys = new HashSet<int>(); Dictionary<int, Player> dictionary = new Dictionary<int, Player>(); foreach (Player item in EnumerateTargetPlayers()) { if (!IsPlayerPastJoinGrace(item)) { continue; } int playerCompassGrantKey = GetPlayerCompassGrantKey(item); activePlayerKeys.Add(playerCompassGrantKey); PhotonView component = ((Component)item).GetComponent<PhotonView>(); int? obj; if (component == null) { obj = null; } else { Player owner = component.Owner; obj = ((owner != null) ? new int?(owner.ActorNumber) : ((int?)null)); } int num = obj ?? (-1); if (num > 0 && !dictionary.ContainsKey(num)) { dictionary[num] = item; } int num2 = GetDeliveredCompassGrantCount(item); int num3 = 0; while (num2 < _totalCompassGrantCount && GrantCompassToPlayer(item, $"{reason}-{num2 + 1}/{_totalCompassGrantCount}")) { num2++; num3++; if (num3 >= 1) { break; } } _playerCompassGrantCounts[playerCompassGrantKey] = num2; } TrySyncCompassGrantsToMissingActorPlayers(reason, activePlayerKeys, dictionary); int[] array = _playerCompassGrantCounts.Keys.Where((int item) => !activePlayerKeys.Contains(item)).ToArray(); foreach (int key in array) { _playerCompassGrantCounts.Remove(key); } } private void TrySyncCompassGrantsToMissingActorPlayers(string reason, HashSet<int> activePlayerKeys, Dictionary<int, Player> playersByActorNumber) { if (!PhotonNetwork.InRoom || PhotonNetwork.CurrentRoom == null) { return; } Player localPlayer = PhotonNetwork.LocalPlayer; int num = ((localPlayer != null) ? localPlayer.ActorNumber : (-1)); foreach (Player item in PhotonNetwork.CurrentRoom.Players.Values.OrderBy((Player player) => (player == null) ? int.MaxValue : player.ActorNumber)) { int num2 = ((item != null) ? item.ActorNumber : (-1)); if (num2 <= 0 || num2 == num || playersByActorNumber.ContainsKey(num2)) { continue; } activePlayerKeys.Add(num2); if (!IsActorPastJoinGrace(num2)) { continue; } int num3 = GetDeliveredCompassGrantCountForActor(num2); int num4 = 0; while (num3 < _totalCompassGrantCount && GrantCompassToActor(num2, $"{reason}-{num3 + 1}/{_totalCompassGrantCount}")) { num3++; num4++; if (num4 >= 1) { break; } } _playerCompassGrantCounts[num2] = num3; } } private static int GetPlayerCompassGrantKey(Player player) { if ((Object)(object)player == (Object)null) { return 0; } PhotonView component = ((Component)player).GetComponent<PhotonView>(); if (((component != null) ? component.Owner : null) != null) { return component.Owner.ActorNumber; } return ((Object)player).GetInstanceID(); } private int GetDeliveredCompassGrantCount(Player player) { int playerCompassGrantKey = GetPlayerCompassGrantKey(player); if (_playerCompassGrantCounts.TryGetValue(playerCompassGrantKey, out var value)) { return value; } PhotonView val = (((Object)(object)player != (Object)null) ? ((Component)player).GetComponent<PhotonView>() : null); if (((val != null) ? val.Owner : null) != null && _remotePlayerCompassBaselineCounts.TryGetValue(val.Owner.ActorNumber, out var value2)) { return value2; } return 0; } private int GetDeliveredCompassGrantCountForActor(int actorNumber) { if (_playerCompassGrantCounts.TryGetValue(actorNumber, out var value)) { return value; } if (_remotePlayerCompassBaselineCounts.TryGetValue(actorNumber, out var value2)) { return value2; } return 0; } private void ProcessPendingCampfireCompassGrants() { if (IsModFeatureEnabled() && HasFogAuthority() && IsCompassFeatureEnabled() && _pendingCampfireCompassGrantTimes.Count > 0 && !LoadingScreenHandler.loading) { float now = Time.unscaledTime; int[] array = _pendingCampfireCompassGrantTimes.Where(delegate(KeyValuePair<int, float> entry) { float num3 = now; KeyValuePair<int, float> keyValuePair = entry; return num3 >= keyValuePair.Value; }).Select(delegate(KeyValuePair<int, float> entry) { KeyValuePair<int, float> keyValuePair = entry; return keyValuePair.Key; }).ToArray(); foreach (int num2 in array) { _pendingCampfireCompassGrantTimes.Remove(num2); ((BaseUnityPlugin)this).Logger.LogInfo((object)string.Format("[{0}] Delivering delayed campfire compass grant for campfire #{1}.", "Fog&ColdControl", num2)); GrantCompassToAllPlayers($"campfire-{num2}"); } } } private bool GrantCompassToPlayer(Player player, string reason) { if ((Object)(object)player == (Object)null || (Object)(object)_compassItem == (Object)null || !IsPlayerPastJoinGrace(player)) { return false; } PhotonView component = ((Component)player).GetComponent<PhotonView>(); int? obj; if (component == null) { obj = null; } else { Player owner = component.Owner; obj = ((owner != null) ? new int?(owner.ActorNumber) : ((int?)null)); } int actorNumber = obj ?? (-1); if (((component != null) ? component.Owner : null) != null && !component.IsMine) { Character val = player.character; if ((Object)(object)val == (Object)null || (Object)(object)val.data == (Object)null || val.data.dead) { val = ((IEnumerable<Character>)Character.AllCharacters).FirstOrDefault((Func<Character, bool>)((Character character) => (Object)(object)character != (Object)null && (Object)(object)((MonoBehaviourPun)character).photonView != (Object)null && ((MonoBehaviourPun)character).photonView.Owner != null && ((MonoBehaviourPun)character).photonView.Owner.ActorNumber == actorNumber && !character.isBot && !character.isZombie && (Object)(object)character.data != (Object)null && !character.data.dead)); } if ((Object)(object)val != (Object)null) { return DropCompassInFrontOfCharacter(val, actorNumber, reason); } } return DropCompassInFrontOfPlayer(player, reason, preferLocalViewAnchor: true); } private bool GrantCompassToActor(int actorNumber, string reason) { if (actorNumber <= 0 || (Object)(object)_compassItem == (Object)null || !IsActorPastJoinGrace(actorNumber)) { return false; } Player val = EnumerateTargetPlayers().FirstOrDefault((Func<Player, bool>)delegate(Player player) { PhotonView val3 = (((Object)(object)player != (Object)null) ? ((Component)player).GetComponent<PhotonView>() : null); if (val3 != null) { Player owner = val3.Owner; if (owner == null) { return false; } return owner.ActorNumber == actorNumber; } return false; }); if ((Object)(object)val != (Object)null) { return GrantCompassToPlayer(val, reason); } Character val2 = ((IEnumerable<Character>)Character.AllCharacters).FirstOrDefault((Func<Character, bool>)((Character character) => (Object)(object)character != (Object)null && (Object)(object)((MonoBehaviourPun)character).photonView != (Object)null && ((MonoBehaviourPun)character).photonView.Owner != null && ((MonoBehaviourPun)character).photonView.Owner.ActorNumber == actorNumber && !character.isBot && !character.isZombie && (Object)(object)character.data != (Object)null && !character.data.dead)); if ((Object)(object)val2 == (Object)null) { return false; } return DropCompassInFrontOfCharacter(val2, actorNumber, reason); } private bool DropCompassInFrontOfPlayer(Player player, string reason) { return DropCompassInFrontOfPlayer(player, reason, preferLocalViewAnchor: false); } private bool DropCompassInFrontOfPlayer(Player player, string reason, bool preferLocalViewAnchor) { //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)player == (Object)null || (Object)(object)_compassItem == (Object)null) { return false; } ResolveCompassSpawnPose(player, preferLocalViewAnchor, out var spawnPosition, out var spawnRotation); try { if (PhotonNetwork.InRoom) { PhotonNetwork.InstantiateItemRoom(((Object)_compassItem).name, spawnPosition, spawnRotation); } else { Object.Instantiate<GameObject>(((Component)_compassItem).gameObject, spawnPosition, spawnRotation); } ((BaseUnityPlugin)this).Logger.LogDebug((object)("[Fog&ColdControl] Spawned compass in front of " + ((Object)player).name + " (" + reason + ").")); return true; } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("[Fog&ColdControl] Failed to spawn compass in front of " + ((Object)player).name + " (" + reason + "): " + ex.Message)); return false; } } private bool DropCompassInFrontOfCharacter(Character character, int actorNumber, string reason) { //IL_004a: 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_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)character == (Object)null || (Object)(object)_compassItem == (Object)null) { return false; } ResolveCompassSpawnPose(character, out var spawnPosition, out var spawnRotation); try { if (PhotonNetwork.InRoom) { PhotonNetwork.InstantiateItemRoom(((Object)_compassItem).name, spawnPosition, spawnRotation); } else { Object.Instantiate<GameObject>(((Component)_compassItem).gameObject, spawnPosition, spawnRotation); } ((BaseUnityPlugin)this).Logger.LogDebug((object)string.Format("[{0}] Spawned compass near actor #{1} ({2}).", "Fog&ColdControl", actorNumber, reason)); return true; } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)string.Format("[{0}] Failed to spawn compass near actor #{1} ({2}): {3}", "Fog&ColdControl", actorNumber, reason, ex.Message)); return false; } } private static Vector3 GetCompassDropPosition(Player player) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) ResolveCompassSpawnPose(player, out var spawnPosition, out var _); return spawnPosition; } private static Quaternion GetCompassDropRotation(Player player) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) ResolveCompassSpawnPose(player, out var _, out var spawnRotation); return spawnRotation; } private static void ResolveCompassSpawnPose(Player player, out Vector3 spawnPosition, out Quaternion spawnRotation) { ResolveCompassSpawnPose(player, preferLocalViewAnchor: false, out spawnPosition, out spawnRotation); } private static void ResolveCompassSpawnPose(Player player, bool preferLocalViewAnchor, out Vector3 spawnPosition, out Quaternion spawnRotation) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) if (!preferLocalViewAnchor || !TryResolveLocalViewCompassSpawnPose(player, out spawnPosition, out spawnRotation)) { Vector3 val = ResolveCompassFaceAnchorPosition(player); Vector3 val2 = ResolveCompassFacingForward(player); if (((Vector3)(ref val2)).sqrMagnitude < 0.01f) { val2 = Vector3.forward; } val2 = ((Vector3)(ref val2)).normalized; Vector3 val3 = Vector3.ProjectOnPlane(val2, Vector3.up); if (((Vector3)(ref val3)).sqrMagnitude < 0.01f) { val3 = Vector3.ProjectOnPlane(((Component)player).transform.forward, Vector3.up); } if (((Vector3)(ref val3)).sqrMagnitude < 0.01f) { val3 = Vector3.forward; } val3 = ((Vector3)(ref val3)).normalized; spawnPosition = val + val2 * 0.85f; spawnRotation = Quaternion.LookRotation(val3, Vector3.up); } } private static void ResolveCompassSpawnPose(Character character, out Vector3 spawnPosition, out Quaternion spawnRotation) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006c: 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_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_005d: 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) Vector3 val = character.Center + Vector3.up * 0.5f; Vector3 val2 = ((Component)character).transform.forward; if (((Vector3)(ref val2)).sqrMagnitude < 0.01f) { val2 = Vector3.forward; } val2 = ((Vector3)(ref val2)).normalized; Vector3 val3 = Vector3.ProjectOnPlane(val2, Vector3.up); if (((Vector3)(ref val3)).sqrMagnitude < 0.01f) { val3 = Vector3.forward; } val3 = ((Vector3)(ref val3)).normalized; spawnPosition = val + val2 * 0.85f; spawnRotation = Quaternion.LookRotation(val3, Vector3.up); } private static bool TryResolveLocalViewCompassSpawnPose(Player player, out Vector3 spawnPosition, out Quaternion spawnRotation) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0136: 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_0102: Unknown result type (might be due to invalid IL or missing references) spawnPosition = default(Vector3); spawnRotation = Quaternion.identity; object obj = Player.localPlayer; if (obj == null) { Character localCharacter = Character.localCharacter; obj = ((localCharacter != null) ? localCharacter.player : null); } Player val = (Player)obj; if ((Object)(object)player == (Object)null || (Object)(object)val == (Object)null || (Object)(object)player != (Object)(object)val) { return false; } Camera val2 = Camera.main; if ((Object)(object)val2 == (Object)null || !((Behaviour)val2).isActiveAndEnabled) { val2 = ((IEnumerable<Camera>)Object.FindObjectsByType<Camera>((FindObjectsSortMode)0)).FirstOrDefault((Func<Camera, bool>)((Camera candidate) => (Object)(object)candidate != (Object)null && ((Behaviour)candidate).isActiveAndEnabled && ((Component)candidate).gameObject.activeInHierarchy)); } if ((Object)(object)val2 == (Object)null) { return false; } Transform transform = ((Component)val2).transform; Vector3 val3 = transform.forward; if (((Vector3)(ref val3)).sqrMagnitude < 0.01f) { return false; } val3 = ((Vector3)(ref val3)).normalized; Vector3 val4 = Vector3.ProjectOnPlane(val3, Vector3.up); if (((Vector3)(ref val4)).sqrMagnitude < 0.01f) { val4 = Vector3.ProjectOnPlane(((Component)player).transform.forward, Vector3.up); } if (((Vector3)(ref val4)).sqrMagnitude < 0.01f) { val4 = Vector3.forward; } val4 = ((Vector3)(ref val4)).normalized; spawnPosition = transform.position + val3 * 0.9f; spawnRotation = Quaternion.LookRotation(val4, Vector3.up); return true; } private static Vector3 ResolveCompassFaceAnchorPosition(Player player) { //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) if (TryGetCompassFaceAnchor(player, out var anchor)) { Vector3 val = ((((Object)anchor).name.IndexOf("camera", StringComparison.OrdinalIgnoreCase) >= 0) ? (Vector3.down * 0.03f) : Vector3.zero); return anchor.position + val; } Character character = player.character; if ((Object)(object)character != (Object)null) { Vector3 center = character.Center; return new Vector3(center.x, center.y + 0.5f, center.z); } return ((Component)player).transform.position + Vector3.up * 1.45f; } private static Vector3 ResolveCompassFacingForward(Player player) { //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: 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_0018: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) if (TryGetCompassFaceAnchor(player, out var anchor) && ShouldUseCompassAnchorForward(anchor)) { Vector3 forward = anchor.forward; if (((Vector3)(ref forward)).sqrMagnitude >= 0.01f) { return forward; } } Character character = player.character; Vector3 forward2; if ((Object)(object)character != (Object)null) { forward2 = ((Component)character).transform.forward; if (((Vector3)(ref forward2)).sqrMagnitude >= 0.01f) { return ((Component)character).transform.forward; } } forward2 = ((Component)player).transform.forward; if (((Vector3)(ref forward2)).sqrMagnitude >= 0.01f) { return ((Component)player).transform.forward; } if (TryGetCompassFaceAnchor(player, out anchor)) { forward2 = anchor.forward; if (((Vector3)(ref forward2)).sqrMagnitude >= 0.01f) { return anchor.forward; } } return Vector3.forward; } private static bool TryGetCompassFaceAnchor(Player player, out Transform anchor) { //IL_00ac: Unknown result type (might be due to invalid IL or missing references) anchor = null; if ((Object)(object)player == (Object)null) { return false; } Transform[] obj = (((Object)(object)player.character != (Object)null && (Object)(object)((Component)player.character).transform != (Object)(object)((Component)player).transform) ? new Transform[2] { ((Component)player.character).transform, ((Component)player).transform } : new Transform[1] { ((Component)player).transform }); int num = int.MaxValue; float num2 = float.MinValue; Transform[] array = (Transform[])(object)obj; foreach (Transform val in array) { if ((Object)(object)val == (Object)null) { continue; } Transform[] componentsInChildren = ((Component)val).GetComponentsInChildren<Transform>(true); foreach (Transform val2 in componentsInChildren) { int compassFaceAnchorScore = GetCompassFaceAnchorScore(val2); if (compassFaceAnchorScore != int.MaxValue) { float y = val2.position.y; if (compassFaceAnchorScore < num || (compassFaceAnchorScore == num && y > num2)) { num = compassFaceAnchorScore; num2 = y; anchor = val2; } } } } return (Object)(object)anchor != (Object)null; } private static int GetCompassFaceAnchorScore(Transform candidate) { if ((Object)(object)candidate == (Object)null) { return int.MaxValue; } string text = ((Object)candidate).name ?? string.Empty; if (text.Equals("MainCamera", StringComparison.OrdinalIgnoreCase)) { return 0; } if (text.IndexOf("maincamera", StringComparison.OrdinalIgnoreCase) >= 0) { return 1; } if (text.IndexOf("camera", StringComparison.OrdinalIgnoreCase) >= 0) { return 2; } if (text.IndexOf("head", StringComparison.OrdinalIgnoreCase) >= 0) { return 3; } if (text.IndexOf("face", StringComparison.OrdinalIgnoreCase) >= 0) { return 4; } if (text.IndexOf("look", StringComparison.OrdinalIgnoreCase) >= 0) { return 5; } if (text.IndexOf("jaw", StringComparison.OrdinalIgnoreCase) >= 0) { return 6; } return int.MaxValue; } private static bool ShouldUseCompassAnchorForward(Transform anchor) { if ((Object)(object)anchor == (Object)null) { return false; } string text = ((Object)anchor).name ?? string.Empty; if (text.IndexOf("camera", StringComparison.OrdinalIgnoreCase) < 0) { return text.IndexOf("look", StringComparison.OrdinalIgnoreCase) >= 0; } return true; } private void HandleManualCompassHotkey() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) if (!IsModFeatureEnabled() || !HasFogAuthority() || !IsCompassFeatureEnabled()) { return; } KeyCode compassHotkey = GetCompassHotkey(); if ((int)compassHotkey != 0) { GUIManager instance = GUIManager.instance; if ((!((Object)(object)instance != (Object)null) || !instance.windowBlockingInput) && Input.GetKeyDown(compassHotkey)) { TrySpawnManualCompassForLocalPlayer(); } } } private void TrySpawnManualCompassForLocalPlayer() { if (IsCompassFeatureEnabled()) { Player localPlayer; if (!TryResolveCompassItem()) { ((BaseUnityPlugin)this).Logger.LogWarning((object)"[Fog&ColdControl] Failed to resolve compass item for manual hotkey spawn."); } else if (TryGetLocalPlayablePlayer(out localPlayer) && !DropCompassInFrontOfPlayer(localPlayer, "manual-hotkey", preferLocalViewAnchor: true)) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("[Fog&ColdControl] Manual compass hotkey spawn failed for " + ((Object)localPlayer).name + ".")); } } } private static KeyCode GetCompassHotkey() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) return (KeyCode)(((??)CompassHotkey?.Value) ?? 103); } private unsafe static string GetCompassHotkeyLabel() { //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_001c: Unknown result type (might be due to invalid IL or missing references) KeyCode compassHotkey = GetCompassHotkey(); string text = ((object)(*(KeyCode*)(&compassHotkey))/*cast due to .constrained prefix*/).ToString(); if (string.IsNullOrWhiteSpace(text) || (int)compassHotkey == 0) { return "G"; } return text.ToUpperInvariant(); } private string GetCompassLobbyNoticeText(bool isChineseLanguage) { string text = "<color=#FF3B30>" + GetCompassHotkeyLabel() + "</color>"; if (!isChineseLanguage) { return "Press " + text + " to spawn compass"; } return "按 " + text + " 生成指南针"; } private bool ShouldShowCompassLobbyNotice() { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) if (IsModFeatureEnabled() && HasFogAuthority() && IsCompassFeatureEnabled() && (int)GetCompassHotkey() != 0) { return IsAirportScene(SceneManager.GetActiveScene()); } return false; } private string GetCompassLobbyNoticeTextSafe(bool isChineseLanguage) { string text = "<color=#FF3B30>" + GetCompassHotkeyLabel() + "</color>"; if (!isChineseLanguage) { return "Press " + text + " to spawn compass"; } return "按 " + text + " 生成指南针"; } private void UpdateCompassLobbyNotice() { if (!ShouldShowCompassLobbyNotice()) { CleanupCompassLobbyNotice(); return; } Canvas val = ResolveHudCanvas(); if (!IsCanvasUsable(val)) { CleanupCompassLobbyNotice(); return; } if ((Object)(object)_compassLobbyNoticeRect == (Object)null || (Object)(object)_compassLobbyNoticeText == (Object)null || (Object)(object)((Transform)_compassLobbyNoticeRect).parent != (Object)(object)((Component)val).transform) { CreateCompassLobbyNotice(val); if ((Object)(object)_compassLobbyNoticeRect == (Object)null || (Object)(object)_compassLobbyNoticeText == (Object)null) { return; } } string compassLobbyNoticeTextSafe = GetCompassLobbyNoticeTextSafe(DetectChineseLanguage()); if (!string.Equals(_lastCompassLobbyNoticeText, compassLobbyNoticeTextSafe, StringComparison.Ordinal)) { _lastCompassLobbyNoticeText = compassLobbyNoticeTextSafe; ((TMP_Text)_compassLobbyNoticeText).text = compassLobbyNoticeTextSafe; } ClampCompassLobbyNoticeToCanvas(val); ((Component)_compassLobbyNoticeRect).gameObject.SetActive(true); } private void CreateCompassLobbyNotice(Canvas targetCanvas = null) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown //IL_0074: Unknown result type (might be due to invalid IL or missing references) CleanupCompassLobbyNotice(); Canvas val = targetCanvas ?? ResolveHudCanvas(); if (IsCanvasUsable(val)) { GameObject val2 = new GameObject("FogClimbCompassLobbyNotice", new Type[1] { typeof(RectTransform) }); _compassLobbyNoticeRect = val2.GetComponent<RectTransform>(); ((Transform)_compassLobbyNoticeRect).SetParent(((Component)val).transform, false); ((Transform)_compassLobbyNoticeRect).SetAsLastSibling(); _compassLobbyNoticeRect.sizeDelta = new Vector2(735f, 81f); _compassLobbyNoticeText = val2.AddComponent<TextMeshProUGUI>(); ApplyCompassLobbyNoticeStyle(_compassLobbyNoticeText); _lastCompassLobbyNoticeText = GetCompassLobbyNoticeTextSafe(DetectChineseLanguage()); ((TMP_Text)_compassLobbyNoticeText).text = _lastCompassLobbyNoticeText; ClampCompassLobbyNoticeToCanvas(val); } } private void ApplyCompassLobbyNoticeStyle(TextMeshProUGUI target) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)target == (Object)null)) { ApplyGameTextStyle(target, new Color(1f, 0.94f, 0.72f), 1.2f); ((TMP_Text)target).fontStyle = (FontStyles)0; ((TMP_Text)target).alignment = (TextAlignmentOptions)4100; ((TMP_Text)target).textWrappingMode = (TextWrappingModes)0; ((TMP_Text)target).overflowMode = (TextOverflowModes)0; ((TMP_Text)target).lineSpacing = 1.125f; } } private void ClampCompassLobbyNoticeToCanvas(Canvas targetCanvas = null) { if ((Object)(object)_compassLobbyNoticeRect == (Object)null) { return; } Canvas val = targetCanvas ?? ResolveHudCanvas() ?? ((Component)_compassLobbyNoticeRect).GetComponentInParent<Canvas>(); if (IsCanvasUsable(val)) { if ((Object)(object)((Transform)_compassLobbyNoticeRect).parent != (Object)(object)((Component)val).transform) { ((Transform)_compassLobbyNoticeRect).SetParent(((Component)val).transform, false); } ApplyRightMiddleAnchoredRect(_compassLobbyNoticeRect, 735f, 81f, 28f, 0f); } } private void CleanupCompassLobbyNotice() { if ((Object)(object)_compassLobbyNoticeRect != (Object)null) { Object.Destroy((Object)(object)((Component)_compassLobbyNoticeRect).gameObject); } _compassLobbyNoticeRect = null; _compassLobbyNoticeText = null; _lastCompassLobbyNoticeText = string.Empty; } private static string GetLobbyCompassHintLabel(bool isChineseLanguage) { if (!IsCompassFeatureEnabled()) { return string.Empty; } string text = (isChineseLanguage ? "指南针:" : "Compass:"); return string.Concat(str2: Colorize(isChineseLanguage ? ("按 " + GetCompassHotkeyLabel() + " 生成") : ("Press " + GetCompassHotkeyLabel() + " to spawn"), "#E2EAF3"), str0: Colorize(text, "#B7C0CC"), str1: " "); } internal static bool IsCompassFeatureEnabled() { if (CompassEnabled != null) { return CompassEnabled.Value; } return true; } private void InitializeConfig(bool isChineseLanguage) { FogColdSuppression = ((BaseUnityPlugin)this).Config.Bind<bool>(GetConfigSectionName(ConfigKey.FogColdSuppression), GetConfigKeyName(ConfigKey.FogColdSuppression), false, CreateConfigDescription(ConfigKey.FogColdSuppression, isChineseLanguage)); NightColdEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>(GetConfigSectionName(ConfigKey.NightColdEnabled), GetConfigKeyName(ConfigKey.NightColdEnabled), true, CreateConfigDescription(ConfigKey.NightColdEnabled, isChineseLanguage)); FogSpeed = ((BaseUnityPlugin)this).Config.Bind<float>(GetConfigSectionName(ConfigKey.FogSpeed), GetConfigKeyName(ConfigKey.FogSpeed), 0.4f, CreateConfigDescription(ConfigKey.FogSpeed, isChineseLanguage)); FogDelay = ((BaseUnityPlugin)this).Config.Bind<float>(GetConfigSectionName(ConfigKey.FogDelay), GetConfigKeyName(ConfigKey.FogDelay), 900f, CreateConfigDescription(ConfigKey.FogDelay, isChineseLanguage)); FogPauseHotkey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>(GetConfigSectionName(ConfigKey.FogPauseHotkey), GetConfigKeyName(ConfigKey.FogPauseHotkey), (KeyCode)121, CreateConfigDescription(ConfigKey.FogPauseHotkey, isChineseLanguage)); ModEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>(GetConfigSectionName(ConfigKey.ModEnabled), GetConfigKeyName(ConfigKey.ModEnabled), true, CreateConfigDescription(ConfigKey.ModEnabled, isChineseLanguage)); FogUiEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>(GetConfigSectionName(ConfigKey.FogUiEnabled), GetConfigKeyName(ConfigKey.FogUiEnabled), true, CreateConfigDescription(ConfigKey.FogUiEnabled, isChineseLanguage)); CampfireLocatorUiEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>(GetConfigSectionName(ConfigKey.CampfireLocatorUiEnabled), GetConfigKeyName(ConfigKey.CampfireLocatorUiEnabled), true, CreateConfigDescription(ConfigKey.CampfireLocatorUiEnabled, isChineseLanguage)); CompassEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>(GetConfigSectionName(ConfigKey.CompassEnabled), GetConfigKeyName(ConfigKey.CompassEnabled), false, CreateConfigDescription(ConfigKey.CompassEnabled, isChineseLanguage)); CompassHotkey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>(GetConfigSectionName(ConfigKey.CompassHotkey), GetConfigKeyName(ConfigKey.CompassHotkey), (KeyCode)103, CreateConfigDescription(ConfigKey.CompassHotkey, isChineseLanguage)); FogUiX = ((BaseUnityPlugin)this).Config.Bind<float>(GetConfigSectionName(ConfigKey.FogUiX), GetConfigKeyName(ConfigKey.FogUiX), 60f, CreateConfigDescription(ConfigKey.FogUiX, isChineseLanguage)); FogUiY = ((BaseUnityPlugin)this).Config.Bind<float>(GetConfigSectionName(ConfigKey.FogUiY), GetConfigKeyName(ConfigKey.FogUiY), 0f, CreateConfigDescription(ConfigKey.FogUiY, isChineseLanguage)); FogUiScale = ((BaseUnityPlugin)this).Config.Bind<float>(GetConfigSectionName(ConfigKey.FogUiScale), GetConfigKeyName(ConfigKey.FogUiScale), 0.9f, CreateConfigDescription(ConfigKey.FogUiScale, isChineseLanguage)); FogUiEntrySpacing = ((BaseUnityPlugin)this).Config.Bind<float>(GetConfigSectionName(ConfigKey.FogUiEntrySpacing), GetConfigKeyName(ConfigKey.FogUiEntrySpacing), 8f, CreateConfigDescription(ConfigKey.FogUiEntrySpacing, isChineseLanguage)); FogUiLayout = ((BaseUnityPlugin)this).Config.Bind<FogUiLayoutKind>(GetConfigSectionName(ConfigKey.FogUiLayout), GetConfigKeyName(ConfigKey.FogUiLayout), FogUiLayoutKind.Horizontal, CreateConfigDescription(ConfigKey.FogUiLayout, isChineseLanguage)); FogUiBackgroundOpacity = ((BaseUnityPlugin)this).Config.Bind<float>(GetConfigSectionName(ConfigKey.FogUiBackgroundOpacity), GetConfigKeyName(ConfigKey.FogUiBackgroundOpacity), 0f, CreateConfigDescription(ConfigKey.FogUiBackgroundOpacity, isChineseLanguage)); FogStateUiEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>(GetConfigSectionName(ConfigKey.FogStateUiEnabled), GetConfigKeyName(ConfigKey.FogStateUiEnabled), true, CreateConfigDescription(ConfigKey.FogStateUiEnabled, isChineseLanguage)); RunTimerUiEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>(GetConfigSectionName(ConfigKey.RunTimerUiEnabled), GetConfigKeyName(ConfigKey.RunTimerUiEnabled), true, CreateConfigDescription(ConfigKey.RunTimerUiEnabled, isChineseLanguage)); DayNightTimeUiEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>(GetConfigSectionName(ConfigKey.DayNightTimeUiEnabled), GetConfigKeyName(ConfigKey.DayNightTimeUiEnabled), true, CreateConfigDescription(ConfigKey.DayNightTimeUiEnabled, isChineseLanguage)); AltitudeUiEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>(GetConfigSectionName(ConfigKey.AltitudeUiEnabled), GetConfigKeyName(ConfigKey.AltitudeUiEnabled), true, CreateConfigDescription(ConfigKey.AltitudeUiEnabled, isChineseLanguage)); FogSpeedUiEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>(GetConfigSectionName(ConfigKey.FogSpeedUiEnabled), GetConfigKeyName(ConfigKey.FogSpeedUiEnabled), true, CreateConfigDescription(ConfigKey.FogSpeedUiEnabled, isChineseLanguage)); CampfireDistanceUiEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>(GetConfigSectionName(ConfigKey.CampfireDistanceUiEnabled), GetConfigKeyName(ConfigKey.CampfireDistanceUiEnabled), true, CreateConfigDescription(ConfigKey.CampfireDistanceUiEnabled, isChineseLanguage)); WeatherHazardUiEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>(GetConfigSectionName(ConfigKey.WeatherHazardUiEnabled), GetConfigKeyName(ConfigKey.WeatherHazardUiEnabled), true, CreateConfigDescription(ConfigKey.WeatherHazardUiEnabled, isChineseLanguage)); FogTimingUiEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>(GetConfigSectionName(ConfigKey.FogTimingUiEnabled), GetConfigKeyName(ConfigKey.FogTimingUiEnabled), true, CreateConfigDescription(ConfigKey.FogTimingUiEnabled, isChineseLanguage)); DirectStartUiEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>(GetConfigSectionName(ConfigKey.DirectStartUiEnabled), GetConfigKeyName(ConfigKey.DirectStartUiEnabled), true, CreateConfigDescription(ConfigKey.DirectStartUiEnabled, isChineseLanguage)); FogApproachUiEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>(GetConfigSectionName(ConfigKey.FogApproachUiEnabled), GetConfigKeyName(ConfigKey.FogApproachUiEnabled), true, CreateConfigDescription(ConfigKey.FogApproachUiEnabled, isChineseLanguage)); LavaApproachUiEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>(GetConfigSectionName(ConfigKey.LavaApproachUiEnabled), GetConfigKeyName(ConfigKey.LavaApproachUiEnabled), true, CreateConfigDescription(ConfigKey.LavaApproachUiEnabled, isChineseLanguage)); NextBiomeUiEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>(GetConfigSectionName(ConfigKey.NextBiomeUiEnabled), GetConfigKeyName(ConfigKey.NextBiomeUiEnabled), true, CreateConfigDescription(ConfigKey.NextBiomeUiEnabled, isChineseLanguage)); MigrateLocalizedConfigEntries(); ClampConfigValues(); } private void EnsurePreferredConfigFile() { //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Expected O, but got Unknown try { string configDirectory = Paths.ConfigPath; if (!string.IsNullOrWhiteSpace(configDirectory)) { Directory.CreateDirectory(configDirectory); string text = Path.Combine(configDirectory, "Thanks.Fog&ColdControl.cfg"); string text2 = LegacyConfigFileNames.Select((string fileName) => Path.Combine(configDirectory, fileName)).Concat(new string[1] { Path.Combine(configDirectory, "com.github.Thanks.FogClimb.cfg") }).Distinct<string>(StringComparer.OrdinalIgnoreCase) .ToArray() .FirstOrDefault(File.Exists); if (!string.IsNullOrWhiteSpace(text2) && !string.Equals(text, text2, StringComparison.OrdinalIgnoreCase) && !File.Exists(text)) { File.Move(text2, text); ((BaseUnityPlugin)this).Logger.LogInfo((object)"[Fog&ColdControl] Migrated config file to Thanks.Fog&ColdControl.cfg."); } if (!(BasePluginConfigBackingField == null) && (((BaseUnityPlugin)this).Config == null || !string.Equals(((BaseUnityPlugin)this).Config.ConfigFilePath, text, StringComparison.OrdinalIgnoreCase))) { ConfigFile value = new ConfigFile(text, true); BasePluginConfigBackingField.SetValue(this, value); } } } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("[Fog&ColdControl] Failed to switch config path to Thanks.Fog&ColdControl.cfg: " + ex.Message)); } } private ConfigDescription CreateConfigDescription(ConfigKey configKey, bool isChineseLanguage) { //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Expected O, but got Unknown //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Expected O, but got Unknown //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Expected O, but got Unknown //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Expected O, but got Unknown //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Expected O, but got Unknown //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Expected O, but got Unknown //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Expected O, but got Unknown //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Expected O, but got Unknown return (ConfigDescription)(configKey switch { ConfigKey.FogSpeed => (object)new ConfigDescription(GetLocalizedDescription(configKey, isChineseLanguage), (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.3f, 20f), Array.Empty<object>()), ConfigKey.FogDelay => (object)new ConfigDescription(GetLocalizedDescription(configKey, isChineseLanguage), (AcceptableValueBase)(object)new AcceptableValueRange<float>(20f, 1000f), Array.Empty<object>()), ConfigKey.FogUiX => (object)new ConfigDescription(GetLocalizedDescription(configKey, isChineseLanguage), (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 3840f), Array.Empty<object>()), ConfigKey.FogUiY => (object)new ConfigDescription(GetLocalizedDescription(configKey, isChineseLanguage), (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 2160f), Array.Empty<object>()), ConfigKey.FogUiScale => (object)new ConfigDescription(GetLocalizedDescription(configKey, isChineseLanguage), (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 2.5f), Array.Empty<object>()), ConfigKey.FogUiEntrySpacing => (object)new ConfigDescription(GetLocalizedDescription(configKey, isChineseLanguage), (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 40f), Array.Empty<object>()), ConfigKey.FogUiBackgroundOpacity => (object)new ConfigDescription(GetLocalizedDescription(configKey, isChineseLanguage), (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()), _ => (object)new ConfigDescription(GetLocalizedDescription(configKey, isChineseLanguage), (AcceptableValueBase)null, Array.Empty<object>()), }); } private void MigrateLocalizedConfigEntries() { IDictionary orphanedEntries = GetOrphanedEntries(((BaseUnityPlugin)this).Config); if (orphanedEntries != null && orphanedEntries.Count != 0 && (0u | (TryMigrateLocalizedConfigValue((ConfigEntryBase)(object)ModEnabled, ConfigKey.ModEnabled, orphanedEntries) ? 1u : 0u) | (TryMigrateLocalizedConfigValue((ConfigEntryBase)(object)FogColdSuppression, ConfigKey.FogColdSuppression, orphanedEntries) ? 1u : 0u) | (TryMigrateLocalizedConfigValue((ConfigEntryBase)(object)NightColdEnabled, ConfigKey.NightColdEnabled, orphanedEntries) ? 1u : 0u) | (TryMigrateLocalizedConfigValue((ConfigEntryBase)(object)FogSpeed, ConfigKey.FogSpeed, orphanedEntries) ? 1u : 0u) | (TryMigrateLocalizedConfigValue((ConfigEntryBase)(object)FogDelay, ConfigKey.FogDelay, orphanedEntries) ? 1u : 0u) | (TryMigrateLocalizedConfigValue((ConfigEntryBase)(object)CompassEnabled, ConfigKey.CompassEnabled, orphanedEntries) ? 1u : 0u) | (TryMigrateLocalizedConfigValue((ConfigEntryBase)(object)CompassHotkey, ConfigKey.CompassHotkey, orphanedEntries) ? 1u : 0u) | (TryMigrateLocalizedConfigValue((ConfigEntryBase)(object)FogPauseHotkey, ConfigKey.FogPauseHotkey, orphanedEntries) ? 1u : 0u) | (TryMigrateLocalizedConfigValue((ConfigEntryBase)(object)FogUiEnabled, ConfigKey.FogUiEnabled, orphanedEntries) ? 1u : 0u) | (TryMigrateLocalizedConfigValue((ConfigEntryBase)(object)CampfireLocatorUiEnabled, ConfigKey.CampfireLocatorUiEnabled, orphanedEntries) ? 1u : 0u) | (TryMigrateLocalizedConfigValue((ConfigEntryBase)(object)FogUiX, ConfigKey.FogUiX, orphanedEntries) ? 1u : 0u) | (TryMigrateLocalizedConfigValue((ConfigEntryBase)(object)FogUiY, ConfigKey.FogUiY, orphanedEntries) ? 1u : 0u) | (TryMigrateLocalizedConfigValue((ConfigEntryBase)(object)FogUiScale, ConfigKey.FogUiScale, orphanedEntries) ? 1u : 0u) | (TryMigrateLocalizedConfigValue((ConfigEntryBase)(object)FogUiEntrySpacing, ConfigKey.FogUiEntrySpacing, orphanedEntries) ? 1u : 0u) | (TryMigrateLocalizedConfigValue((ConfigEntryBase)(object)FogUiLayout, ConfigKey.FogUiLayout, orphanedEntries) ? 1u : 0u) | (TryMigrateLocalizedConfigValue((ConfigEntryBase)(object)FogUiBackgroundOpacity, ConfigKey.FogUiBackgroundOpacity, orphanedEntries) ? 1u : 0u) | (TryMigrateLocalizedConfigValue((ConfigEntryBase)(object)FogStateUiEnabled, ConfigKey.FogStateUiEnabled, orphanedEntries) ? 1u : 0u) | (TryMigrateLocalizedConfigValue((ConfigEntryBase)(object)RunTimerUiEnabled, ConfigKey.RunTimerUiEnabled, orphanedEntries) ? 1u : 0u) | (TryMigrateLocalizedConfigValue((ConfigEntryBase)(object)DayNightTimeUiEnabled, ConfigKey.DayNightTimeUiEnabled, orphanedEntries) ? 1u : 0u) | (TryMigrateLocalizedConfigValue((ConfigEntryBase)(object)AltitudeUiEnabled, ConfigKey.AltitudeUiEnabled, orphanedEntries) ? 1u : 0u) | (TryMigrateLocalizedConfigValue((ConfigEntryBase)(object)FogSpeedUiEnabled, ConfigKey.FogSpeedUiEnabled, orphanedEntries) ? 1u : 0u) | (TryMigrateLocalizedConfigValue((ConfigEntryBase)(object)CampfireDistanceUiEnabled, ConfigKey.CampfireDistanceUiEnabled, orphanedEntries) ? 1u : 0u) | (TryMigrateLocalizedConfigValue((ConfigEntryBase)(object)WeatherHazardUiEnabled, ConfigKey.WeatherHazardUiEnabled, orphanedEntries) ? 1u : 0u) | (TryMigrateLocalizedConfigValue((ConfigEntryBase)(object)FogTimingUiEnabled, ConfigKey.FogTimingUiEnabled, orphanedEntries) ? 1u : 0u) | (TryMigrateLocalizedConfigValue((ConfigEntryBase)(object)DirectStartUiEnabled, ConfigKey.DirectStartUiEnabled, orphanedEntries) ? 1u : 0u) | (TryMigrateLocalizedConfigValue((ConfigEntryBase)(object)FogApproachUiEnabled, ConfigKey.FogApproachUiEnabled, orphanedEntries) ? 1u : 0u) | (TryMigrateLocalizedConfigValue((ConfigEntryBase)(object)LavaApproachUiEnabled, ConfigKey.LavaApproachUiEnabled, orphanedEntries) ? 1u : 0u) | (TryMigrateLocalizedConfigValue((ConfigEntryBase)(object)NextBiomeUiEnabled, ConfigKey.NextBiomeUiEnabled, orphanedEntries) ? 1u : 0u)) != 0) { ((BaseUnityPlugin)this).Config.Save(); MarkConfigFileLocalizationDirty(saveConfigFile: false, reorderConfigFile: true); } } private static bool TryMigrateLocalizedConfigValue(ConfigEntryBase entry, ConfigKey configKey, IDictionary orphanedEntries) { if (((entry != null) ? entry.Definition : null) == (ConfigDefinition)null || orphanedEntries == null) { return false; } bool flag = false; foreach (ConfigDefinition aliasDefinition in GetAliasDefinitions(configKey)) { if (DefinitionsEqual(aliasDefinition, entry.Definition) || !orphanedEntries.Contains(aliasDefinition)) { continue; } if (!flag) { object obj = orphanedEntries[aliasDefinition]; if (obj != null) { entry.SetSerializedValue(obj.ToString()); } flag = true; } orphanedEntries.Remove(aliasDefinition); } return flag; } private static IEnumerable<ConfigDefinition> GetAliasDefinitions(ConfigKey configKey) { string canonicalKey = GetConfigKeyName(configKey); string chineseKey = GetKeyName(configKey, isChineseLanguage: true); string[] array = (from value in new string[4] { GetConfigSectionName(configKey), GetSectionName(configKey, isChineseLanguage: true), GetLegacyConfigSectionName(), GetLegacySectionName(isChineseLanguage: true) }.Concat(GetLegacySectionNames(configKey)) where !string.IsNullOrWhiteSpace(value) select value).Distinct<string>(StringComparer.Ordinal).ToArray(); string[] array2 = array; foreach (string section in array2) { yield return new ConfigDefinition(section, canonicalKey); yield return new ConfigDefinition(section, chineseKey); foreach (string legacyKeyName in GetLegacyKeyNames(configKey)) { yield return new ConfigDefinition(section, legacyKeyName); } } } private static IEnumerable<string> GetLegacySectionNames(ConfigKey configKey) { if (HasBasicSectionLegacyAlias(configKey)) { yield return GetBasicSectionName(isChineseLanguage: false); yield return GetBasicSectionName(isChineseLanguage: true); } } private static bool HasBasicSectionLegacyAlias(ConfigKey configKey) { if (configKey != ConfigKey.ModEnabled && configKey != ConfigKey.FogUiEnabled && configKey != ConfigKey.CampfireLocatorUiEnabled && configKey != ConfigKey.CompassEnabled) { return configKey == ConfigKey.CompassHotkey; } return true; } private static IEnumerable<string> GetLegacyKeyNames(ConfigKey configKey) { if (configKey == ConfigKey.FogColdSuppression) { yield return "毒雾寒冷"; } if (configKey == ConfigKey.CampfireLocatorUiEnabled) { yield return "篭火位置 HUD"; } } private static IDictionary GetOrphanedEntries(ConfigFile configFile) { return ((object)configFile)?.GetType().GetProperty("OrphanedEntries", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(configFile) as IDictionary; } private static bool DefinitionsEqual(ConfigDefinition left, ConfigDefinition right) { if (string.Equals((left != null) ? left.Section : null, (right != null) ? right.Section : null, StringComparison.Ordinal)) { return string.Equals((left != null) ? left.Key : null, (right != null) ? right.Key : null, StringComparison.Ordinal); } return false; } private static void ClampConfigValues() { NormalizeShootZombiesFogUiDefaults(); if (FogSpeed != null) { FogSpeed.Value = Mathf.Clamp(FogSpeed.Value, 0.3f, 20f); } if (FogDelay != null) { FogDelay.Value = Mathf.Clamp(FogDelay.Value, 20f, 1000f); } if (FogUiX != null) { FogUiX.Value = Mathf.Clamp(FogUiX.Value, 0f, 3840f); } if (FogUiY != null) { FogUiY.Value = Mathf.Clamp(FogUiY.Value, 0f, 2160f); } if (FogUiScale != null) { FogUiScale.Value = Mathf.Clamp(FogUiScale.Value, 0.5f, 2.5f); } if (FogUiEntrySpacing != null) { FogUiEntrySpacing.Value = Mathf.Clamp(FogUiEntrySpacing.Value, 0f, 40f); } } private void RegisterConfigChangeHandlers() { if (((BaseUnityPlugin)this).Config != null) { ((BaseUnityPlugin)this).Config.SettingChanged -= OnConfigSettingChanged; ((BaseUnityPlugin)this).Config.SettingChanged += OnConfigSettingChanged; } } private void UnregisterConfigChangeHandlers() { if (((BaseUnityPlugin)this).Config != null) { ((BaseUnityPlugin)this).Config.SettingChanged -= OnConfigSettingChanged; } } private void OnConfigSettingChanged(object sender, SettingChangedEventArgs e) { MarkConfigFileLocalizationDirty(saveConfigFile: false); } private void MarkConfigFileLocalizationDirty(bool saveConfigFile, bool reorderConfigFile = false) { _pendingConfigFileLocalizationRefresh = true; _pendingConfigFileLocalizationSave |= saveConfigFile; _pendingConfigFileOrderRefresh |= reorderConfigFile; } private void HandlePendingConfigFileLocalizationRefresh() { if (_pendingConfigFileLocalizationRefresh && !_isRefreshingLanguage) { bool lastDetectedChineseLanguage = _lastDetectedChineseLanguage; bool pendingConfigFileLocalizationSave = _pendingConfigFileLocalizationSave; bool pendingConfigFileOrderRefresh = _pendingConfigFileOrderRefresh; _pendingConfigFileLocalizationRefresh = false; _pendingConfigFileLocalizationSave = false; _pendingConfigFileOrderRefresh = false; TryRefreshLocalizedConfigFile(lastDetectedChineseLanguage, pendingConfigFileLocalizationSave, pendingConfigFileOrderRefresh); } } private static bool HasAnyConfiguredFogDelay() { return true; } private bool ShouldEnforceConfiguredDelay(OrbFogHandler fogHandler) { if (_initialDelayCompleted || (Object)(object)fogHandler == (Object)null || !HasAnyConfiguredFogDelay()) { return false; } if (fogHandler.currentID != 0) { return IsCampfireDelayPendingForOrigin(fogHandler.currentID); } return true; } private bool ShouldSuppressConfiguredNightCold(Character character) { float currentNormalizedTime; if ((Object)(object)character != (Object)null && (Object)(object)character.data != (Object)null && !character.data.dead && !character.isBot && !character.isZombie && ShouldDisableNightColdFeatureLocally() && IsNightColdStageActive()) { return TryIsNightTime(out currentNormalizedTime); } return false; } private void HandleFogUiConfigChanges() { bool flag = FogUiEnabled?.Value ?? true; bool flag2 = CampfireLocatorUiEnabled?.Value ?? true; float num = FogUiX?.Value ?? 60f; float num2 = FogUiY?.Value ?? 0f; float num3 = FogUiScale?.Value ?? 0.9f; FogUiLayoutKind fogUiLayoutKind = FogUiLayout?.Value ?? FogUiLayoutKind.Horizontal; if (flag != _lastFogUiEnabledState || flag2 != _lastCampfireLocatorUiEnabledState || !Approximately(num, _lastFogUiX) || !Approximately(num2, _lastFogUiY) || !Approximately(num3, _lastFogUiScale) || fogUiLayoutKind != _lastFogUiLayout) { _lastFogUiEnabledState = flag; _lastCampfireLocatorUiEnabledState = flag2; _lastFogUiX = num; _lastFogUiY = num2; _lastFogUiScale = num3; _lastFogUiLayout = fogUiLayoutKind; CreateFogUi(); CreateCampfireLocatorUi(); } } private void ReinitializeLocalizedConfig(bool isChineseLanguage) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) if (_isRefreshingLanguage) { return; } _isRefreshingLanguage = true; try { _lastDetectedChineseLanguage = isChineseLanguage; ApplyLocalizedConfigMetadata(isChineseLanguage); MarkConfigFileLocalizationDirty(saveConfigFile: true); if ((Object)(object)_fogUiText != (Object)null) { ApplyGameTextStyle(_fogUiText, Color.white); } if ((Object)(object)_compassLobbyNoticeText != (Object)null) { ApplyCompassLobbyNoticeStyle(_compassLobbyNoticeText); } RefreshFogUiEntryStyles(); TryLocalizeVisibleModConfigUi(); UpdateFogUi(); UpdateCompassLobbyNotice(); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("[Fog&ColdControl] Failed to reinitialize localized config: " + ex.Message)); } finally { _isRefreshingLanguage = false; } } private void ApplyLocalizedConfigMetadata(bool isChineseLanguage) { try { ConfigEntryBase[] configEntriesSnapshot = GetConfigEntriesSnapshot(((BaseUnityPlugin)this).Config); foreach (ConfigEntryBase val in configEntriesSnapshot) { if (!(((val != null) ? val.Definition : null) == (ConfigDefinition)null) && val.Description != null && TryGetConfigKey(val.Definition.Key, out var configKey)) { string localizedDescription = GetLocalizedDescription(configKey, isChineseLanguage); if (!string.IsNullOrWhiteSpace(localizedDescription)) { SetPrivateField(val.Description, "<Description>k__BackingField", localizedDescription); } } } } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("[Fog&ColdControl] Failed to apply localized config metadata: " + ex.Message)); } } private static ConfigEntryBase[] GetConfigEntriesSnapshot(ConfigFile configFile) { if (configFile == null) { return Array.Empty<ConfigEntryBase>(); } if (!(ConfigFileEntriesProperty?.GetValue(configFile) is IDictionary { Count: not 0 } dictionary)) { return Array.Empty<ConfigEntryBase>(); } return (from entry in dictionary.Values.Cast<object>().OfType<ConfigEntryBase>() where entry != null select entry).ToArray(); } private static bool TryGetConfigKey(string keyName, out ConfigKey configKey) { foreach (ConfigKey value in Enum.GetValues(typeof(ConfigKey))) { if (string.Equals(keyName, GetConfigKeyName(value), StringComparison.OrdinalIgnoreCase) || string.Equals(keyName, GetKeyName(value, isChineseLanguage: true), StringComparison.OrdinalIgnoreCase) || GetLegacyKeyNames(value).Any((string legacyKey) => string.Equals(keyName, legacyKey, StringComparison.OrdinalIgnoreCase))) { configKey = value; return true; } } configKey = ConfigKey.ModEnabled; return false; } private void TryRefreshLocalizedConfigFile(bool isChineseLanguage, bool saveConfigFile, bool reorderConfigFile) { try { if (((BaseUnityPlugin)this).Config != null && !string.IsNullOrWhiteSpace(((BaseUnityPlugin)this).Config.ConfigFilePath)) { if (saveConfigFile) { ((BaseUnityPlugin)this).Config.Save(); } RewriteConfigFileLocalization(((BaseUnityPlugin)this).Config.ConfigFilePath, isChineseLanguage, reorderConfigFile); } } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("[Fog&ColdControl] Failed to refresh localized config file: " + ex.Message)); } } private static void RewriteConfigFileLocalization(string configFilePath, bool isChineseLanguage, bool reorderConfigFile) { if (string.IsNullOrWhiteSpace(configFilePath) || !File.Exists(configFilePath)) { return; } string[] array = File.ReadAllLines(configFilePath); string[] array2 = new string[array.Length]; bool flag = false; for (int i = 0; i < array.Length; i++) { string text = array[i] ?? string.Empty; if (!string.Equals(text, array2[i] = RewriteConfigFileLine(text, isChineseLanguage), StringComparison.Ordinal)) { flag = true; } } if (reorderConfigFile) { string[] array3 = ReorderConfigFileLines(array2, isChineseLanguage); if (!array2.SequenceEqual(array3)) { array2 = array3; flag = true; } } if (flag) { File.WriteAllLines(configFilePath, array2); } } private static string[] ReorderConfigFileLines(string[] lines, bool isChineseLanguage) { if (lines == null || lines.Length == 0) { return Array.Empty<string>(); } string basicSectionName = GetBasicSectionName(isChineseLanguage); string adjustmentSectionName = GetAdjustmentSectionName(isChineseLanguage); List<string> list = new List<string>(); List<string> list2 = new List<string>(); Dictionary<ConfigKey, ConfigFileEntryBlock> dictionary = new Dictionary<ConfigKey, ConfigFileEntryBlock>(); Dictionary<string, List<ConfigFileEntryBlock>> dictionary2 = new Dictionary<string, List<Con