using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security.Cryptography;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using Bulbul;
using ChillWithYou.EnvSync.Core;
using ChillWithYou.EnvSync.Models;
using ChillWithYou.EnvSync.Patches;
using ChillWithYou.EnvSync.Services;
using ChillWithYou.EnvSync.Utils;
using HarmonyLib;
using TMPro;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.SceneManagement;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("RealTimeWeatherMod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("RealTimeWeatherMod")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("426b3167-5474-4b37-941d-a32b8cf29351")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace ChillWithYou.EnvSync
{
[BepInPlugin("chillwithyou.envsync", "Chill Env Sync", "5.1.3")]
public class ChillEnvPlugin : BaseUnityPlugin
{
[CompilerGenerated]
private sealed class <VerifyUnlockAfterDelay>d__28 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public float delay;
public UnlockItemService svc;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <VerifyUnlockAfterDelay>d__28(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>2__current = (object)new WaitForSeconds(delay);
<>1__state = 1;
return true;
case 1:
{
<>1__state = -1;
ManualLogSource log = Log;
if (log != null)
{
log.LogInfo((object)$"[调试] {delay}秒后验证解锁状态...");
}
int num = 0;
int num2 = 0;
try
{
object value = ((object)svc).GetType().GetProperty("Environment").GetValue(svc);
foreach (DictionaryEntry item in value.GetType().GetField("_environmentDic", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).GetValue(value) as IDictionary)
{
object value2 = item.Value;
object value3 = value2.GetType().GetField("_isLocked", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).GetValue(value2);
if ((bool)value3.GetType().GetProperty("Value").GetValue(value3, null))
{
num++;
ManualLogSource log2 = Log;
if (log2 != null)
{
log2.LogWarning((object)$"[调试] ⚠\ufe0f 环境 {item.Key} 被重新锁定!");
}
}
}
}
catch (Exception ex)
{
ManualLogSource log3 = Log;
if (log3 != null)
{
log3.LogError((object)("[调试] 验证环境失败: " + ex.Message));
}
}
try
{
object obj = ((object)svc).GetType().GetProperty("Decoration")?.GetValue(svc);
if (obj != null && obj.GetType().GetField("_decorationDic", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(obj) is IDictionary dictionary)
{
foreach (DictionaryEntry item2 in dictionary)
{
object value4 = item2.Value;
object obj2 = value4.GetType().GetField("_isLocked", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(value4);
if (obj2 != null && (bool)obj2.GetType().GetProperty("Value").GetValue(obj2, null))
{
num2++;
ManualLogSource log4 = Log;
if (log4 != null)
{
log4.LogWarning((object)$"[调试] ⚠\ufe0f 装饰品 {item2.Key} 被重新锁定!");
}
}
}
}
}
catch (Exception ex2)
{
ManualLogSource log5 = Log;
if (log5 != null)
{
log5.LogError((object)("[调试] 验证装饰品失败: " + ex2.Message));
}
}
if (num == 0 && num2 == 0)
{
ManualLogSource log6 = Log;
if (log6 != null)
{
log6.LogInfo((object)"[调试] ✅ 验证通过: 所有解锁状态保持正常");
}
}
else
{
ManualLogSource log7 = Log;
if (log7 != null)
{
log7.LogError((object)$"[调试] ❌ 发现问题: {num} 个环境和 {num2} 个装饰品被重新锁定");
}
ManualLogSource log8 = Log;
if (log8 != null)
{
log8.LogError((object)"[调试] 可能原因: 游戏在初始化后重新加载了存档数据");
}
}
return false;
}
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
internal static ChillEnvPlugin Instance;
internal static ManualLogSource Log;
internal static UnlockItemService UnlockItemServiceInstance;
internal static object WindowViewServiceInstance;
internal static MethodInfo ChangeWeatherMethod;
internal static string UIWeatherString = "";
internal static bool Initialized;
internal static ConfigEntry<int> Cfg_WeatherRefreshMinutes;
internal static ConfigEntry<string> Cfg_SunriseTime;
internal static ConfigEntry<string> Cfg_SunsetTime;
internal static ConfigEntry<string> Cfg_SeniverseKey;
internal static ConfigEntry<string> Cfg_Location;
internal static ConfigEntry<bool> Cfg_EnableWeatherSync;
internal static ConfigEntry<bool> Cfg_UnlockEnvironments;
internal static ConfigEntry<bool> Cfg_UnlockDecorations;
internal static ConfigEntry<bool> Cfg_UnlockPurchasableItems;
internal static ConfigEntry<bool> Cfg_ShowWeatherOnUI;
internal static ConfigEntry<bool> Cfg_DetailedTimeSegments;
internal static ConfigEntry<bool> Cfg_EnableEasterEggs;
internal static ConfigEntry<bool> Cfg_DebugMode;
internal static ConfigEntry<int> Cfg_DebugCode;
internal static ConfigEntry<int> Cfg_DebugTemp;
internal static ConfigEntry<string> Cfg_DebugText;
internal static ConfigEntry<string> Cfg_LastSunSyncDate;
private static GameObject _runnerGO;
private void Awake()
{
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Expected O, but got Unknown
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Expected O, but got Unknown
Instance = this;
Log = ((BaseUnityPlugin)this).Logger;
Log.LogWarning((object)"【5.1.3】启动 - 解锁调试版");
try
{
Harmony val = new Harmony("ChillWithYou.EnvSync");
val.PatchAll();
UnlockConditionGodMode.ApplyPatches(val);
}
catch (Exception arg)
{
Log.LogError((object)$"Harmony 失败: {arg}");
}
InitConfig();
try
{
_runnerGO = new GameObject("ChillEnvSyncRunner");
((Object)_runnerGO).hideFlags = (HideFlags)61;
Object.DontDestroyOnLoad((Object)(object)_runnerGO);
_runnerGO.SetActive(true);
_runnerGO.AddComponent<AutoEnvRunner>();
_runnerGO.AddComponent<SceneryAutomationSystem>();
_runnerGO.AddComponent<ModSettingsIntegration>();
}
catch (Exception arg2)
{
Log.LogError((object)$"Runner 创建失败: {arg2}");
}
}
private void InitConfig()
{
Cfg_WeatherRefreshMinutes = ((BaseUnityPlugin)this).Config.Bind<int>("WeatherSync", "RefreshMinutes", 30, "天气API刷新间隔(分钟)");
Cfg_SunriseTime = ((BaseUnityPlugin)this).Config.Bind<string>("TimeConfig", "Sunrise", "06:30", "日出时间");
Cfg_SunsetTime = ((BaseUnityPlugin)this).Config.Bind<string>("TimeConfig", "Sunset", "18:30", "日落时间");
Cfg_EnableWeatherSync = ((BaseUnityPlugin)this).Config.Bind<bool>("WeatherAPI", "EnableWeatherSync", false, "是否启用天气API同步");
Cfg_SeniverseKey = ((BaseUnityPlugin)this).Config.Bind<string>("WeatherAPI", "SeniverseKey", "", "心知天气 API Key");
Cfg_Location = ((BaseUnityPlugin)this).Config.Bind<string>("WeatherAPI", "Location", "beijing", "城市名称");
Cfg_UnlockEnvironments = ((BaseUnityPlugin)this).Config.Bind<bool>("Unlock", "UnlockAllEnvironments", true, "自动解锁环境");
Cfg_UnlockDecorations = ((BaseUnityPlugin)this).Config.Bind<bool>("Unlock", "UnlockAllDecorations", true, "自动解锁装饰道具");
Cfg_UnlockPurchasableItems = ((BaseUnityPlugin)this).Config.Bind<bool>("Unlock", "UnlockPurchasableItems", false, "解锁游戏币购买内容");
Cfg_ShowWeatherOnUI = ((BaseUnityPlugin)this).Config.Bind<bool>("UI", "ShowWeatherOnDate", true, "日期栏显示天气");
Cfg_DetailedTimeSegments = ((BaseUnityPlugin)this).Config.Bind<bool>("UI", "DetailedTimeSegments", true, "开启12小时制时,显示详细时段(凌晨/清晨/上午等)");
Cfg_EnableEasterEggs = ((BaseUnityPlugin)this).Config.Bind<bool>("Automation", "EnableSeasonalEasterEggs", true, "启用季节性彩蛋与环境音效自动托管");
Cfg_DebugMode = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "EnableDebugMode", false, "调试模式");
Cfg_DebugCode = ((BaseUnityPlugin)this).Config.Bind<int>("Debug", "SimulatedCode", 1, "模拟天气代码");
Cfg_DebugTemp = ((BaseUnityPlugin)this).Config.Bind<int>("Debug", "SimulatedTemp", 25, "模拟温度");
Cfg_DebugText = ((BaseUnityPlugin)this).Config.Bind<string>("Debug", "SimulatedText", "DebugWeather", "模拟描述");
Cfg_LastSunSyncDate = ((BaseUnityPlugin)this).Config.Bind<string>("Internal", "LastSunSyncDate", "", "上次同步日期");
}
internal static void TryInitializeOnce(UnlockItemService svc)
{
if (!Initialized && svc != null)
{
if (Cfg_UnlockEnvironments.Value)
{
ForceUnlockAllEnvironments(svc);
}
if (Cfg_UnlockDecorations.Value)
{
ForceUnlockAllDecorations(svc);
}
Initialized = true;
ManualLogSource log = Log;
if (log != null)
{
log.LogInfo((object)"初始化完成");
}
if (Cfg_DebugMode.Value && (Object)(object)Instance != (Object)null)
{
((MonoBehaviour)Instance).StartCoroutine(VerifyUnlockAfterDelay(svc, 3f));
}
}
}
[IteratorStateMachine(typeof(<VerifyUnlockAfterDelay>d__28))]
private static IEnumerator VerifyUnlockAfterDelay(UnlockItemService svc, float delay)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <VerifyUnlockAfterDelay>d__28(0)
{
svc = svc,
delay = delay
};
}
internal static void CallServiceChangeWeather(EnvironmentType envType)
{
//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: 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)
MonoBehaviour val = null;
Type type = AccessTools.TypeByName("Bulbul.EnvironmentUI");
if (type != null)
{
Object[] array = Resources.FindObjectsOfTypeAll(type);
if (array != null && array.Length != 0)
{
Object[] array2 = array;
foreach (Object obj in array2)
{
MonoBehaviour val2 = (MonoBehaviour)(object)((obj is MonoBehaviour) ? obj : null);
if ((Object)(object)val2 != (Object)null)
{
Scene scene = ((Component)val2).gameObject.scene;
if (((Scene)(ref scene)).rootCount != 0)
{
val = val2;
break;
}
}
}
}
}
if ((Object)(object)val == (Object)null)
{
return;
}
try
{
MethodInfo methodInfo = AccessTools.Method(((object)val).GetType(), "ChangeTime", (Type[])null, (Type[])null);
if (methodInfo != null)
{
ParameterInfo[] parameters = methodInfo.GetParameters();
if (parameters.Length != 0)
{
object obj2 = Enum.Parse(parameters[0].ParameterType, ((object)(EnvironmentType)(ref envType)).ToString());
methodInfo.Invoke(val, new object[1] { obj2 });
ManualLogSource log = Log;
if (log != null)
{
log.LogInfo((object)$"[Service] \ud83c\udf27\ufe0f 天气已切换并同步状态: {envType}");
}
}
}
else
{
ManualLogSource log2 = Log;
if (log2 != null)
{
log2.LogError((object)"[Service] ❌ 找不到 ChangeTime 方法,游戏版本可能不匹配");
}
}
}
catch (Exception ex)
{
ManualLogSource log3 = Log;
if (log3 != null)
{
log3.LogError((object)("[Service] ❌ 调用 ChangeTime 失败: " + ex.Message));
}
}
}
internal static void SimulateClickMainIcon(EnvironmentController ctrl)
{
if ((Object)(object)ctrl == (Object)null)
{
return;
}
try
{
ManualLogSource log = Log;
if (log != null)
{
log.LogInfo((object)("[SimulateClick] 准备点击: " + ((Object)ctrl).name + " (Type: " + ((object)ctrl).GetType().Name + ")"));
}
MethodInfo method = ((object)ctrl).GetType().GetMethod("OnClickButtonMainIcon", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
if (method != null)
{
UserInteractionPatch.IsSimulatingClick = true;
method.Invoke(ctrl, null);
UserInteractionPatch.IsSimulatingClick = false;
ManualLogSource log2 = Log;
if (log2 != null)
{
log2.LogInfo((object)("[SimulateClick] 点击调用完成: " + ((Object)ctrl).name));
}
}
else
{
ManualLogSource log3 = Log;
if (log3 != null)
{
log3.LogError((object)("[SimulateClick] ❌ 未找到 OnClickButtonMainIcon 方法: " + ((Object)ctrl).name));
}
}
}
catch (Exception ex)
{
ManualLogSource log4 = Log;
if (log4 != null)
{
log4.LogError((object)("模拟点击失败: " + ex.Message));
}
}
}
private static void ForceUnlockAllEnvironments(UnlockItemService svc)
{
try
{
object value = ((object)svc).GetType().GetProperty("Environment").GetValue(svc);
IDictionary obj = value.GetType().GetField("_environmentDic", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).GetValue(value) as IDictionary;
int num = 0;
int num2 = 0;
foreach (DictionaryEntry item in obj)
{
object value2 = item.Value;
object value3 = value2.GetType().GetField("_isLocked", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).GetValue(value2);
PropertyInfo? property = value3.GetType().GetProperty("Value");
bool flag = (bool)property.GetValue(value3, null);
property.SetValue(value3, false, null);
num++;
bool flag2 = (bool)property.GetValue(value3, null);
if (!flag2)
{
num2++;
}
if (Cfg_DebugMode.Value)
{
ManualLogSource log = Log;
if (log != null)
{
log.LogInfo((object)$"[环境解锁] {item.Key}: {flag} -> {flag2}");
}
}
}
ManualLogSource log2 = Log;
if (log2 != null)
{
log2.LogInfo((object)$"✅ 已解锁 {num} 个环境 (验证成功: {num2})");
}
}
catch (Exception arg)
{
ManualLogSource log3 = Log;
if (log3 != null)
{
log3.LogError((object)$"环境解锁失败: {arg}");
}
}
}
private static void ForceUnlockAllDecorations(UnlockItemService svc)
{
if (svc == null)
{
return;
}
ManualLogSource log = Log;
if (log != null)
{
log.LogInfo((object)"☢\ufe0f 启动通用解锁核弹 v2 (钻地模式)...");
}
int num = 0;
try
{
foreach (FieldInfo declaredField in AccessTools.GetDeclaredFields(((object)svc).GetType()))
{
if (declaredField.FieldType.Name.Contains("MasterData") || declaredField.FieldType.Name.Contains("Loader"))
{
continue;
}
object value = declaredField.GetValue(svc);
if (value == null)
{
continue;
}
foreach (FieldInfo declaredField2 in AccessTools.GetDeclaredFields(value.GetType()))
{
if (!typeof(IDictionary).IsAssignableFrom(declaredField2.FieldType) || !(declaredField2.GetValue(value) is IDictionary dictionary) || dictionary.Count == 0)
{
continue;
}
int num2 = 0;
foreach (DictionaryEntry item in dictionary)
{
object value2 = item.Value;
if (value2 == null)
{
continue;
}
FieldInfo fieldInfo = AccessTools.Field(value2.GetType(), "_isLocked");
if (fieldInfo == null)
{
continue;
}
object value3 = fieldInfo.GetValue(value2);
if (value3 == null)
{
continue;
}
PropertyInfo property = value3.GetType().GetProperty("Value");
if (property == null || !(bool)property.GetValue(value3, null))
{
continue;
}
property.SetValue(value3, false, null);
num2++;
num++;
if (Cfg_DebugMode.Value)
{
ManualLogSource log2 = Log;
if (log2 != null)
{
log2.LogInfo((object)$" \ud83d\udd13 解锁: {item.Key} (在 {declaredField.Name}.{declaredField2.Name})");
}
}
}
if (num2 > 0)
{
ManualLogSource log3 = Log;
if (log3 != null)
{
log3.LogInfo((object)$"✅ 在 {declaredField.Name} -> {declaredField2.Name} 中解锁了 {num2} 个项目");
}
}
}
}
ManualLogSource log4 = Log;
if (log4 != null)
{
log4.LogInfo((object)$"\ud83c\udf89 核弹 v2 投放完毕,本次共解锁 {num} 个项目!");
}
}
catch (Exception arg)
{
ManualLogSource log5 = Log;
if (log5 != null)
{
log5.LogError((object)$"❌ 通用解锁 v2 失败: {arg}");
}
}
}
}
}
namespace ChillWithYou.EnvSync.Utils
{
internal static class EnvRegistry
{
private static readonly Dictionary<EnvironmentType, EnvironmentController> _map = new Dictionary<EnvironmentType, EnvironmentController>();
public static int Count => _map.Count;
public static bool TryGet(EnvironmentType type, out EnvironmentController ctrl)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
return _map.TryGetValue(type, out ctrl);
}
public static void Register(EnvironmentType type, EnvironmentController ctrl)
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)ctrl != (Object)null)
{
_map[type] = ctrl;
}
}
}
}
namespace ChillWithYou.EnvSync.Services
{
internal static class KeySecurity
{
private static readonly byte[] _k = new byte[16]
{
67, 104, 105, 108, 108, 87, 105, 116, 104, 89,
111, 117, 50, 48, 50, 53
};
private static readonly byte[] _i = new byte[16]
{
87, 101, 97, 116, 104, 101, 114, 77, 111, 100,
73, 86, 56, 56, 56, 56
};
public static string Decrypt(string encryptedText)
{
if (string.IsNullOrEmpty(encryptedText))
{
return null;
}
try
{
using Aes aes = Aes.Create();
aes.Key = _k;
aes.IV = _i;
ICryptoTransform transform = aes.CreateDecryptor(aes.Key, aes.IV);
using MemoryStream stream = new MemoryStream(Convert.FromBase64String(encryptedText));
using CryptoStream stream2 = new CryptoStream(stream, transform, CryptoStreamMode.Read);
using StreamReader streamReader = new StreamReader(stream2);
return streamReader.ReadToEnd();
}
catch (Exception ex)
{
ManualLogSource log = ChillEnvPlugin.Log;
if (log != null)
{
log.LogError((object)("[KeySecurity] 解密失败: " + ex.Message));
}
return null;
}
}
public static string Encrypt(string plainText)
{
if (string.IsNullOrEmpty(plainText))
{
return null;
}
try
{
using Aes aes = Aes.Create();
aes.Key = _k;
aes.IV = _i;
ICryptoTransform transform = aes.CreateEncryptor(aes.Key, aes.IV);
using MemoryStream memoryStream = new MemoryStream();
using (CryptoStream stream = new CryptoStream(memoryStream, transform, CryptoStreamMode.Write))
{
using StreamWriter streamWriter = new StreamWriter(stream);
streamWriter.Write(plainText);
}
return Convert.ToBase64String(memoryStream.ToArray());
}
catch (Exception ex)
{
ManualLogSource log = ChillEnvPlugin.Log;
if (log != null)
{
log.LogError((object)("[KeySecurity] 加密失败: " + ex.Message));
}
return null;
}
}
}
public class WeatherService
{
[CompilerGenerated]
private sealed class <FetchSunSchedule>d__12 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public string apiKey;
public Action<SunData> onComplete;
public string location;
private UnityWebRequest <request>5__2;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <FetchSunSchedule>d__12(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
int num = <>1__state;
if (num == -3 || num == 1)
{
try
{
}
finally
{
<>m__Finally1();
}
}
<request>5__2 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0105: Unknown result type (might be due to invalid IL or missing references)
//IL_010b: Invalid comparison between Unknown and I4
bool result;
try
{
switch (<>1__state)
{
default:
result = false;
break;
case 0:
{
<>1__state = -1;
string text = apiKey;
if (string.IsNullOrEmpty(text) && HasDefaultKey)
{
text = KeySecurity.Decrypt(_encryptedDefaultKey);
}
if (string.IsNullOrEmpty(text))
{
onComplete?.Invoke(null);
result = false;
break;
}
string text2 = "https://api.seniverse.com/v3/geo/sun.json?key=" + text + "&location=" + UnityWebRequest.EscapeURL(location) + "&language=zh-Hans&start=0&days=1";
ManualLogSource log3 = ChillEnvPlugin.Log;
if (log3 != null)
{
log3.LogInfo((object)("[API] 请求日出日落: " + location));
}
<request>5__2 = UnityWebRequest.Get(text2);
<>1__state = -3;
<request>5__2.timeout = 15;
<>2__current = <request>5__2.SendWebRequest();
<>1__state = 1;
result = true;
break;
}
case 1:
<>1__state = -3;
if ((int)<request>5__2.result != 1 || string.IsNullOrEmpty(<request>5__2.downloadHandler.text))
{
ManualLogSource log = ChillEnvPlugin.Log;
if (log != null)
{
log.LogWarning((object)("[API] 日出日落请求失败: " + <request>5__2.error));
}
onComplete?.Invoke(null);
result = false;
<>m__Finally1();
break;
}
try
{
SunData obj = ParseSunJson(<request>5__2.downloadHandler.text);
onComplete?.Invoke(obj);
}
catch (Exception arg)
{
ManualLogSource log2 = ChillEnvPlugin.Log;
if (log2 != null)
{
log2.LogError((object)$"[API] 日出日落解析失败: {arg}");
}
onComplete?.Invoke(null);
}
<>m__Finally1();
<request>5__2 = null;
result = false;
break;
}
}
catch
{
//try-fault
((IDisposable)this).Dispose();
throw;
}
return result;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
private void <>m__Finally1()
{
<>1__state = -1;
if (<request>5__2 != null)
{
((IDisposable)<request>5__2).Dispose();
}
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[CompilerGenerated]
private sealed class <FetchWeather>d__9 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public string location;
public bool force;
public Action<WeatherInfo> onComplete;
public string apiKey;
private string <normalizedLocation>5__2;
private UnityWebRequest <request>5__3;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <FetchWeather>d__9(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
int num = <>1__state;
if (num == -3 || num == 1)
{
try
{
}
finally
{
<>m__Finally1();
}
}
<normalizedLocation>5__2 = null;
<request>5__3 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0195: Unknown result type (might be due to invalid IL or missing references)
//IL_019b: Invalid comparison between Unknown and I4
bool result;
try
{
switch (<>1__state)
{
default:
result = false;
break;
case 0:
{
<>1__state = -1;
<normalizedLocation>5__2 = location?.Trim() ?? "";
if (!force && _cachedWeather != null && DateTime.Now - _lastFetchTime < CacheExpiry && string.Equals(_lastLocation, <normalizedLocation>5__2, StringComparison.OrdinalIgnoreCase))
{
onComplete?.Invoke(_cachedWeather);
result = false;
break;
}
string text = apiKey;
if (string.IsNullOrEmpty(text) && HasDefaultKey)
{
text = KeySecurity.Decrypt(_encryptedDefaultKey);
}
if (string.IsNullOrEmpty(text))
{
ManualLogSource log4 = ChillEnvPlugin.Log;
if (log4 != null)
{
log4.LogWarning((object)"[API] 未配置 API Key 且无内置 Key");
}
onComplete?.Invoke(null);
result = false;
break;
}
string text2 = "https://api.seniverse.com/v3/weather/now.json?key=" + text + "&location=" + UnityWebRequest.EscapeURL(location) + "&language=zh-Hans&unit=c";
ManualLogSource log5 = ChillEnvPlugin.Log;
if (log5 != null)
{
log5.LogInfo((object)("[API] 发起请求: " + location));
}
<request>5__3 = UnityWebRequest.Get(text2);
<>1__state = -3;
<request>5__3.timeout = 10;
<>2__current = <request>5__3.SendWebRequest();
<>1__state = 1;
result = true;
break;
}
case 1:
<>1__state = -3;
if ((int)<request>5__3.result != 1 || string.IsNullOrEmpty(<request>5__3.downloadHandler.text))
{
ManualLogSource log = ChillEnvPlugin.Log;
if (log != null)
{
log.LogWarning((object)("[API] 请求失败: " + <request>5__3.error));
}
onComplete?.Invoke(null);
result = false;
<>m__Finally1();
break;
}
try
{
WeatherInfo weatherInfo = ParseWeatherJson(<request>5__3.downloadHandler.text);
if (weatherInfo != null)
{
_cachedWeather = weatherInfo;
_lastFetchTime = DateTime.Now;
_lastLocation = <normalizedLocation>5__2;
ManualLogSource log2 = ChillEnvPlugin.Log;
if (log2 != null)
{
log2.LogInfo((object)$"[API] 数据更新: {weatherInfo}");
}
onComplete?.Invoke(weatherInfo);
}
else
{
ManualLogSource log3 = ChillEnvPlugin.Log;
if (log3 != null)
{
log3.LogWarning((object)"[API] 解析失败");
}
onComplete?.Invoke(null);
}
}
catch
{
onComplete?.Invoke(null);
}
<>m__Finally1();
<request>5__3 = null;
result = false;
break;
}
}
catch
{
//try-fault
((IDisposable)this).Dispose();
throw;
}
return result;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
private void <>m__Finally1()
{
<>1__state = -1;
if (<request>5__3 != null)
{
((IDisposable)<request>5__3).Dispose();
}
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
private static WeatherInfo _cachedWeather;
private static DateTime _lastFetchTime;
private static readonly TimeSpan CacheExpiry = TimeSpan.FromMinutes(60.0);
private static string _lastLocation;
private static readonly string _encryptedDefaultKey = "7Mr4YSR87bFvE4zDgj6NbuBKgz4EiPYEnRTQ0RIaeSU=";
public static WeatherInfo CachedWeather => _cachedWeather;
public static bool HasDefaultKey => !string.IsNullOrEmpty(_encryptedDefaultKey);
[IteratorStateMachine(typeof(<FetchWeather>d__9))]
public static IEnumerator FetchWeather(string apiKey, string location, bool force, Action<WeatherInfo> onComplete)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <FetchWeather>d__9(0)
{
apiKey = apiKey,
location = location,
force = force,
onComplete = onComplete
};
}
public static void InvalidateCache()
{
_cachedWeather = null;
_lastLocation = null;
_lastFetchTime = DateTime.MinValue;
}
private static WeatherInfo ParseWeatherJson(string json)
{
try
{
if (json.Contains("\"status\"") && !json.Contains("\"results\""))
{
return null;
}
if (json.IndexOf("\"now\"") < 0)
{
return null;
}
int code = ExtractIntValue(json, "\"code\":\"", "\"");
int temperature = ExtractIntValue(json, "\"temperature\":\"", "\"");
string text = ExtractStringValue(json, "\"text\":\"", "\"");
if (string.IsNullOrEmpty(text))
{
return null;
}
return new WeatherInfo
{
Code = code,
Text = text,
Temperature = temperature,
Condition = MapCodeToCondition(code),
UpdateTime = DateTime.Now
};
}
catch
{
return null;
}
}
[IteratorStateMachine(typeof(<FetchSunSchedule>d__12))]
public static IEnumerator FetchSunSchedule(string apiKey, string location, Action<SunData> onComplete)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <FetchSunSchedule>d__12(0)
{
apiKey = apiKey,
location = location,
onComplete = onComplete
};
}
private static SunData ParseSunJson(string json)
{
if (json.IndexOf("\"sun\"") < 0)
{
return null;
}
string text = ExtractStringValue(json, "\"sunrise\":\"", "\"");
string text2 = ExtractStringValue(json, "\"sunset\":\"", "\"");
if (!string.IsNullOrEmpty(text) && !string.IsNullOrEmpty(text2))
{
return new SunData
{
sunrise = text,
sunset = text2
};
}
return null;
}
private static int ExtractIntValue(string json, string prefix, string suffix)
{
int num = json.IndexOf(prefix);
if (num < 0)
{
return 0;
}
num += prefix.Length;
int num2 = json.IndexOf(suffix, num);
if (num2 < 0)
{
return 0;
}
int.TryParse(json.Substring(num, num2 - num), out var result);
return result;
}
private static string ExtractStringValue(string json, string prefix, string suffix)
{
int num = json.IndexOf(prefix);
if (num < 0)
{
return null;
}
num += prefix.Length;
int num2 = json.IndexOf(suffix, num);
if (num2 < 0)
{
return null;
}
return json.Substring(num, num2 - num);
}
public static WeatherCondition MapCodeToCondition(int code)
{
if (code >= 0 && code <= 3)
{
return WeatherCondition.Clear;
}
if (code >= 4 && code <= 9)
{
return WeatherCondition.Cloudy;
}
if (code >= 10 && code <= 20)
{
return WeatherCondition.Rainy;
}
if (code >= 21 && code <= 25)
{
return WeatherCondition.Snowy;
}
if (code >= 26 && code <= 36)
{
return WeatherCondition.Foggy;
}
return WeatherCondition.Unknown;
}
}
}
namespace ChillWithYou.EnvSync.Patches
{
[HarmonyPatch(typeof(UnlockItemService), "Setup")]
internal static class UnlockServicePatch
{
private static void Postfix(UnlockItemService __instance)
{
ChillEnvPlugin.UnlockItemServiceInstance = __instance;
ChillEnvPlugin.TryInitializeOnce(__instance);
}
}
[HarmonyPatch(typeof(EnvironmentController), "Setup")]
internal static class EnvControllerPatch
{
private static void Postfix(EnvironmentController __instance)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
EnvRegistry.Register(__instance.EnvironmentType, __instance);
}
}
[HarmonyPatch(typeof(FacilityEnvironment), "Setup")]
internal static class FacilityEnvPatch
{
private static void Postfix(FacilityEnvironment __instance)
{
try
{
FieldInfo field = typeof(FacilityEnvironment).GetField("_windowViewService", BindingFlags.Instance | BindingFlags.NonPublic);
if (!(field != null))
{
return;
}
object value = field.GetValue(__instance);
if (value == null)
{
return;
}
ChillEnvPlugin.WindowViewServiceInstance = value;
ChillEnvPlugin.ChangeWeatherMethod = value.GetType().GetMethod("ChangeWeatherAndTime", BindingFlags.Instance | BindingFlags.Public);
if (ChillEnvPlugin.ChangeWeatherMethod != null)
{
ManualLogSource log = ChillEnvPlugin.Log;
if (log != null)
{
log.LogInfo((object)"✅ 成功捕获 WindowViewService.ChangeWeatherAndTime");
}
}
}
catch (Exception arg)
{
ManualLogSource log2 = ChillEnvPlugin.Log;
if (log2 != null)
{
log2.LogError((object)$"捕获 Service 失败: {arg}");
}
}
}
}
[HarmonyPatch(typeof(CurrentDateAndTimeUI), "UpdateDateAndTime")]
internal static class DateUIPatch
{
private static void Postfix(CurrentDateAndTimeUI __instance)
{
//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)
if (ChillEnvPlugin.Cfg_ShowWeatherOnUI.Value && !string.IsNullOrEmpty(ChillEnvPlugin.UIWeatherString))
{
try
{
FieldInfo field = typeof(CurrentDateAndTimeUI).GetField("_dateText", BindingFlags.Instance | BindingFlags.NonPublic);
if (field != null)
{
object? value = field.GetValue(__instance);
TextMeshProUGUI val = (TextMeshProUGUI)((value is TextMeshProUGUI) ? value : null);
if ((Object)(object)val != (Object)null)
{
((TMP_Text)val).text = ((TMP_Text)val).text + " | " + ChillEnvPlugin.UIWeatherString;
}
}
}
catch
{
}
}
if (!ChillEnvPlugin.Cfg_DetailedTimeSegments.Value)
{
return;
}
try
{
TimeFormatType value2 = SaveDataManager.Instance.SettingData.TimeFormat.Value;
if (((object)(TimeFormatType)(ref value2)).ToString() != "AMPM")
{
return;
}
int hour = DateTime.Now.Hour;
string text = "晚上";
if (hour >= 0 && hour < 5)
{
text = "凌晨";
}
else if (hour >= 5 && hour < 7)
{
text = "清晨";
}
else if (hour >= 7 && hour < 11)
{
text = "上午";
}
else if (hour >= 11 && hour < 13)
{
text = "中午";
}
else if (hour >= 13 && hour < 18)
{
text = "下午";
}
else if (hour >= 18 && hour < 19)
{
text = "傍晚";
}
else if (hour >= 19 && hour <= 23)
{
text = "晚上";
}
FieldInfo field2 = typeof(CurrentDateAndTimeUI).GetField("_amPmText", BindingFlags.Instance | BindingFlags.NonPublic);
if (!(field2 != null))
{
return;
}
object value3 = field2.GetValue(__instance);
if (value3 == null)
{
return;
}
PropertyInfo property = value3.GetType().GetProperty("Text");
if (property != null)
{
object? value4 = property.GetValue(value3);
TextMeshProUGUI val2 = (TextMeshProUGUI)((value4 is TextMeshProUGUI) ? value4 : null);
if ((Object)(object)val2 != (Object)null)
{
((TMP_Text)val2).text = text;
}
}
}
catch
{
}
}
}
[HarmonyPatch(typeof(EnvironmentController), "OnClickButtonMainIcon")]
internal static class UserInteractionPatch
{
public static bool IsSimulatingClick;
private static void Prefix(EnvironmentController __instance)
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: 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_0086: Invalid comparison between Unknown and I4
//IL_005c: 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_0073: Unknown result type (might be due to invalid IL or missing references)
if (IsSimulatingClick)
{
return;
}
EnvironmentType environmentType = __instance.EnvironmentType;
if (!SceneryAutomationSystem.UserInteractedMods.Contains(environmentType))
{
SceneryAutomationSystem.UserInteractedMods.Add(environmentType);
ManualLogSource log = ChillEnvPlugin.Log;
if (log != null)
{
log.LogInfo((object)$"[用户交互] 用户接管了 {environmentType},停止自动托管。");
}
}
if (SceneryAutomationSystem._autoEnabledMods.Contains(environmentType))
{
SceneryAutomationSystem._autoEnabledMods.Remove(environmentType);
ManualLogSource log2 = ChillEnvPlugin.Log;
if (log2 != null)
{
log2.LogDebug((object)$"[用户交互] 已从托管列表移除 {environmentType}");
}
}
if ((int)environmentType == 15 && SceneryAutomationSystem.IsWhaleSystemTriggered)
{
SceneryAutomationSystem.IsWhaleSystemTriggered = false;
ManualLogSource log3 = ChillEnvPlugin.Log;
if (log3 != null)
{
log3.LogInfo((object)"[鲸鱼彩蛋] 用户手动关闭了系统抽中的鲸鱼,标志已清除");
}
}
}
}
[HarmonyPatch]
internal static class UnlockStatusMonitorPatch
{
private static IEnumerable<MethodBase> TargetMethods()
{
List<MethodBase> list = new List<MethodBase>();
try
{
Type[] types = typeof(UnlockItemService).Assembly.GetTypes();
foreach (Type type in types)
{
if (!type.Name.Contains("UnlockEnvironmentData") && !type.Name.Contains("UnlockDecorationData"))
{
continue;
}
MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
foreach (MethodInfo methodInfo in methods)
{
if (methodInfo.Name.Contains("Lock") || methodInfo.Name.Contains("Unlock"))
{
list.Add(methodInfo);
ManualLogSource log = ChillEnvPlugin.Log;
if (log != null)
{
log.LogInfo((object)("[监控] 找到解锁相关方法: " + type.Name + "." + methodInfo.Name));
}
}
}
}
}
catch (Exception ex)
{
ManualLogSource log2 = ChillEnvPlugin.Log;
if (log2 != null)
{
log2.LogError((object)("[监控] 查找目标方法失败: " + ex.Message));
}
}
return list;
}
private static void Prefix(MethodBase __originalMethod)
{
if (ChillEnvPlugin.Cfg_DebugMode.Value && ChillEnvPlugin.Initialized)
{
ManualLogSource log = ChillEnvPlugin.Log;
if (log != null)
{
log.LogWarning((object)("[监控] 检测到解锁状态变更调用: " + __originalMethod.DeclaringType?.Name + "." + __originalMethod.Name));
}
}
}
}
public class ModSettingsIntegration : MonoBehaviour
{
[CompilerGenerated]
private sealed class <RefreshWeatherAfterDelay>d__8 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public float delay;
public string location;
public ModSettingsIntegration <>4__this;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <RefreshWeatherAfterDelay>d__8(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Expected O, but got Unknown
int num = <>1__state;
ModSettingsIntegration modSettingsIntegration = <>4__this;
switch (num)
{
default:
return false;
case 0:
<>1__state = -1;
<>2__current = (object)new WaitForSecondsRealtime(delay);
<>1__state = 1;
return true;
case 1:
{
<>1__state = -1;
ManualLogSource log = ChillEnvPlugin.Log;
if (log != null)
{
log.LogInfo((object)("\ud83d\udd04 [EnvSync] 城市已更新为 '" + location + "',正在刷新天气与日出日落数据..."));
}
AutoEnvRunner.TriggerWeatherRefresh();
AutoEnvRunner.TriggerSunScheduleRefresh();
modSettingsIntegration._locationDebounceCoroutine = null;
return false;
}
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[CompilerGenerated]
private sealed class <RegisterSettingsWhenReady>d__4 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public ModSettingsIntegration <>4__this;
private float <timeout>5__2;
private float <elapsed>5__3;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <RegisterSettingsWhenReady>d__4(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: Expected O, but got Unknown
int num = <>1__state;
ModSettingsIntegration modSettingsIntegration = <>4__this;
switch (num)
{
default:
return false;
case 0:
<>1__state = -1;
<>2__current = null;
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
<timeout>5__2 = 10f;
<elapsed>5__3 = 0f;
break;
case 2:
<>1__state = -1;
<elapsed>5__3 += 0.5f;
break;
}
if (<elapsed>5__3 < <timeout>5__2)
{
if (modSettingsIntegration.TryRegisterSettings())
{
ManualLogSource log = ChillEnvPlugin.Log;
if (log != null)
{
log.LogInfo((object)"✅ [EnvSync] MOD 设置已成功注册到 iGPU Savior 界面");
}
return false;
}
<>2__current = (object)new WaitForSeconds(0.5f);
<>1__state = 2;
return true;
}
ManualLogSource log2 = ChillEnvPlugin.Log;
if (log2 != null)
{
log2.LogWarning((object)"⚠\ufe0f [EnvSync] 未检测到 iGPU Savior,设置界面集成已跳过。");
}
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
private static bool _settingsRegistered;
private const string MANAGER_TYPE_NAME = "ModShared.ModSettingsManager, iGPU Savior";
private Coroutine _locationDebounceCoroutine;
private void Start()
{
((MonoBehaviour)this).StartCoroutine(RegisterSettingsWhenReady());
}
[IteratorStateMachine(typeof(<RegisterSettingsWhenReady>d__4))]
private IEnumerator RegisterSettingsWhenReady()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <RegisterSettingsWhenReady>d__4(0)
{
<>4__this = this
};
}
private bool TryRegisterSettings()
{
if (_settingsRegistered)
{
return true;
}
try
{
Type type = Type.GetType("ModShared.ModSettingsManager, iGPU Savior");
if (type == null)
{
return false;
}
PropertyInfo property = type.GetProperty("Instance", BindingFlags.Static | BindingFlags.Public);
if (property == null)
{
return false;
}
object value2 = property.GetValue(null);
if (value2 == null)
{
return false;
}
PropertyInfo property2 = type.GetProperty("IsInitialized");
if (property2 != null && !(bool)property2.GetValue(value2))
{
return false;
}
MethodInfo method = type.GetMethod("RegisterMod", new Type[2]
{
typeof(string),
typeof(string)
});
if (method != null)
{
method.Invoke(value2, new object[2] { "Chill Env Sync", "5.1.3" });
}
MethodInfo method2 = type.GetMethod("RegisterTranslation", new Type[4]
{
typeof(string),
typeof(string),
typeof(string),
typeof(string)
});
bool flag = method2 != null;
if (flag)
{
method2.Invoke(value2, new object[4] { "ENV_SYNC_ENABLE", "Weather Sync", "天気同期", "天气同步" });
method2.Invoke(value2, new object[4] { "ENV_SYNC_UI", "Show Weather on UI", "UIに天気を表示", "日期栏天气" });
method2.Invoke(value2, new object[4] { "ENV_SYNC_DETAIL", "Detailed Segments", "詳細セグメント", "详细时段" });
method2.Invoke(value2, new object[4] { "ENV_SYNC_EGG", "Easter Eggs", "イースターエッグ", "彩蛋" });
method2.Invoke(value2, new object[4] { "ENV_SYNC_CITY", "City", "都市", "城市" });
}
bool flag2 = true;
string label = (flag ? "ENV_SYNC_ENABLE" : "天气同步");
if (!AddToggleSafe(value2, type, label, ChillEnvPlugin.Cfg_EnableWeatherSync.Value, delegate(bool value)
{
ChillEnvPlugin.Cfg_EnableWeatherSync.Value = value;
((BaseUnityPlugin)ChillEnvPlugin.Instance).Config.Save();
ManualLogSource log2 = ChillEnvPlugin.Log;
if (log2 != null)
{
log2.LogInfo((object)$"[设置] 天气API同步已设置为: {value}");
}
}))
{
flag2 = false;
}
string label2 = (flag ? "ENV_SYNC_UI" : "日期栏天气");
AddToggleSafe(value2, type, label2, ChillEnvPlugin.Cfg_ShowWeatherOnUI.Value, delegate(bool value)
{
ChillEnvPlugin.Cfg_ShowWeatherOnUI.Value = value;
((BaseUnityPlugin)ChillEnvPlugin.Instance).Config.Save();
});
string label3 = (flag ? "ENV_SYNC_DETAIL" : "详细时段");
AddToggleSafe(value2, type, label3, ChillEnvPlugin.Cfg_DetailedTimeSegments.Value, delegate(bool value)
{
ChillEnvPlugin.Cfg_DetailedTimeSegments.Value = value;
((BaseUnityPlugin)ChillEnvPlugin.Instance).Config.Save();
});
string label4 = (flag ? "ENV_SYNC_EGG" : "彩蛋");
AddToggleSafe(value2, type, label4, ChillEnvPlugin.Cfg_EnableEasterEggs.Value, delegate(bool value)
{
ChillEnvPlugin.Cfg_EnableEasterEggs.Value = value;
((BaseUnityPlugin)ChillEnvPlugin.Instance).Config.Save();
});
string label5 = (flag ? "ENV_SYNC_CITY" : "城市");
if (!AddInputFieldSafe(value2, type, label5, ChillEnvPlugin.Cfg_Location.Value, delegate(string val)
{
ChillEnvPlugin.Cfg_Location.Value = val;
((BaseUnityPlugin)ChillEnvPlugin.Instance).Config.Save();
WeatherService.InvalidateCache();
if (_locationDebounceCoroutine != null)
{
((MonoBehaviour)this).StopCoroutine(_locationDebounceCoroutine);
}
_locationDebounceCoroutine = ((MonoBehaviour)this).StartCoroutine(RefreshWeatherAfterDelay(val, 3f));
}))
{
flag2 = false;
}
if (flag2)
{
_settingsRegistered = true;
return true;
}
return false;
}
catch (Exception ex)
{
ManualLogSource log = ChillEnvPlugin.Log;
if (log != null)
{
log.LogError((object)("❌ [EnvSync] 注册设置时发生致命错误: " + ex.Message));
}
return false;
}
}
private bool AddToggleSafe(object managerInstance, Type managerType, string label, bool defaultValue, Action<bool> callback)
{
try
{
MethodInfo method = managerType.GetMethod("AddToggle", new Type[3]
{
typeof(string),
typeof(bool),
typeof(Action<bool>)
});
if (method == null)
{
ManualLogSource log = ChillEnvPlugin.Log;
if (log != null)
{
log.LogError((object)"❌ API Error: AddToggle method not found.");
}
return false;
}
Action<bool> action = delegate(bool value)
{
try
{
callback?.Invoke(value);
}
catch (Exception ex2)
{
ManualLogSource log3 = ChillEnvPlugin.Log;
if (log3 != null)
{
log3.LogError((object)("❌ 设置回调错误 (" + label + "): " + ex2.Message));
}
}
};
method.Invoke(managerInstance, new object[3] { label, defaultValue, action });
return true;
}
catch (Exception ex)
{
ManualLogSource log2 = ChillEnvPlugin.Log;
if (log2 != null)
{
log2.LogError((object)("❌ 添加开关失败 '" + label + "': " + ex.Message));
}
return false;
}
}
private bool AddInputFieldSafe(object managerInstance, Type managerType, string label, string initialValue, Action<string> callback)
{
try
{
MethodInfo method = managerType.GetMethod("AddInputField", new Type[3]
{
typeof(string),
typeof(string),
typeof(Action<string>)
});
if (method == null)
{
return false;
}
Action<string> action = delegate(string val)
{
try
{
callback?.Invoke(val);
}
catch (Exception arg)
{
Debug.LogError($"[EnvSync] Input callback error ({label}): {arg}");
}
};
method.Invoke(managerInstance, new object[3] { label, initialValue, action });
return true;
}
catch (Exception ex)
{
Debug.LogError("[EnvSync] Failed to add input field '" + label + "': " + ex.Message);
return false;
}
}
[IteratorStateMachine(typeof(<RefreshWeatherAfterDelay>d__8))]
private IEnumerator RefreshWeatherAfterDelay(string location, float delay)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <RefreshWeatherAfterDelay>d__8(0)
{
<>4__this = this,
location = location,
delay = delay
};
}
}
public static class UnlockConditionGodMode
{
public static void ApplyPatches(Harmony harmony)
{
//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
//IL_0108: Expected O, but got Unknown
//IL_0168: Unknown result type (might be due to invalid IL or missing references)
//IL_0176: Expected O, but got Unknown
try
{
ManualLogSource log = ChillEnvPlugin.Log;
if (log != null)
{
log.LogInfo((object)"\ud83d\udee1\ufe0f 正在部署上帝模式 (终极版)...");
}
Type type = AccessTools.TypeByName("Bulbul.UnlockConditionService");
Type type2 = null;
Type type3 = AccessTools.TypeByName("UnlockDecoration");
if (type3 != null)
{
MethodInfo methodInfo = AccessTools.Method(type3, "Purchase", (Type[])null, (Type[])null);
if (methodInfo != null)
{
ParameterInfo[] parameters = methodInfo.GetParameters();
if (parameters.Length != 0)
{
type2 = parameters[0].ParameterType;
ManualLogSource log2 = ChillEnvPlugin.Log;
if (log2 != null)
{
log2.LogInfo((object)("✅ 成功捕获 Enum: " + type2.Name));
}
}
}
}
if (type == null || type2 == null)
{
ManualLogSource log3 = ChillEnvPlugin.Log;
if (log3 != null)
{
log3.LogError((object)"❌ 类型解析失败,补丁取消。");
}
return;
}
MethodInfo methodInfo2 = AccessTools.Method(type, "IsUnlocked", (Type[])null, (Type[])null)?.MakeGenericMethod(type2);
MethodInfo method = typeof(UnlockConditionGodMode).GetMethod("IsUnlockedPrefix");
if (methodInfo2 != null)
{
harmony.Patch((MethodBase)methodInfo2, new HarmonyMethod(method), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
ManualLogSource log4 = ChillEnvPlugin.Log;
if (log4 != null)
{
log4.LogInfo((object)"✅ IsUnlocked 拦截成功");
}
}
MethodInfo methodInfo3 = AccessTools.Method(type, "IsPurchasableItem", (Type[])null, (Type[])null)?.MakeGenericMethod(type2);
MethodInfo method2 = typeof(UnlockConditionGodMode).GetMethod("IsPurchasablePrefix");
if (methodInfo3 != null)
{
harmony.Patch((MethodBase)methodInfo3, new HarmonyMethod(method2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
ManualLogSource log5 = ChillEnvPlugin.Log;
if (log5 != null)
{
log5.LogInfo((object)"✅ IsPurchasableItem 拦截成功");
}
}
}
catch (Exception arg)
{
ManualLogSource log6 = ChillEnvPlugin.Log;
if (log6 != null)
{
log6.LogError((object)$"❌ 上帝模式部署失败: {arg}");
}
}
}
public static bool IsUnlockedPrefix(ref (bool, bool) __result)
{
if (!ChillEnvPlugin.Cfg_UnlockDecorations.Value)
{
return true;
}
__result = (true, true);
return false;
}
public static bool IsPurchasablePrefix(ref int price, ref bool __result)
{
if (!ChillEnvPlugin.Cfg_UnlockPurchasableItems.Value)
{
return true;
}
price = 0;
__result = false;
return false;
}
}
}
namespace ChillWithYou.EnvSync.Models
{
[Serializable]
public class SunResponse
{
public List<SunResult> results;
}
[Serializable]
public class SunResult
{
public List<SunData> sun;
}
[Serializable]
public class SunData
{
public string date;
public string sunrise;
public string sunset;
}
public enum WeatherCondition
{
Clear,
Cloudy,
Rainy,
Snowy,
Foggy,
Unknown
}
public class WeatherInfo
{
public WeatherCondition Condition;
public int Temperature;
public string Text;
public int Code;
public DateTime UpdateTime;
public override string ToString()
{
return $"{Text}({Condition}), {Temperature}°C, Code={Code}";
}
}
[Serializable]
public class WeatherApiResponse
{
public WeatherResult[] results;
}
[Serializable]
public class WeatherResult
{
public WeatherLocation location;
public WeatherNow now;
}
[Serializable]
public class WeatherLocation
{
public string name;
}
[Serializable]
public class WeatherNow
{
public string text;
public string code;
public string temperature;
}
}
namespace ChillWithYou.EnvSync.Core
{
public class AutoEnvRunner : MonoBehaviour
{
[CompilerGenerated]
private sealed class <>c__DisplayClass11_0
{
public string targetDate;
}
[CompilerGenerated]
private sealed class <>c__DisplayClass11_1
{
public bool success;
public <>c__DisplayClass11_0 CS$<>8__locals1;
internal void <SyncSunScheduleRoutine>b__0(SunData data)
{
if (data != null)
{
ManualLogSource log = ChillEnvPlugin.Log;
if (log != null)
{
log.LogInfo((object)("[SunSync] 同步成功: 日出" + data.sunrise + " 日落" + data.sunset));
}
ChillEnvPlugin.Cfg_SunriseTime.Value = data.sunrise;
ChillEnvPlugin.Cfg_SunsetTime.Value = data.sunset;
ChillEnvPlugin.Cfg_LastSunSyncDate.Value = CS$<>8__locals1.targetDate;
((BaseUnityPlugin)ChillEnvPlugin.Instance).Config.Save();
success = true;
}
}
}
[CompilerGenerated]
private sealed class <SyncSunScheduleRoutine>d__11 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public string targetDate;
private <>c__DisplayClass11_0 <>8__1;
private <>c__DisplayClass11_1 <>8__2;
private int <retryCount>5__2;
private float <delay>5__3;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <SyncSunScheduleRoutine>d__11(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>8__1 = null;
<>8__2 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0110: Unknown result type (might be due to invalid IL or missing references)
//IL_011a: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>8__1 = new <>c__DisplayClass11_0();
<>8__1.targetDate = targetDate;
<retryCount>5__2 = 0;
<delay>5__3 = 1f;
break;
case 1:
{
<>1__state = -1;
if (<>8__2.success)
{
return false;
}
ManualLogSource log = ChillEnvPlugin.Log;
if (log != null)
{
log.LogWarning((object)$"[SunSync] 同步失败,{<delay>5__3}秒后重试 ({<retryCount>5__2 + 1}/{10})");
}
<>2__current = (object)new WaitForSeconds(<delay>5__3);
<>1__state = 2;
return true;
}
case 2:
<>1__state = -1;
<delay>5__3 *= 2f;
<retryCount>5__2++;
<>8__2 = null;
break;
}
if (<retryCount>5__2 < 10)
{
<>8__2 = new <>c__DisplayClass11_1();
<>8__2.CS$<>8__locals1 = <>8__1;
<>8__2.success = false;
string value = ChillEnvPlugin.Cfg_SeniverseKey.Value;
string value2 = ChillEnvPlugin.Cfg_Location.Value;
<>2__current = WeatherService.FetchSunSchedule(value, value2, delegate(SunData data)
{
if (data != null)
{
ManualLogSource log3 = ChillEnvPlugin.Log;
if (log3 != null)
{
log3.LogInfo((object)("[SunSync] 同步成功: 日出" + data.sunrise + " 日落" + data.sunset));
}
ChillEnvPlugin.Cfg_SunriseTime.Value = data.sunrise;
ChillEnvPlugin.Cfg_SunsetTime.Value = data.sunset;
ChillEnvPlugin.Cfg_LastSunSyncDate.Value = <>8__2.CS$<>8__locals1.targetDate;
((BaseUnityPlugin)ChillEnvPlugin.Instance).Config.Save();
<>8__2.success = true;
}
});
<>1__state = 1;
return true;
}
ManualLogSource log2 = ChillEnvPlugin.Log;
if (log2 != null)
{
log2.LogError((object)"[SunSync] 达到最大重试次数,今日放弃同步");
}
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
private float _nextWeatherCheckTime;
private float _nextTimeCheckTime;
private EnvironmentType? _lastAppliedEnv;
private bool _isFetching;
private bool _pendingForceRefresh;
private static AutoEnvRunner _instance;
private static readonly EnvironmentType[] BaseEnvironments;
private static readonly EnvironmentType[] SceneryWeathers;
private static readonly EnvironmentType[] MainEnvironments;
private void Start()
{
_instance = this;
_nextWeatherCheckTime = Time.time + 10f;
_nextTimeCheckTime = Time.time + 10f;
ManualLogSource log = ChillEnvPlugin.Log;
if (log != null)
{
log.LogInfo((object)"Runner 启动...");
}
CheckAndSyncSunSchedule();
}
private void CheckAndSyncSunSchedule()
{
if (ChillEnvPlugin.Cfg_EnableWeatherSync.Value)
{
string value = ChillEnvPlugin.Cfg_LastSunSyncDate.Value;
string text = DateTime.Now.ToString("yyyy-MM-dd");
if (value != text)
{
((MonoBehaviour)this).StartCoroutine(SyncSunScheduleRoutine(text));
}
}
}
[IteratorStateMachine(typeof(<SyncSunScheduleRoutine>d__11))]
private IEnumerator SyncSunScheduleRoutine(string targetDate)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <SyncSunScheduleRoutine>d__11(0)
{
targetDate = targetDate
};
}
private void Update()
{
if (!ChillEnvPlugin.Initialized || EnvRegistry.Count == 0)
{
return;
}
if (Input.GetKeyDown((KeyCode)290))
{
ManualLogSource log = ChillEnvPlugin.Log;
if (log != null)
{
log.LogInfo((object)"F9: 强制同步");
}
TriggerSync(forceApi: false, forceApply: true);
}
if (Input.GetKeyDown((KeyCode)289))
{
ShowStatus();
}
if (Input.GetKeyDown((KeyCode)288))
{
ManualLogSource log2 = ChillEnvPlugin.Log;
if (log2 != null)
{
log2.LogInfo((object)"F7: 强制刷新");
}
((BaseUnityPlugin)ChillEnvPlugin.Instance).Config.Reload();
ForceRefreshWeather();
}
if (Time.time >= _nextTimeCheckTime)
{
_nextTimeCheckTime = Time.time + 30f;
TriggerSync(forceApi: false, forceApply: false);
}
if (Time.time >= _nextWeatherCheckTime)
{
_nextWeatherCheckTime = Time.time + (float)Mathf.Max(1, ChillEnvPlugin.Cfg_WeatherRefreshMinutes.Value) * 60f;
TriggerSync(forceApi: true, forceApply: false);
}
}
private void ShowStatus()
{
DateTime now = DateTime.Now;
ManualLogSource log = ChillEnvPlugin.Log;
if (log != null)
{
log.LogInfo((object)$"--- 状态 [{now:HH:mm:ss}] ---");
}
ManualLogSource log2 = ChillEnvPlugin.Log;
if (log2 != null)
{
log2.LogInfo((object)$"插件记录: {_lastAppliedEnv}");
}
EnvironmentType? currentActiveEnvironment = GetCurrentActiveEnvironment();
ManualLogSource log3 = ChillEnvPlugin.Log;
if (log3 != null)
{
log3.LogInfo((object)$"游戏实际: {currentActiveEnvironment}");
}
ManualLogSource log4 = ChillEnvPlugin.Log;
if (log4 != null)
{
log4.LogInfo((object)("UI文本: " + ChillEnvPlugin.UIWeatherString));
}
if (ChillEnvPlugin.Cfg_DebugMode.Value)
{
ManualLogSource log5 = ChillEnvPlugin.Log;
if (log5 != null)
{
log5.LogWarning((object)"【警告】调试模式已开启!");
}
}
}
private void ForceRefreshWeather()
{
if (_isFetching)
{
_pendingForceRefresh = true;
ManualLogSource log = ChillEnvPlugin.Log;
if (log != null)
{
log.LogInfo((object)"ForceRefresh requested while fetching; queued until current fetch completes");
}
}
else
{
_nextWeatherCheckTime = Time.time + (float)ChillEnvPlugin.Cfg_WeatherRefreshMinutes.Value * 60f;
TriggerSync(forceApi: true, forceApply: false);
}
}
public static void TriggerWeatherRefresh()
{
if ((Object)(object)_instance != (Object)null)
{
ManualLogSource log = ChillEnvPlugin.Log;
if (log != null)
{
log.LogInfo((object)"\ud83d\udd04 外部触发天气刷新");
}
_instance.ForceRefreshWeather();
}
}
public static void TriggerSunScheduleRefresh()
{
if ((Object)(object)_instance != (Object)null)
{
ManualLogSource log = ChillEnvPlugin.Log;
if (log != null)
{
log.LogInfo((object)"\ud83c\udf05 外部触发日出日落刷新");
}
string targetDate = DateTime.Now.ToString("yyyy-MM-dd");
((MonoBehaviour)_instance).StartCoroutine(_instance.SyncSunScheduleRoutine(targetDate));
}
}
private void TriggerSync(bool forceApi, bool forceApply)
{
if (ChillEnvPlugin.Cfg_DebugMode.Value)
{
ManualLogSource log = ChillEnvPlugin.Log;
if (log != null)
{
log.LogInfo((object)$"TriggerSync called (forceApi={forceApi}, forceApply={forceApply})");
}
}
if (ChillEnvPlugin.Cfg_DebugMode.Value)
{
ManualLogSource log2 = ChillEnvPlugin.Log;
if (log2 != null)
{
log2.LogWarning((object)"[调试模式] 使用模拟数据...");
}
int value = ChillEnvPlugin.Cfg_DebugCode.Value;
WeatherInfo weather2 = new WeatherInfo
{
Code = value,
Temperature = ChillEnvPlugin.Cfg_DebugTemp.Value,
Text = ChillEnvPlugin.Cfg_DebugText.Value,
Condition = WeatherService.MapCodeToCondition(value),
UpdateTime = DateTime.Now
};
ApplyEnvironment(weather2, forceApply);
return;
}
bool value2 = ChillEnvPlugin.Cfg_EnableWeatherSync.Value;
string value3 = ChillEnvPlugin.Cfg_SeniverseKey.Value;
if (ChillEnvPlugin.Cfg_DebugMode.Value)
{
ManualLogSource log3 = ChillEnvPlugin.Log;
if (log3 != null)
{
log3.LogInfo((object)$"TriggerSync: EnableWeatherSync={value2}, ApiKeyPresent={!string.IsNullOrEmpty(value3)}, HasDefaultKey={WeatherService.HasDefaultKey}");
}
}
if (!value2)
{
if (forceApply || ChillEnvPlugin.Cfg_DebugMode.Value)
{
ManualLogSource log4 = ChillEnvPlugin.Log;
if (log4 != null)
{
log4.LogInfo((object)"TriggerSync aborted: Weather sync disabled");
}
}
return;
}
if (!value2 || (string.IsNullOrEmpty(value3) && !WeatherService.HasDefaultKey))
{
if (string.IsNullOrEmpty(value3) && !WeatherService.HasDefaultKey && (forceApply || ChillEnvPlugin.Cfg_DebugMode.Value))
{
ManualLogSource log5 = ChillEnvPlugin.Log;
if (log5 != null)
{
log5.LogInfo((object)"TriggerSync: No API key, using time-based fallback");
}
}
ApplyTimeBasedEnvironment(forceApply);
return;
}
string value4 = ChillEnvPlugin.Cfg_Location.Value;
if (forceApi || WeatherService.CachedWeather == null)
{
if (_isFetching)
{
ManualLogSource log6 = ChillEnvPlugin.Log;
if (log6 != null)
{
log6.LogWarning((object)"TriggerSync aborted: fetch already in progress");
}
return;
}
_isFetching = true;
if (ChillEnvPlugin.Cfg_DebugMode.Value)
{
ManualLogSource log7 = ChillEnvPlugin.Log;
if (log7 != null)
{
log7.LogInfo((object)"TriggerSync: starting WeatherService.FetchWeather");
}
}
((MonoBehaviour)this).StartCoroutine(WeatherService.FetchWeather(value3, value4, forceApi, delegate(WeatherInfo weather)
{
_isFetching = false;
if (weather != null)
{
ApplyEnvironment(weather, forceApply);
}
else
{
ManualLogSource log9 = ChillEnvPlugin.Log;
if (log9 != null)
{
log9.LogWarning((object)"[API异常] 启用时间兜底");
}
ApplyTimeBasedEnvironment(forceApply);
}
if (_pendingForceRefresh)
{
_pendingForceRefresh = false;
ForceRefreshWeather();
}
}));
return;
}
if (ChillEnvPlugin.Cfg_DebugMode.Value)
{
ManualLogSource log8 = ChillEnvPlugin.Log;
if (log8 != null)
{
log8.LogInfo((object)"TriggerSync: using cached weather");
}
}
ApplyEnvironment(WeatherService.CachedWeather, forceApply);
}
private EnvironmentType? GetCurrentActiveEnvironment()
{
//IL_0018: 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_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
try
{
Dictionary<WindowViewType, WindowViewData> windowViewDic = SaveDataManager.Instance.WindowViewDic;
EnvironmentType[] mainEnvironments = MainEnvironments;
for (int i = 0; i < mainEnvironments.Length; i++)
{
EnvironmentType value = mainEnvironments[i];
WindowViewType key = (WindowViewType)Enum.Parse(typeof(WindowViewType), ((object)(EnvironmentType)(ref value)).ToString());
if (windowViewDic.ContainsKey(key) && windowViewDic[key].IsActive)
{
return value;
}
}
}
catch
{
}
return null;
}
private bool IsEnvironmentActive(EnvironmentType env)
{
//IL_0027: 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_002e: 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)
try
{
Dictionary<WindowViewType, WindowViewData> windowViewDic = SaveDataManager.Instance.WindowViewDic;
WindowViewType key = (WindowViewType)Enum.Parse(typeof(WindowViewType), ((object)(EnvironmentType)(ref env)).ToString());
if (windowViewDic.ContainsKey(key))
{
return windowViewDic[key].IsActive;
}
}
catch
{
}
return false;
}
private void SimulateClick(EnvironmentType env)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
if (EnvRegistry.TryGet(env, out var ctrl))
{
ChillEnvPlugin.SimulateClickMainIcon(ctrl);
}
}
private bool IsBadWeather(int code)
{
if (code != 10)
{
switch (code)
{
case 13:
case 21:
case 22:
break;
case 4:
return true;
case 7:
case 8:
case 9:
case 10:
case 11:
case 12:
case 14:
case 15:
case 16:
case 17:
case 18:
case 19:
case 20:
case 23:
case 24:
case 25:
case 26:
case 27:
case 28:
case 29:
case 30:
case 31:
return true;
default:
if (code >= 34 && code <= 36)
{
return true;
}
return false;
}
}
return false;
}
private EnvironmentType? GetSceneryType(int code)
{
if (code >= 20 && code <= 25)
{
return (EnvironmentType)9;
}
switch (code)
{
case 11:
case 12:
case 16:
case 17:
case 18:
return (EnvironmentType)12;
default:
switch (code)
{
case 10:
case 14:
case 15:
return (EnvironmentType)11;
case 13:
case 19:
return (EnvironmentType)10;
default:
return null;
}
}
}
private EnvironmentType GetTimeBasedEnvironment()
{
TimeSpan timeOfDay = DateTime.Now.TimeOfDay;
TimeSpan.TryParse(ChillEnvPlugin.Cfg_SunriseTime.Value, out var result);
TimeSpan.TryParse(ChillEnvPlugin.Cfg_SunsetTime.Value, out var result2);
if (timeOfDay >= result && timeOfDay < result2.Subtract(TimeSpan.FromMinutes(30.0)))
{
return (EnvironmentType)0;
}
if (timeOfDay >= result2.Subtract(TimeSpan.FromMinutes(30.0)) && timeOfDay < result2.Add(TimeSpan.FromMinutes(30.0)))
{
return (EnvironmentType)1;
}
return (EnvironmentType)2;
}
private void ApplyBaseEnvironment(EnvironmentType target, bool force)
{
//IL_0004: 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_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_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: 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_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
if (!force && IsEnvironmentActive(target))
{
return;
}
EnvironmentType[] baseEnvironments = BaseEnvironments;
foreach (EnvironmentType val in baseEnvironments)
{
if (val != target && IsEnvironmentActive(val))
{
SimulateClick(val);
}
}
if (!IsEnvironmentActive(target))
{
SimulateClick(target);
}
ChillEnvPlugin.CallServiceChangeWeather(target);
ManualLogSource log = ChillEnvPlugin.Log;
if (log != null)
{
log.LogInfo((object)$"[环境] 切换至: {target}");
}
}
private void ApplyScenery(EnvironmentType? target, bool force)
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: 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_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: 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_004c: Unknown result type (might be due to invalid IL or missing references)
EnvironmentType[] sceneryWeathers = SceneryWeathers;
foreach (EnvironmentType val in sceneryWeathers)
{
bool flag = target.HasValue && target.Value == val;
bool flag2 = IsEnvironmentActive(val);
if (flag && !flag2)
{
SimulateClick(val);
ManualLogSource log = ChillEnvPlugin.Log;
if (log != null)
{
log.LogInfo((object)$"[景色] 开启: {val}");
}
}
else if (!flag && flag2)
{
SimulateClick(val);
}
}
}
private void ApplyEnvironment(WeatherInfo weather, bool force)
{
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: 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_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
//IL_00bd: Invalid comparison between Unknown and I4
//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
if (!ChillEnvPlugin.Cfg_EnableWeatherSync.Value)
{
if (ChillEnvPlugin.Cfg_DebugMode.Value)
{
ManualLogSource log = ChillEnvPlugin.Log;
if (log != null)
{
log.LogInfo((object)"[环境] 天气同步已关闭,跳过天气切换");
}
}
return;
}
if (SceneryAutomationSystem.IsWhaleSystemTriggered)
{
ManualLogSource log2 = ChillEnvPlugin.Log;
if (log2 != null)
{
log2.LogInfo((object)"[鲸鱼彩蛋] \ud83d\udc0b 系统抽中的鲸鱼生效中,跳过天气切换");
}
return;
}
if (force || !_lastAppliedEnv.HasValue)
{
ManualLogSource log3 = ChillEnvPlugin.Log;
if (log3 != null)
{
log3.LogInfo((object)$"[决策] 天气:{weather.Text}(Code:{weather.Code})");
}
}
ChillEnvPlugin.UIWeatherString = $"{weather.Text} {weather.Temperature}°C";
EnvironmentType timeBasedEnvironment = GetTimeBasedEnvironment();
EnvironmentType val = timeBasedEnvironment;
if (IsBadWeather(weather.Code) && (int)timeBasedEnvironment != 2)
{
val = (EnvironmentType)3;
}
ApplyBaseEnvironment(val, force);
ApplyScenery(GetSceneryType(weather.Code), force);
_lastAppliedEnv = val;
}
private void ApplyTimeBasedEnvironment(bool force)
{
//IL_0054: 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_005b: Unknown result type (might be due to invalid IL or missing references)
if (!ChillEnvPlugin.Cfg_EnableWeatherSync.Value)
{
if (ChillEnvPlugin.Cfg_DebugMode.Value)
{
ManualLogSource log = ChillEnvPlugin.Log;
if (log != null)
{
log.LogInfo((object)"[环境] 天气同步已关闭,跳过天气切换");
}
}
}
else if (SceneryAutomationSystem.IsWhaleSystemTriggered)
{
ManualLogSource log2 = ChillEnvPlugin.Log;
if (log2 != null)
{
log2.LogInfo((object)"[鲸鱼彩蛋] \ud83d\udc0b 系统抽中的鲸鱼生效中,跳过天气切换");
}
}
else
{
ChillEnvPlugin.UIWeatherString = "";
EnvironmentType timeBasedEnvironment = GetTimeBasedEnvironment();
ApplyBaseEnvironment(timeBasedEnvironment, force);
ApplyScenery(null, force);
}
}
static AutoEnvRunner()
{
EnvironmentType[] array = new EnvironmentType[4];
RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
BaseEnvironments = (EnvironmentType[])(object)array;
EnvironmentType[] array2 = new EnvironmentType[4];
RuntimeHelpers.InitializeArray(array2, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
SceneryWeathers = (EnvironmentType[])(object)array2;
EnvironmentType[] array3 = new EnvironmentType[8];
RuntimeHelpers.InitializeArray(array3, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
MainEnvironments = (EnvironmentType[])(object)array3;
}
}
public class SceneryAutomationSystem : MonoBehaviour
{
private class PendingAction
{
public bool TargetState;
public float VerifyTime;
public string RuleName;
}
private class SceneryRule
{
public EnvironmentType EnvType;
public Func<bool> Condition;
public string Name;
}
private enum Season
{
Spring,
Summer,
Autumn,
Winter
}
internal static HashSet<EnvironmentType> _autoEnabledMods = new HashSet<EnvironmentType>();
public static HashSet<EnvironmentType> UserInteractedMods = new HashSet<EnvironmentType>();
private Dictionary<EnvironmentType, float> _lastClickTime = new Dictionary<EnvironmentType, float>();
private Dictionary<EnvironmentType, PendingAction> _pendingActions = new Dictionary<EnvironmentType, PendingAction>();
private const float ClickCooldown = 2f;
private const float VerifyDelay = 0.5f;
private List<SceneryRule> _rules = new List<SceneryRule>();
private float _checkTimer;
private const float CheckInterval = 5f;
private const EnvironmentType Env_Fireworks = 4;
private const EnvironmentType Env_Cooking = 23;
private const EnvironmentType Env_AC = 32;
private const EnvironmentType Env_Sakura = 8;
private const EnvironmentType Env_Cicada = 27;
private const EnvironmentType Env_DeepSea = 5;
private const EnvironmentType Env_Space = 17;
private const EnvironmentType Env_Locomotive = 18;
private const EnvironmentType Env_Balloon = 14;
private const EnvironmentType Env_Books = 6;
private const EnvironmentType Env_BlueButterfly = 33;
private const EnvironmentType Env_WindBell = 7;
private const EnvironmentType Env_HotSpring = 16;
private const EnvironmentType Env_Whale = 15;
private Random _random = new Random();
private DateTime _lastDailyCheck = DateTime.MinValue;
private bool _windBellTriggeredToday;
private bool _windBellRollDoneToday;
private bool _hotSpringTriggeredToday;
private bool _hotSpringRollDoneToday;
private bool _whaleTriggeredToday;
private bool _whaleRollDoneToday;
private bool _spaceTriggeredToday;
private bool _spaceRollDoneToday;
private bool _blueButterflyTriggeredToday;
private DateTime _blueButterflyStartTime = DateTime.MinValue;
internal static bool IsWhaleSystemTriggered = false;
private void Start()
{
InitializeRules();
}
private void InitializeRules()
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: 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_00dc: Unknown result type (might be due to invalid IL or missing references)
//IL_0111: Unknown result type (might be due to invalid IL or missing references)
//IL_0146: Unknown result type (might be due to invalid IL or missing references)
//IL_017b: Unknown result type (might be due to invalid IL or missing references)
//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
//IL_022c: Unknown result type (might be due to invalid IL or missing references)
//IL_0260: Unknown result type (might be due to invalid IL or missing references)
//IL_0295: Unknown result type (might be due to invalid IL or missing references)
//IL_02ca: Unknown result type (might be due to invalid IL or missing references)
_rules.Add(new SceneryRule
{
Name = "Fireworks",
EnvType = (EnvironmentType)4,
Condition = delegate
{
DateTime now5 = DateTime.Now;
bool num5 = IsNight();
bool flag2 = now5.Month == 1 && now5.Day == 1;
bool flag3 = IsLunarNewYearPeriod(now5);
return num5 && (flag2 || flag3);
}
});
_rules.Add(new SceneryRule
{
Name = "CookingAudio",
EnvType = (EnvironmentType)23,
Condition = delegate
{
int hour = DateTime.Now.Hour;
int minute = DateTime.Now.Minute;
double num4 = (double)hour + (double)minute / 60.0;
return (num4 >= 11.5 && num4 <= 12.5) || (num4 >= 17.5 && num4 <= 18.5);
}
});
_rules.Add(new SceneryRule
{
Name = "AC_Audio",
EnvType = (EnvironmentType)32,
Condition = delegate
{
WeatherInfo cachedWeather2 = WeatherService.CachedWeather;
if (cachedWeather2 == null)
{
return false;
}
return cachedWeather2.Temperature > 30 || cachedWeather2.Temperature < 5;
}
});
_rules.Add(new SceneryRule
{
Name = "Sakura",
EnvType = (EnvironmentType)8,
Condition = () => GetSeason() == Season.Spring && IsDay() && IsGoodWeather()
});
_rules.Add(new SceneryRule
{
Name = "Cicadas",
EnvType = (EnvironmentType)27,
Condition = () => GetSeason() == Season.Summer && IsDay() && IsGoodWeather()
});
_rules.Add(new SceneryRule
{
Name = "Space",
EnvType = (EnvironmentType)17,
Condition = delegate
{
CheckDailyReset();
if (!IsNight() || !IsGoodWeather())
{
return false;
}
if (_spaceTriggeredToday)
{
return true;
}
if (!_spaceRollDoneToday)
{
_spaceRollDoneToday = true;
if (_random.NextDouble() < 0.01)
{
_spaceTriggeredToday = true;
return true;
}
}
return false;
}
});
_rules.Add(new SceneryRule
{
Name = "Locomotive",
EnvType = (EnvironmentType)18,
Condition = delegate
{
DateTime now4 = DateTime.Now;
return now4.Month == 12 && (now4.Day == 24 || now4.Day == 25) && IsNight() && IsGoodWeather();
}
});
_rules.Add(new SceneryRule
{
Name = "Balloon",
EnvType = (EnvironmentType)14,
Condition = delegate
{
DateTime now3 = DateTime.Now;
return now3.Month == 6 && now3.Day == 1 && IsDay() && IsGoodWeather();
}
});
_rules.Add(new SceneryRule
{
Name = "Books",
EnvType = (EnvironmentType)6,
Condition = delegate
{
DateTime now2 = DateTime.Now;
bool num3 = now2.Month == 4 && now2.Day == 23;
bool flag = now2.Month == 9 && now2.Day == 1;
return num3 || flag;
}
});
_rules.Add(new SceneryRule
{
Name = "BlueButterfly",
EnvType = (EnvironmentType)33,
Condition = delegate
{
CheckDailyReset();
DateTime now = DateTime.Now;
int month3 = now.Month;
if (month3 < 5 || month3 > 6 || !IsNight() || !IsGoodWeather())
{
return false;
}
if (_blueButterflyTriggeredToday)
{
if (_autoEnabledMods.Contains((EnvironmentType)33))
{
if ((DateTime.Now - _blueButterflyStartTime).TotalMinutes >= 20.0)
{
return false;
}
return true;
}
return false;
}
int num2 = (now.Hour * 60 + now.Minute) / 20;
if (new Random(now.Year * 10000 + now.DayOfYear * 100 + num2).NextDouble() < 0.15)
{
_blueButterflyTriggeredToday = true;
_blueButterflyStartTime = DateTime.Now;
return true;
}
return false;
}
});
_rules.Add(new SceneryRule
{
Name = "WindBell",
EnvType = (EnvironmentType)7,
Condition = delegate
{
CheckDailyReset();
int month2 = DateTime.Now.Month;
if (month2 < 7 || month2 > 8 || !IsGoodWeather())
{
return false;
}
if (_windBellTriggeredToday)
{
return true;
}
if (!_windBellRollDoneToday)
{
_windBellRollDoneToday = true;
if (_random.NextDouble() < 0.05)
{
_windBellTriggeredToday = true;
return true;
}
}
return false;
}
});
_rules.Add(new SceneryRule
{
Name = "HotSpring",
EnvType = (EnvironmentType)16,
Condition = delegate
{
CheckDailyReset();
int month = DateTime.Now.Month;
if (((month < 11 || month > 12) && (month < 1 || month > 2)) || !IsGoodWeather())
{
return false;
}
if (_hotSpringTriggeredToday)
{
return true;
}
if (!_hotSpringRollDoneToday)
{
_hotSpringRollDoneToday = true;
WeatherInfo cachedWeather = WeatherService.CachedWeather;
double num = ((cachedWeather != null && cachedWeather.Code >= 13 && cachedWeather.Code <= 17) ? 0.3 : 0.05);
if (_random.NextDouble() < num)
{
_hotSpringTriggeredToday = true;
return true;
}
}
return false;
}
});
_rules.Add(new SceneryRule
{
Name = "Whale",
EnvType = (EnvironmentType)15,
Condition = delegate
{
CheckDailyReset();
if (_whaleTriggeredToday)
{
return true;
}
if (!_whaleRollDoneToday)
{
_whaleRollDoneToday = true;
if (_random.NextDouble() < 0.0005)
{
_whaleTriggeredToday = true;
IsWhaleSystemTriggered = true;
ManualLogSource log = ChillEnvPlugin.Log;
if (log != null)
{
log.LogWarning((object)"[鲸鱼彩蛋] \ud83d\udc0b 系统抽中鲸鱼!保持当前时段...");
}
return true;
}
}
return false;
}
});
}
private void Update()
{
if (ChillEnvPlugin.Cfg_EnableEasterEggs.Value && ChillEnvPlugin.Initialized)
{
ProcessPendingActions();
_checkTimer += Time.deltaTime;
if (_checkTimer >= 5f)
{
_checkTimer = 0f;
RunAutomationLogic();
}
}
}
private void ProcessPendingActions()
{
//IL_0037: 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_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_0097: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_00f6: 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_0129: 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)
List<EnvironmentType> list = new List<EnvironmentType>();
foreach (KeyValuePair<EnvironmentType, PendingAction> pendingAction in _pendingActions)
{
if (!(Time.time >= pendingAction.Value.VerifyTime))
{
continue;
}
EnvironmentType key = pendingAction.Key;
PendingAction value = pendingAction.Value;
bool flag = IsEnvActive(key);
if (flag == value.TargetState)
{
if (value.TargetState)
{
_autoEnabledMods.Add(key);
ManualLogSource log = ChillEnvPlugin.Log;
if (log != null)
{
log.LogInfo((object)("[自动托管] ✓ 已开启: " + value.RuleName));
}
}
else
{
_autoEnabledMods.Remove(key);
ManualLogSource log2 = ChillEnvPlugin.Log;
if (log2 != null)
{
log2.LogInfo((object)("[自动托管] ✓ 已关闭: " + value.RuleName));
}
}
}
else
{
ManualLogSource log3 = ChillEnvPlugin.Log;
if (log3 != null)
{
log3.LogInfo((object)$"[自动托管] ✗ 状态验证失败: {value.RuleName} (期望={value.TargetState}, 实际={flag})");
}
}
list.Add(key);
}
foreach (EnvironmentType item in list)
{
_pendingActions.Remove(item);
}
}
private void RunAutomationLogic()
{
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: 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_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
//IL_00f7: 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_011a: Unknown result type (might be due to invalid IL or missing references)
//IL_013e: Unknown result type (might be due to invalid IL or missing references)
if (IsEnvActive((EnvironmentType)5))
{
CleanupAllAutoMods();
return;
}
foreach (EnvironmentType envType in new List<EnvironmentType>(_autoEnabledMods))
{
if (UserInteractedMods.Contains(envType))
{
_autoEnabledMods.Remove(envType);
}
else if (!_pendingActions.ContainsKey(envType))
{
SceneryRule sceneryRule = _rules.Find((SceneryRule r) => r.EnvType == envType);
if (sceneryRule != null && !sceneryRule.Condition())
{
DisableMod(sceneryRule.Name, envType);
}
}
}
foreach (SceneryRule rule in _rules)
{
if (!UserInteractedMods.Contains(rule.EnvType) && !_autoEnabledMods.Contains(rule.EnvType) && !_pendingActions.ContainsKey(rule.EnvType) && !IsEnvActive(rule.EnvType) && rule.Condition())
{
EnableMod(rule.Name, rule.EnvType);
}
}
}
private void EnableMod(string ruleName, EnvironmentType env)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: 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)
if (_lastClickTime.TryGetValue(env, out var value) && Time.time - value < 2f)
{
return;
}
EnvironmentController ctrl;
if (IsEnvActive(env))
{
_autoEnabledMods.Add(env);
ManualLogSource log = ChillEnvPlugin.Log;
if (log != null)
{
log.LogInfo((object)("[自动托管] ↻ 已是开启状态: " + ruleName));
}
}
else if (EnvRegistry.TryGet(env, out ctrl))
{
ManualLogSource log2 = ChillEnvPlugin.Log;
if (log2 != null)
{
log2.LogInfo((object)("[自动托管] → 点击开启: " + ruleName));
}
ChillEnvPlugin.SimulateClickMainIcon(ctrl);
_lastClickTime[env] = Time.time;
_pendingActions[env] = new PendingAction
{
TargetState = true,
VerifyTime = Time.time + 0.5f,
RuleName = ruleName
};
}
}
private void DisableMod(string ruleName, EnvironmentType env)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: 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)
if (_lastClickTime.TryGetValue(env, out var value) && Time.time - value < 2f)
{
return;
}
EnvironmentController ctrl;
if (!IsEnvActive(env))
{
_autoEnabledMods.Remove(env);
ManualLogSource log = ChillEnvPlugin.Log;
if (log != null)
{
log.LogInfo((object)("[自动托管] ↻ 已是关闭状态: " + ruleName));
}
}
else if (EnvRegistry.TryGet(env, out ctrl))
{
ManualLogSource log2 = ChillEnvPlugin.Log;
if (log2 != null)
{
log2.LogInfo((object)("[自动托管] → 点击关闭: " + ruleName));
}
ChillEnvPlugin.SimulateClickMainIcon(ctrl);
_lastClickTime[env] = Time.time;
_pendingActions[env] = new PendingAction
{
TargetState = false,
VerifyTime = Time.time + 0.5f,
RuleName = ruleName
};
}
}
private void CleanupAllAutoMods()
{
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
foreach (EnvironmentType env in new List<EnvironmentType>(_autoEnabledMods))
{
SceneryRule sceneryRule = _rules.Find((SceneryRule r) => r.EnvType == env);
if (sceneryRule != null)
{
DisableMod(sceneryRule.Name, env);
}
}
}
public bool IsAutoManaged(EnvironmentType type)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
return _autoEnabledMods.Contains(type);
}
private void CheckDailyReset()
{
DateTime today = DateTime.Today;
if (_lastDailyCheck.Date != today)
{
_lastDailyCheck = today;
_windBellTriggeredToday = false;
_windBellRollDoneToday = false;
_hotSpringTriggeredToday = false;
_hotSpringRollDoneToday = false;
_whaleTriggeredToday = false;
_whaleRollDoneToday = false;
_spaceTriggeredToday = false;
_spaceRollDoneToday = false;
_blueButterflyTriggeredToday = false;
IsWhaleSystemTriggered = false;
ManualLogSource log = ChillEnvPlugin.Log;
if (log != null)
{
log.LogDebug((object)"[每日重置] 概率触发标志已重置");
}
}
}
private bool IsEnvActive(EnvironmentType env)
{
//IL_0000: 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_012b: 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)
if (!EnvRegistry.TryGet(env, out var ctrl))
{
return false;
}
try
{
Type type = ((object)ctrl).GetType();
FieldInfo field = type.GetField("_ambientSoundBehavior", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
if (field != null)
{
object value = field.GetValue(ctrl);
if (value != null)
{
FieldInfo field2 = value.GetType().GetField("_volumeSlider", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
if (field2 != null)
{
object value2 = field2.GetValue(value);
if (value2 != null)
{
PropertyInfo property = value2.GetType().GetProperty("value");
if (property != null)
{
float num = (float)property.GetValue(value2);
ManualLogSource log = ChillEnvPlugin.Log;
if (log != null)
{
log.LogDebug((object)$"[状态检测] {env} Slider值={num:F3}");
}
return num > 0f;
}
}
}
}
}
FieldInfo field3 = type.GetField("_windowBehavior", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
if (field3 != null)
{
object value3 = field3.GetValue(ctrl);
if (value3 != null)
{
PropertyInfo property2 = value3.GetType().GetProperty("WindowViewType");
if (property2 != null)
{
WindowViewType key = (WindowViewType)property2.GetValue(value3);
if (SaveDataManager.Instance.WindowViewDic.TryGetValue(key, out var value4))
{
return value4.IsActive;
}
}
}
}
PropertyInfo property3 = type.GetProperty("IsActive", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
if (property3 != null)
{
return (bool)property3.GetValue(ctrl);
}
FieldInfo field4 = type.GetField("_isActive", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
if (field4 != null)
{
return (bool)field4.GetValue(ctrl);
}
}
catch (Exception ex)
{
ManualLogSource log2 = ChillEnvPlugin.Log;
if (log2 != null)
{
log2.LogError((object)("[CheckState] Error: " + ex.Message));
}
}
return false;
}
private Season GetSeason()
{
int month = DateTime.Now.Month;
if (month >= 3 && month <= 5)
{
return Season.Spring;
}
if (month >= 6 && month <= 8)
{
return Season.Summer;
}
if (month >= 9 && month <= 11)
{
return Season.Autumn;
}
return Season.Winter;
}
private bool IsDay()
{
int hour = DateTime.Now.Hour;
if (hour >= 6)
{
return hour < 18;
}
return false;
}
private bool IsNight()
{
int hour = DateTime.Now.Hour;
if (hour < 19)
{
return hour < 5;
}
return true;
}
private bool IsGoodWeather()
{
WeatherInfo cachedWeather = WeatherService.CachedWeather;
if (cachedWeather == null)
{
return true;
}
if (cachedWeather.Code >= 0)
{
return cachedWeather.Code <= 9;
}
return false;
}
private bool IsLunarNewYearPeriod(DateTime gregorianDate)
{
try
{
ChineseLunisolarCalendar chineseLunisolarCalendar = new ChineseLunisolarCalendar();
int month = chineseLunisolarCalendar.GetMonth(gregorianDate);
int dayOfMonth = chineseLunisolarCalendar.GetDayOfMonth(gregorianDate);
if (month == 1 && dayOfMonth >= 1 && dayOfMonth <= 5)
{
return true;
}
if (month == 12)
{
int year = chineseLunisolarCalendar.GetYear(gregorianDate);
int daysInMonth = chineseLunisolarCalendar.GetDaysInMonth(year, 12);
if (dayOfMonth == daysInMonth)
{
return true;
}
}
return false;
}
catch
{
return false;
}
}
}
}