Decompiled source of LivingSkies v1.0.3

HTFDayNight.dll

Decompiled 10 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.Rendering;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("HTFDayNight")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("HTFDayNight")]
[assembly: AssemblyTitle("HTFDayNight")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
[BepInPlugin("yoxi.htf.daynight", "HTF Day and Night", "1.0.0")]
public class DayNightPlugin : BaseUnityPlugin
{
	public const string Id = "yoxi.htf.daynight";

	internal static ManualLogSource Log;

	private ConfigEntry<float> _minutesPerDay;

	private ConfigEntry<KeyCode> _backKey;

	private ConfigEntry<KeyCode> _forwardKey;

	private ConfigEntry<float> _scrubSeconds;

	private ConfigEntry<float> _savedTime;

	private ConfigEntry<float> _savedOffset;

	private ConfigEntry<KeyCode> _resyncKey;

	private ConfigEntry<float> _nightSun;

	private ConfigEntry<string> _nightSunColor;

	private ConfigEntry<string> _nightFogColor;

	private ConfigEntry<float> _nightFogMul;

	private GameObject _skyPrefab;

	private GameObject _sky;

	private float _poll;

	private Func<double> _netClock;

	private void Awake()
	{
		Log = ((BaseUnityPlugin)this).Logger;
		_minutesPerDay = ((BaseUnityPlugin)this).Config.Bind<float>("Sky", "MinutesPerDay", 20f, "How many real minutes one full day (sunrise to sunrise) lasts.");
		_backKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Sky", "TimeBackKey", (KeyCode)276, "Hold to roll time backwards. Set to None to disable.");
		_forwardKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Sky", "TimeForwardKey", (KeyCode)275, "Hold to run time forwards. Set to None to disable.");
		_scrubSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("Sky", "TimeScrubSeconds", 8f, "Holding a time key crosses one whole day in this many real seconds.");
		_nightSun = ((BaseUnityPlugin)this).Config.Bind<float>("Night", "MoonlightIntensity", 0.35f, "Strength of the moonlight at full night.");
		_nightSunColor = ((BaseUnityPlugin)this).Config.Bind<string>("Night", "MoonlightColor", "#9EB3EB", "Hex colour of the moonlight.");
		_nightFogColor = ((BaseUnityPlugin)this).Config.Bind<string>("Night", "FogColor", "#080D1A", "Hex colour of the night fog above water. Underwater fog is never touched.");
		_nightFogMul = ((BaseUnityPlugin)this).Config.Bind<float>("Night", "FogDensityMultiplier", 2f, "Night fog density as a multiple of the day's.");
		_resyncKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Sky", "ResyncKey", (KeyCode)290, "Press to drop your personal time shift and rejoin the shared clock (or reset the arrow-key shift when playing offline).");
		_savedOffset = ((BaseUnityPlugin)this).Config.Bind<float>("Sky", "SavedTimeOffset", 0f, "Your arrow-key time shift. Offline it is folded into the saved clock; in a synced co-op game it shifts only YOUR view of the shared server time.");
		_savedTime = ((BaseUnityPlugin)this).Config.Bind<float>("Sky", "SavedTimeOfDay", 0.25f, "Where the clock stood when you last left the world (0..1, noon is 0.25). The day pauses while you are away and resumes here. Set it back to 0.25 to start a fresh day at noon.");
		string text = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "htfsky.bundle");
		if (!File.Exists(text))
		{
			Log.LogWarning((object)"htfsky.bundle is missing beside HTFDayNight.dll - the world keeps its endless day. Reinstall the mod so both files sit in the same folder.");
			return;
		}
		AssetBundle val = AssetBundle.LoadFromFile(text);
		if ((Object)(object)val == (Object)null)
		{
			Log.LogError((object)"htfsky.bundle would not load.");
			return;
		}
		GameObject[] array = val.LoadAllAssets<GameObject>();
		foreach (GameObject val2 in array)
		{
			if (((Object)val2).name == "NightSky")
			{
				_skyPrefab = val2;
				break;
			}
		}
		if ((Object)(object)_skyPrefab == (Object)null)
		{
			Log.LogError((object)"htfsky.bundle holds no NightSky prefab.");
		}
		else
		{
			Log.LogInfo((object)("The sky is loaded. Day and night will cycle over " + _minutesPerDay.Value + " real minutes."));
		}
	}

	private static Func<double> MakeNetClock()
	{
		try
		{
			Type type = Type.GetType("FishNet.InstanceFinder, FishNet.Runtime");
			if (type == null)
			{
				return null;
			}
			PropertyInfo tmProp = type.GetProperty("TimeManager", BindingFlags.Static | BindingFlags.Public);
			if (tmProp == null)
			{
				return null;
			}
			PropertyInfo tickProp = null;
			PropertyInfo deltaProp = null;
			return delegate
			{
				try
				{
					object value = tmProp.GetValue(null, null);
					if (value == null)
					{
						return -1.0;
					}
					if (tickProp == null)
					{
						tickProp = value.GetType().GetProperty("Tick");
						deltaProp = value.GetType().GetProperty("TickDelta");
					}
					if (tickProp == null || deltaProp == null)
					{
						return -1.0;
					}
					uint num = Convert.ToUInt32(tickProp.GetValue(value, null));
					if (num == 0)
					{
						return -1.0;
					}
					double num2 = Convert.ToDouble(deltaProp.GetValue(value, null));
					return (double)num * num2;
				}
				catch (Exception)
				{
					return -1.0;
				}
			};
		}
		catch (Exception)
		{
			return null;
		}
	}

	private void SaveClock()
	{
		if (!((Object)(object)_sky == (Object)null))
		{
			NightKeeper component = _sky.GetComponent<NightKeeper>();
			if ((Object)(object)component != (Object)null)
			{
				_savedTime.Value = component.TimeOfDay;
				_savedOffset.Value = component.TimeOffset;
			}
		}
	}

	private void OnApplicationQuit()
	{
		SaveClock();
	}

	private void OnDestroy()
	{
		SaveClock();
	}

	private void Update()
	{
		//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0116: Unknown result type (might be due to invalid IL or missing references)
		//IL_0118: Unknown result type (might be due to invalid IL or missing references)
		//IL_0137: Unknown result type (might be due to invalid IL or missing references)
		//IL_0139: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)_skyPrefab == (Object)null)
		{
			return;
		}
		_poll -= Time.deltaTime;
		if (_poll > 0f)
		{
			return;
		}
		_poll = 2f;
		bool flag = Object.FindObjectsByType<IslandManager>((FindObjectsInactive)0, (FindObjectsSortMode)0).Length != 0;
		if (flag && (Object)(object)_sky == (Object)null)
		{
			_sky = Object.Instantiate<GameObject>(_skyPrefab);
			((Object)_sky).name = "NightSky";
			Object.DontDestroyOnLoad((Object)(object)_sky);
			NightKeeper nightKeeper = _sky.AddComponent<NightKeeper>();
			nightKeeper.Cycle = true;
			nightKeeper.TimeOfDay = _savedTime.Value;
			nightKeeper.TimeOffset = _savedOffset.Value;
			nightKeeper.ResyncKey = _resyncKey.Value;
			nightKeeper.NightLightIntensity = _nightSun.Value;
			Color val = default(Color);
			if (ColorUtility.TryParseHtmlString(_nightSunColor.Value, ref val))
			{
				nightKeeper.NightLightColor = val;
			}
			if (ColorUtility.TryParseHtmlString(_nightFogColor.Value, ref val))
			{
				nightKeeper.NightFogColor = val;
			}
			nightKeeper.NightFogDensityMul = _nightFogMul.Value;
			nightKeeper.NetworkSeconds = _netClock ?? (_netClock = MakeNetClock());
			Log.LogInfo((object)((_netClock != null) ? "Co-op sync armed: time rides the FishNet server tick." : "No FishNet found - local clock only."));
			nightKeeper.DayMinutes = Mathf.Max(1f, _minutesPerDay.Value);
			nightKeeper.BackKey = _backKey.Value;
			nightKeeper.ForwardKey = _forwardKey.Value;
			nightKeeper.ScrubSeconds = Mathf.Max(1f, _scrubSeconds.Value);
			Log.LogInfo((object)"The wheel begins to turn.");
		}
		else if (!flag && (Object)(object)_sky != (Object)null)
		{
			SaveClock();
			Object.Destroy((Object)(object)_sky);
			_sky = null;
			Log.LogInfo((object)"The heavens rest until the next voyage.");
		}
	}
}
public class NightKeeper : MonoBehaviour
{
	private class CloudPaint
	{
		public Material M;

		public int[] Ids;

		public Color[] Day;

		public bool[] Disc;

		public float[] Weight;

		public byte[] Mode;

		public int DepthFadeId = -1;

		public float DepthFadeDay;
	}

	private class ProbeMemory
	{
		public ReflectionProbe P;

		public ReflectionProbeMode Mode;

		public Texture Baked;
	}

	public bool Cycle;

	public float DayMinutes = 20f;

	public KeyCode BackKey = (KeyCode)276;

	public KeyCode ForwardKey = (KeyCode)275;

	public KeyCode ResyncKey = (KeyCode)290;

	public float ScrubSeconds = 8f;

	private static int _inputMode;

	private bool _censusDone;

	public Func<double> NetworkSeconds;

	public Color NightLightColor = new Color(0.62f, 0.7f, 0.92f);

	public float NightLightIntensity = 0.35f;

	public Color NightFogColor = new Color(0.03f, 0.05f, 0.1f);

	public float NightFogDensityMul = 2f;

	private float _localT = 0.25f;

	private float _offset;

	private float _dayFogDensity;

	private float _t = 0.25f;

	private Light[] _lights = (Light[])(object)new Light[0];

	private readonly Dictionary<Light, Color> _dayColor = new Dictionary<Light, Color>();

	private readonly Dictionary<Light, Quaternion> _dayAim = new Dictionary<Light, Quaternion>();

	private readonly Dictionary<Light, float> _dayIntensity = new Dictionary<Light, float>();

	private readonly List<Renderer> _hiddenSky = new List<Renderer>();

	private Renderer[] _ours = (Renderer[])(object)new Renderer[0];

	private MaterialPropertyBlock _tint;

	private readonly List<CloudPaint> _clouds = new List<CloudPaint>();

	private readonly HashSet<Material> _cloudSeen = new HashSet<Material>();

	private readonly List<CloudPaint> _water = new List<CloudPaint>();

	private readonly HashSet<Material> _waterSeen = new HashSet<Material>();

	private Cubemap _envCube;

	private float _envTick;

	private DefaultReflectionMode _dayReflMode;

	private Texture _dayReflTexture;

	private bool _tookRefl;

	private readonly List<ProbeMemory> _probes = new List<ProbeMemory>();

	private readonly HashSet<ReflectionProbe> _probeSeen = new HashSet<ReflectionProbe>();

	private Color _skyNow = new Color(0.6f, 0.78f, 0.93f);

	private MaterialPropertyBlock _shade;

	private MaterialPropertyBlock _sunTint;

	private MaterialPropertyBlock _full;

	private readonly Dictionary<Camera, CameraClearFlags> _wasFlagsBy = new Dictionary<Camera, CameraClearFlags>();

	private readonly Dictionary<Camera, Color> _wasBackgroundBy = new Dictionary<Camera, Color>();

	private Material _wasSkybox;

	private float _rescan;

	private Color _dayAmbient;

	private float _dayAmbientStrength;

	private Color _dayFog;

	private float _dayReflection = 1f;

	private float _sunHeight = 1f;

	private bool _tookWorld;

	private static readonly Color NightSky = new Color(0.02f, 0.03f, 0.07f);

	private static readonly Vector3 PolarAxis = Vector3.Normalize(new Vector3(1f, 0f, 0.35f));

	private static readonly Vector3 SunHome = SunHomeDir();

	private static readonly Vector3 MoonHome = -SunHomeDir();

	private bool _photoSwap;

	private Color _photoAmbient;

	private float _photoAmbientStrength;

	private Color _photoFog;

	private float _photoReflStrength;

	private Texture _photoReflTexture;

	private DefaultReflectionMode _photoReflMode;

	private readonly Dictionary<Light, float> _photoIntensity = new Dictionary<Light, float>();

	private readonly Dictionary<Light, Color> _photoColor = new Dictionary<Light, Color>();

	private readonly Dictionary<Light, Quaternion> _photoAimWas = new Dictionary<Light, Quaternion>();

	private static ManualLogSource DayNightLogTarget => DayNightPlugin.Log;

	public float TimeOfDay
	{
		get
		{
			return _t;
		}
		set
		{
			_localT = Mathf.Repeat(value, 1f);
			_t = _localT;
		}
	}

	public float TimeOffset
	{
		get
		{
			return _offset;
		}
		set
		{
			_offset = Mathf.Repeat(value, 1f);
		}
	}

	private unsafe static bool Held(KeyCode key)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0003: Invalid comparison between Unknown and I4
		//IL_0021: 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)
		if ((int)key == 0)
		{
			return false;
		}
		if (_inputMode <= 1)
		{
			try
			{
				bool key2 = Input.GetKey(key);
				_inputMode = 1;
				return key2;
			}
			catch (Exception)
			{
				_inputMode = 2;
			}
		}
		if (_inputMode == 2)
		{
			try
			{
				Keyboard current = Keyboard.current;
				if (current == null)
				{
					return false;
				}
				if (!Enum.TryParse<Key>(((object)(*(KeyCode*)(&key))/*cast due to .constrained prefix*/).ToString(), ignoreCase: true, out Key result))
				{
					return false;
				}
				return ((ButtonControl)current[result]).isPressed;
			}
			catch (Exception)
			{
				_inputMode = -1;
			}
		}
		return false;
	}

	private static Vector3 SunHomeDir()
	{
		//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_0009: Unknown result type (might be due to invalid IL or missing references)
		return Vector3.down;
	}

	private float Nightness()
	{
		if (!Cycle)
		{
			return 1f;
		}
		if (_t < 0.03f)
		{
			return Mathf.SmoothStep(1f, 0f, (_t + 0.03f) / 0.06f);
		}
		if (_t < 0.47f)
		{
			return 0f;
		}
		if (_t < 0.53f)
		{
			return Mathf.SmoothStep(0f, 1f, (_t - 0.47f) / 0.06f);
		}
		if (_t < 0.97f)
		{
			return 1f;
		}
		return Mathf.SmoothStep(1f, 0f, (_t - 0.97f) / 0.06f);
	}

	private void LateUpdate()
	{
		//IL_0031: 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_0061: Unknown result type (might be due to invalid IL or missing references)
		//IL_0171: Unknown result type (might be due to invalid IL or missing references)
		//IL_0178: Expected O, but got Unknown
		//IL_0193: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_0264: Unknown result type (might be due to invalid IL or missing references)
		//IL_023f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0249: Expected O, but got Unknown
		//IL_0280: Unknown result type (might be due to invalid IL or missing references)
		//IL_028a: Expected O, but got Unknown
		//IL_0295: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f4: Expected O, but got Unknown
		//IL_03a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_03a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_03bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_03c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_03d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_03dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_03e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0374: Unknown result type (might be due to invalid IL or missing references)
		//IL_037e: Expected O, but got Unknown
		//IL_047a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0d5e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0d4d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0d63: Unknown result type (might be due to invalid IL or missing references)
		//IL_101e: Unknown result type (might be due to invalid IL or missing references)
		//IL_1023: Unknown result type (might be due to invalid IL or missing references)
		//IL_1059: Unknown result type (might be due to invalid IL or missing references)
		//IL_105e: Unknown result type (might be due to invalid IL or missing references)
		//IL_1063: Unknown result type (might be due to invalid IL or missing references)
		//IL_1065: Unknown result type (might be due to invalid IL or missing references)
		//IL_1067: Unknown result type (might be due to invalid IL or missing references)
		//IL_106c: Unknown result type (might be due to invalid IL or missing references)
		//IL_1071: Unknown result type (might be due to invalid IL or missing references)
		//IL_1073: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f0d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f12: Unknown result type (might be due to invalid IL or missing references)
		//IL_1103: Unknown result type (might be due to invalid IL or missing references)
		//IL_108f: Unknown result type (might be due to invalid IL or missing references)
		//IL_1081: Unknown result type (might be due to invalid IL or missing references)
		//IL_1083: Unknown result type (might be due to invalid IL or missing references)
		//IL_1088: Unknown result type (might be due to invalid IL or missing references)
		//IL_060c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0612: Invalid comparison between Unknown and I4
		//IL_0f8e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f9b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0fa8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0fb5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0fd2: Unknown result type (might be due to invalid IL or missing references)
		//IL_0fd4: Unknown result type (might be due to invalid IL or missing references)
		//IL_0fd7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f35: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f42: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f4f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f77: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f79: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f7d: Unknown result type (might be due to invalid IL or missing references)
		//IL_1091: Unknown result type (might be due to invalid IL or missing references)
		//IL_1094: Unknown result type (might be due to invalid IL or missing references)
		//IL_10a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_10b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_10cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_10d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_10d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_10de: Unknown result type (might be due to invalid IL or missing references)
		//IL_0db4: Unknown result type (might be due to invalid IL or missing references)
		//IL_0db9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0dbd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0dc2: Unknown result type (might be due to invalid IL or missing references)
		//IL_0dc4: Unknown result type (might be due to invalid IL or missing references)
		//IL_0dc9: Unknown result type (might be due to invalid IL or missing references)
		//IL_064e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ddb: Unknown result type (might be due to invalid IL or missing references)
		//IL_113a: Unknown result type (might be due to invalid IL or missing references)
		//IL_114e: Unknown result type (might be due to invalid IL or missing references)
		//IL_07bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_07c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_07c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_07c5: Invalid comparison between Unknown and I4
		//IL_07c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_07ca: Invalid comparison between Unknown and I4
		//IL_1160: Unknown result type (might be due to invalid IL or missing references)
		//IL_1165: Unknown result type (might be due to invalid IL or missing references)
		//IL_1167: Unknown result type (might be due to invalid IL or missing references)
		//IL_1178: Unknown result type (might be due to invalid IL or missing references)
		//IL_1189: Unknown result type (might be due to invalid IL or missing references)
		//IL_118e: Unknown result type (might be due to invalid IL or missing references)
		//IL_1194: Unknown result type (might be due to invalid IL or missing references)
		//IL_1199: Unknown result type (might be due to invalid IL or missing references)
		//IL_0e8b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0e90: Unknown result type (might be due to invalid IL or missing references)
		//IL_0e94: Unknown result type (might be due to invalid IL or missing references)
		//IL_0e99: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ab7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0abd: Invalid comparison between Unknown and I4
		//IL_0af9: Unknown result type (might be due to invalid IL or missing references)
		//IL_125c: Unknown result type (might be due to invalid IL or missing references)
		//IL_1265: Unknown result type (might be due to invalid IL or missing references)
		//IL_1267: Unknown result type (might be due to invalid IL or missing references)
		//IL_1206: Unknown result type (might be due to invalid IL or missing references)
		//IL_120c: Invalid comparison between Unknown and I4
		//IL_1365: Unknown result type (might be due to invalid IL or missing references)
		//IL_1210: Unknown result type (might be due to invalid IL or missing references)
		//IL_1216: Invalid comparison between Unknown and I4
		//IL_1393: Unknown result type (might be due to invalid IL or missing references)
		//IL_1398: Unknown result type (might be due to invalid IL or missing references)
		//IL_13d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_1405: Unknown result type (might be due to invalid IL or missing references)
		//IL_140b: Unknown result type (might be due to invalid IL or missing references)
		//IL_1415: Unknown result type (might be due to invalid IL or missing references)
		//IL_141a: Unknown result type (might be due to invalid IL or missing references)
		//IL_1447: Unknown result type (might be due to invalid IL or missing references)
		//IL_1537: Unknown result type (might be due to invalid IL or missing references)
		//IL_153c: Unknown result type (might be due to invalid IL or missing references)
		//IL_154d: Unknown result type (might be due to invalid IL or missing references)
		//IL_1552: Unknown result type (might be due to invalid IL or missing references)
		//IL_1230: Unknown result type (might be due to invalid IL or missing references)
		//IL_1245: Unknown result type (might be due to invalid IL or missing references)
		//IL_15e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_15e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_1937: Unknown result type (might be due to invalid IL or missing references)
		//IL_194b: Unknown result type (might be due to invalid IL or missing references)
		//IL_1951: Unknown result type (might be due to invalid IL or missing references)
		//IL_161a: Unknown result type (might be due to invalid IL or missing references)
		//IL_161f: Unknown result type (might be due to invalid IL or missing references)
		//IL_1622: Unknown result type (might be due to invalid IL or missing references)
		//IL_162c: Unknown result type (might be due to invalid IL or missing references)
		//IL_1631: Unknown result type (might be due to invalid IL or missing references)
		//IL_1640: Unknown result type (might be due to invalid IL or missing references)
		//IL_164a: Unknown result type (might be due to invalid IL or missing references)
		//IL_164f: Unknown result type (might be due to invalid IL or missing references)
		//IL_160f: Unknown result type (might be due to invalid IL or missing references)
		//IL_1619: Expected O, but got Unknown
		//IL_17d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_17d8: Invalid comparison between Unknown and I4
		//IL_1984: Unknown result type (might be due to invalid IL or missing references)
		//IL_19a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_19ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_184f: Unknown result type (might be due to invalid IL or missing references)
		//IL_1854: Unknown result type (might be due to invalid IL or missing references)
		//IL_180c: Unknown result type (might be due to invalid IL or missing references)
		//IL_183b: Unknown result type (might be due to invalid IL or missing references)
		//IL_166d: Unknown result type (might be due to invalid IL or missing references)
		//IL_166f: Unknown result type (might be due to invalid IL or missing references)
		//IL_1672: Invalid comparison between Unknown and I4
		//IL_18e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_18e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_18e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_19cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_19d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_19d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_19d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_19db: Unknown result type (might be due to invalid IL or missing references)
		//IL_1680: Unknown result type (might be due to invalid IL or missing references)
		//IL_1683: Invalid comparison between Unknown and I4
		//IL_167a: Unknown result type (might be due to invalid IL or missing references)
		//IL_167c: Unknown result type (might be due to invalid IL or missing references)
		//IL_18bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_18c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_1894: Unknown result type (might be due to invalid IL or missing references)
		//IL_1899: Unknown result type (might be due to invalid IL or missing references)
		//IL_189d: Unknown result type (might be due to invalid IL or missing references)
		//IL_18a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_1691: Unknown result type (might be due to invalid IL or missing references)
		//IL_1693: Unknown result type (might be due to invalid IL or missing references)
		//IL_169e: Unknown result type (might be due to invalid IL or missing references)
		//IL_16a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_168b: Unknown result type (might be due to invalid IL or missing references)
		//IL_168d: Unknown result type (might be due to invalid IL or missing references)
		//IL_1766: Unknown result type (might be due to invalid IL or missing references)
		//IL_176b: Unknown result type (might be due to invalid IL or missing references)
		//IL_18d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_16b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_16b6: Unknown result type (might be due to invalid IL or missing references)
		if (Cycle)
		{
			float num = 0f;
			float num2 = Time.deltaTime / Mathf.Max(1f, ScrubSeconds);
			if (Held(BackKey))
			{
				num -= num2;
			}
			if (Held(ForwardKey))
			{
				num += num2;
			}
			if (Held(ResyncKey))
			{
				_offset = 0f;
			}
			double num3 = ((NetworkSeconds != null) ? NetworkSeconds() : (-1.0));
			if (num3 >= 0.0)
			{
				_offset = Mathf.Repeat(_offset + num, 1f);
				_t = Mathf.Repeat((float)(num3 / ((double)DayMinutes * 60.0) % 1.0) + 0.25f + _offset, 1f);
			}
			else
			{
				_localT = Mathf.Repeat(_localT + Time.deltaTime / Mathf.Max(1f, DayMinutes * 60f) + num, 1f);
				_t = _localT;
			}
		}
		float num4 = Nightness();
		foreach (Transform item3 in ((Component)this).transform)
		{
			Transform val = item3;
			if (((Object)val).name == "Clouds")
			{
				val.Rotate(Vector3.up, Time.deltaTime * 0.45f, (Space)0);
			}
			else if (Cycle)
			{
				val.localRotation = Quaternion.AngleAxis((_t - 0.75f) * 360f, PolarAxis);
			}
			else
			{
				val.Rotate(Vector3.up, Time.deltaTime * 0.14f, (Space)0);
			}
		}
		float num5 = Mathf.Clamp01((num4 - 0.55f) / 0.45f);
		if (_tint == null)
		{
			_tint = new MaterialPropertyBlock();
		}
		_tint.SetColor("_Tint", new Color(1f, 1f, 1f, num5));
		if (_full == null)
		{
			_full = new MaterialPropertyBlock();
			_full.SetColor("_Tint", Color.white);
		}
		float num6 = Mathf.Sin(num4 * (float)Math.PI);
		num6 = num6 * num6 * 0.95f;
		float num7 = Mathf.SmoothStep(0f, 1f, Mathf.Clamp01((num4 - 0.4f) / 0.45f));
		if (_shade == null)
		{
			_shade = new MaterialPropertyBlock();
		}
		Renderer[] ours = _ours;
		foreach (Renderer val2 in ours)
		{
			if (!((Object)(object)val2 != (Object)null))
			{
				continue;
			}
			string name = ((Object)((Component)val2).gameObject).name;
			if (name == "Clouds")
			{
				val2.enabled = false;
			}
			else if (name.StartsWith("Sun"))
			{
				if (_sunTint == null)
				{
					_sunTint = new MaterialPropertyBlock();
				}
				float num8 = Mathf.Clamp01(1f - num5 / 0.3f);
				Color val3 = Color.Lerp(new Color(1f, 0.52f, 0.26f), Color.white, Mathf.Clamp01(_sunHeight * 1.3f));
				_sunTint.SetColor("_Tint", new Color(val3.r, val3.g, val3.b, num8));
				val2.enabled = num8 > 0.002f;
				val2.SetPropertyBlock(_sunTint);
			}
			else if (name == "DuskShade" || name == "NightShade")
			{
				float num9 = ((name == "DuskShade") ? num6 : num7);
				val2.enabled = num9 > 0.002f;
				_shade.SetColor("_Tint", new Color(1f, 1f, 1f, num9));
				val2.SetPropertyBlock(_shade);
			}
			else if (name.StartsWith("Storm"))
			{
				val2.enabled = true;
			}
			else
			{
				val2.enabled = num5 > 0.001f;
				val2.SetPropertyBlock(_tint);
			}
		}
		_rescan -= Time.deltaTime;
		if (_rescan <= 0f)
		{
			_rescan = 2f;
			Material[] array = Resources.FindObjectsOfTypeAll<Material>();
			foreach (Material val4 in array)
			{
				if ((Object)(object)val4 == (Object)null || (Object)(object)val4.shader == (Object)null || (((Object)val4.shader).name.IndexOf("water", StringComparison.OrdinalIgnoreCase) < 0 && ((Object)val4).name.IndexOf("water", StringComparison.OrdinalIgnoreCase) < 0 && ((Object)val4).name.IndexOf("ocean", StringComparison.OrdinalIgnoreCase) < 0) || !_waterSeen.Add(val4))
				{
					continue;
				}
				List<int> list = new List<int>();
				List<Color> list2 = new List<Color>();
				List<string> list3 = new List<string>();
				List<float> list4 = new List<float>();
				List<byte> list5 = new List<byte>();
				int propertyCount = val4.shader.GetPropertyCount();
				for (int k = 0; k < propertyCount; k++)
				{
					if ((int)val4.shader.GetPropertyType(k) == 0)
					{
						int propertyNameId = val4.shader.GetPropertyNameId(k);
						string propertyName = val4.shader.GetPropertyName(k);
						list.Add(propertyNameId);
						list2.Add(val4.GetColor(propertyNameId));
						list3.Add(propertyName);
						float item = 0.18f;
						if (propertyName.EndsWith("_1"))
						{
							item = 0.3f;
						}
						else if (propertyName.IndexOf("Foam", StringComparison.OrdinalIgnoreCase) >= 0 || propertyName.IndexOf("Specular", StringComparison.OrdinalIgnoreCase) >= 0)
						{
							item = 0.08f;
						}
						list4.Add(item);
						byte item2 = 1;
						if (propertyName.IndexOf("Min_Max", StringComparison.OrdinalIgnoreCase) >= 0)
						{
							item2 = 2;
						}
						else if (propertyName.IndexOf("Smoothstep", StringComparison.OrdinalIgnoreCase) >= 0 || propertyName.IndexOf("Alpha", StringComparison.OrdinalIgnoreCase) >= 0)
						{
							item2 = 0;
						}
						list5.Add(item2);
					}
				}
				if (_water.Count < 4)
				{
					DayNightLogTarget.LogInfo((object)("Water material '" + ((Object)val4).name + "' (" + ((Object)val4.shader).name + ") colours: " + string.Join(", ", list3.ToArray())));
					List<string> list6 = new List<string>();
					for (int l = 0; l < propertyCount; l++)
					{
						ShaderPropertyType propertyType = val4.shader.GetPropertyType(l);
						if ((int)propertyType == 2 || (int)propertyType == 3)
						{
							string propertyName2 = val4.shader.GetPropertyName(l);
							list6.Add(propertyName2 + "=" + val4.GetFloat(val4.shader.GetPropertyNameId(l)).ToString("0.###"));
						}
					}
					DayNightLogTarget.LogInfo((object)("Water material '" + ((Object)val4).name + "' floats: " + string.Join(", ", list6.ToArray())));
				}
				if (list.Count > 0)
				{
					CloudPaint cloudPaint = new CloudPaint();
					cloudPaint.M = val4;
					cloudPaint.Ids = list.ToArray();
					cloudPaint.Day = list2.ToArray();
					cloudPaint.Disc = new bool[list.Count];
					cloudPaint.Weight = list4.ToArray();
					cloudPaint.Mode = list5.ToArray();
					CloudPaint cloudPaint2 = cloudPaint;
					if (val4.HasProperty("_Depth_Fade_Distance"))
					{
						cloudPaint2.DepthFadeId = Shader.PropertyToID("_Depth_Fade_Distance");
						cloudPaint2.DepthFadeDay = val4.GetFloat(cloudPaint2.DepthFadeId);
					}
					_water.Add(cloudPaint2);
				}
			}
			_lights = Object.FindObjectsByType<Light>((FindObjectsInactive)0, (FindObjectsSortMode)0);
			_ours = ((Component)this).GetComponentsInChildren<Renderer>(true);
			Renderer[] array2 = Object.FindObjectsByType<Renderer>((FindObjectsInactive)0, (FindObjectsSortMode)0);
			foreach (Renderer val5 in array2)
			{
				if ((Object)(object)val5 == (Object)null || !val5.enabled || ((Component)val5).transform.IsChildOf(((Component)this).transform))
				{
					continue;
				}
				string name2 = ((Object)((Component)val5).gameObject).name;
				bool flag = name2 == "Sun" || name2.Contains("SunAndMoon");
				if ((Cycle && flag) || (num4 > 0.5f && flag))
				{
					val5.enabled = false;
					_hiddenSky.Add(val5);
				}
				else
				{
					if (!name2.Contains("Cloud"))
					{
						continue;
					}
					Material[] materials = val5.materials;
					foreach (Material val6 in materials)
					{
						if ((Object)(object)val6 == (Object)null || (Object)(object)val6.shader == (Object)null || !_cloudSeen.Add(val6))
						{
							continue;
						}
						List<int> list7 = new List<int>();
						List<Color> list8 = new List<Color>();
						List<bool> list9 = new List<bool>();
						List<string> list10 = new List<string>();
						int propertyCount2 = val6.shader.GetPropertyCount();
						for (int num10 = 0; num10 < propertyCount2; num10++)
						{
							if ((int)val6.shader.GetPropertyType(num10) == 0)
							{
								int propertyNameId2 = val6.shader.GetPropertyNameId(num10);
								string propertyName3 = val6.shader.GetPropertyName(num10);
								list7.Add(propertyNameId2);
								list8.Add(val6.GetColor(propertyNameId2));
								list9.Add(propertyName3.IndexOf("sun", StringComparison.OrdinalIgnoreCase) >= 0 || propertyName3.IndexOf("moon", StringComparison.OrdinalIgnoreCase) >= 0 || propertyName3.IndexOf("sss", StringComparison.OrdinalIgnoreCase) >= 0 || propertyName3.IndexOf("scatter", StringComparison.OrdinalIgnoreCase) >= 0);
								list10.Add(propertyName3);
							}
						}
						DayNightPlugin.Log.LogInfo((object)("Sky material '" + ((Object)val6).name + "' (" + ((Object)val6.shader).name + ") colours: " + string.Join(", ", list10.ToArray())));
						if (list7.Count > 0)
						{
							_clouds.Add(new CloudPaint
							{
								M = val6,
								Ids = list7.ToArray(),
								Day = list8.ToArray(),
								Disc = list9.ToArray()
							});
						}
					}
				}
			}
		}
		if (num4 <= 0.5f && _hiddenSky.Count > 0)
		{
			for (int num11 = _hiddenSky.Count - 1; num11 >= 0; num11--)
			{
				Renderer val7 = _hiddenSky[num11];
				if ((Object)(object)val7 == (Object)null)
				{
					_hiddenSky.RemoveAt(num11);
				}
				else
				{
					string name3 = ((Object)((Component)val7).gameObject).name;
					if (!Cycle || (!(name3 == "Sun") && !name3.Contains("SunAndMoon")))
					{
						val7.enabled = true;
						_hiddenSky.RemoveAt(num11);
					}
				}
			}
		}
		if (!_censusDone && num4 > 0.55f)
		{
			_censusDone = true;
			Vector3 val8 = (((Object)(object)Camera.main != (Object)null) ? ((Component)Camera.main).transform.position : ((Component)this).transform.position);
			Renderer[] array3 = Object.FindObjectsByType<Renderer>((FindObjectsInactive)0, (FindObjectsSortMode)0);
			foreach (Renderer val9 in array3)
			{
				if (!((Object)(object)val9 == (Object)null) && val9.enabled && !((Component)val9).transform.IsChildOf(((Component)this).transform))
				{
					Bounds bounds = val9.bounds;
					Vector3 val10 = ((Bounds)(ref bounds)).center - val8;
					if (!(((Vector3)(ref val10)).magnitude < 60f) && !(((Vector3)(ref val10)).normalized.y < 0.1f))
					{
						Material sharedMaterial = val9.sharedMaterial;
						ManualLogSource log = DayNightPlugin.Log;
						string[] obj = new string[8]
						{
							"In the sky at dusk: '",
							((Object)((Component)val9).gameObject).name,
							"' shader ",
							((Object)(object)sharedMaterial != (Object)null && (Object)(object)sharedMaterial.shader != (Object)null) ? ((Object)sharedMaterial.shader).name : "none",
							" material ",
							((Object)(object)sharedMaterial != (Object)null) ? ((Object)sharedMaterial).name : "none",
							" at ",
							null
						};
						bounds = val9.bounds;
						Vector3 center = ((Bounds)(ref bounds)).center;
						obj[7] = ((Vector3)(ref center)).ToString("0");
						log.LogInfo((object)string.Concat(obj));
					}
				}
			}
		}
		Color val12 = default(Color);
		Color val13 = default(Color);
		foreach (CloudPaint cloud in _clouds)
		{
			if ((Object)(object)cloud.M == (Object)null)
			{
				continue;
			}
			for (int num13 = 0; num13 < cloud.Ids.Length; num13++)
			{
				Color val11 = cloud.Day[num13];
				if (cloud.Disc[num13])
				{
					float num14 = Mathf.Clamp01(num4 / 0.1f);
					((Color)(ref val12))..ctor(val11.r * 0.02f, val11.g * 0.02f, val11.b * 0.04f, 0f);
					cloud.M.SetColor(cloud.Ids[num13], Color.Lerp(val11, val12, num14));
				}
				else
				{
					((Color)(ref val13))..ctor(val11.r * 0.1f, val11.g * 0.12f, val11.b * 0.22f, val11.a);
					cloud.M.SetColor(cloud.Ids[num13], Color.Lerp(val11, val13, num4));
				}
			}
		}
		Quaternion rotation = Quaternion.identity;
		float num15 = 1f;
		float num16 = 1f;
		bool cycle = Cycle;
		if (cycle)
		{
			Quaternion val14 = Quaternion.AngleAxis((_t - 0.75f) * 360f, PolarAxis);
			Vector3 val15 = val14 * SunHome;
			Vector3 val16 = ((val15.y >= 0f) ? val15 : (val14 * MoonHome));
			_sunHeight = val15.y;
			num15 = Mathf.Clamp01(val15.y * 2.2f);
			num16 = Mathf.Clamp01(Mathf.Abs(val15.y) * 3f);
			rotation = Quaternion.LookRotation(-((Vector3)(ref val16)).normalized);
		}
		Camera val17 = Eye();
		if ((Object)(object)val17 != (Object)null)
		{
			((Component)this).transform.position = ((Component)val17).transform.position;
		}
		if (Cycle || num4 > 0.35f)
		{
			Color val18 = Color.Lerp(new Color(0.96f, 0.52f, 0.24f), new Color(0.42f, 0.68f, 0.96f), cycle ? num15 : 1f);
			Color val19 = Color.Lerp(Color.Lerp(val18, new Color(0.38f, 0.22f, 0.34f), Mathf.Clamp01(num4 / 0.35f)), NightSky, num7);
			Camera[] allCameras = Camera.allCameras;
			foreach (Camera val20 in allCameras)
			{
				if ((Object)(object)val20 == (Object)null || !((Behaviour)val20).isActiveAndEnabled || (Object)(object)val20.targetTexture != (Object)null)
				{
					continue;
				}
				if (!_wasFlagsBy.ContainsKey(val20))
				{
					if ((int)val20.clearFlags != 1 && (int)val20.clearFlags != 2)
					{
						continue;
					}
					_wasFlagsBy[val20] = val20.clearFlags;
					_wasBackgroundBy[val20] = val20.backgroundColor;
				}
				val20.clearFlags = (CameraClearFlags)2;
				val20.backgroundColor = val19;
				_skyNow = val19;
			}
			if ((Object)(object)_wasSkybox == (Object)null && (Object)(object)RenderSettings.skybox != (Object)null)
			{
				_wasSkybox = RenderSettings.skybox;
				RenderSettings.skybox = null;
			}
		}
		else
		{
			GiveBackTheDay();
		}
		float num18 = Mathf.Max(num4, cycle ? (1f - num15) : 0f);
		foreach (CloudPaint item4 in _water)
		{
			if ((Object)(object)item4.M == (Object)null)
			{
				continue;
			}
			for (int num19 = 0; num19 < item4.Ids.Length; num19++)
			{
				float num20 = item4.Weight[num19];
				float num21 = Mathf.Clamp01((num4 - 0.15f) / 0.45f);
				if (item4.Mode[num19] == 0)
				{
					item4.M.SetColor(item4.Ids[num19], item4.Day[num19]);
					continue;
				}
				if (item4.Mode[num19] == 2)
				{
					Color val21 = item4.Day[num19];
					val21.r = Mathf.Lerp(item4.Day[num19].r, 0.96f, num21);
					item4.M.SetColor(item4.Ids[num19], val21);
					continue;
				}
				if (num20 > 0.1f)
				{
					num20 = Mathf.Lerp(num20, 0.92f, num21);
				}
				Color val22 = Color.Lerp(item4.Day[num19], _skyNow, num18 * num20);
				val22.a = item4.Day[num19].a;
				item4.M.SetColor(item4.Ids[num19], val22);
			}
		}
		float num22 = Mathf.Clamp01((num4 - 0.15f) / 0.45f);
		foreach (CloudPaint item5 in _water)
		{
			if ((Object)(object)item5.M != (Object)null && item5.DepthFadeId >= 0)
			{
				item5.M.SetFloat(item5.DepthFadeId, Mathf.Lerp(item5.DepthFadeDay, item5.DepthFadeDay * 0.12f, num22));
			}
		}
		if (!_tookWorld)
		{
			_dayAmbient = RenderSettings.ambientLight;
			_dayAmbientStrength = RenderSettings.ambientIntensity;
			_dayFog = RenderSettings.fogColor;
			_dayFogDensity = RenderSettings.fogDensity;
			_dayReflection = RenderSettings.reflectionIntensity;
			_tookWorld = true;
		}
		RenderSettings.reflectionIntensity = Mathf.Lerp(_dayReflection, _dayReflection * 0.85f, num4);
		_envTick -= Time.deltaTime;
		if (_envTick <= 0f)
		{
			_envTick = 0.25f;
			if (!_tookRefl)
			{
				_tookRefl = true;
				_dayReflMode = RenderSettings.defaultReflectionMode;
				_dayReflTexture = RenderSettings.customReflectionTexture;
			}
			if ((Object)(object)_envCube == (Object)null)
			{
				_envCube = new Cubemap(16, (TextureFormat)4, false);
			}
			Color skyNow = _skyNow;
			Color val23 = _skyNow * 0.55f;
			val23.a = 1f;
			Color val24 = _skyNow * 0.25f;
			val24.a = 1f;
			for (int num23 = 0; num23 < 6; num23++)
			{
				for (int num24 = 0; num24 < 16; num24++)
				{
					CubemapFace val25 = (CubemapFace)num23;
					Color val26 = (((int)val25 == 2) ? val23 : (((int)val25 != 3) ? Color.Lerp(val23, skyNow, (float)num24 / 15f) : val24));
					for (int num25 = 0; num25 < 16; num25++)
					{
						_envCube.SetPixel(val25, num25, num24, val26);
					}
				}
			}
			_envCube.Apply();
			RenderSettings.defaultReflectionMode = (DefaultReflectionMode)1;
			RenderSettings.customReflectionTexture = (Texture)(object)_envCube;
			ReflectionProbe[] array4 = Object.FindObjectsByType<ReflectionProbe>((FindObjectsInactive)0, (FindObjectsSortMode)0);
			foreach (ReflectionProbe val27 in array4)
			{
				if (!((Object)(object)val27 == (Object)null))
				{
					if (_probeSeen.Add(val27))
					{
						_probes.Add(new ProbeMemory
						{
							P = val27,
							Mode = val27.mode,
							Baked = val27.customBakedTexture
						});
					}
					val27.mode = (ReflectionProbeMode)2;
					val27.customBakedTexture = (Texture)(object)_envCube;
				}
			}
		}
		Light[] lights = _lights;
		foreach (Light val28 in lights)
		{
			if ((Object)(object)val28 == (Object)null || (int)val28.type != 1)
			{
				continue;
			}
			if (!_dayColor.ContainsKey(val28))
			{
				_dayColor[val28] = val28.color;
				_dayIntensity[val28] = val28.intensity;
				_dayAim[val28] = ((Component)val28).transform.rotation;
			}
			Color val29 = _dayColor[val28];
			float num28 = _dayIntensity[val28];
			if (cycle)
			{
				if (_sunHeight >= 0f)
				{
					val29 = Color.Lerp(new Color(1f, 0.62f, 0.3f), val29, num15);
					num28 *= 0.68f + 0.32f * num15;
				}
				else
				{
					val29 = NightLightColor;
					num28 *= 0.45f;
				}
				((Component)val28).transform.rotation = rotation;
			}
			val28.color = Color.Lerp(val29, NightLightColor, num4);
			val28.intensity = Mathf.Lerp(num28, NightLightIntensity, num4) * (cycle ? (0.15f + 0.85f * num16) : 1f);
		}
		RenderSettings.ambientLight = Color.Lerp(_dayAmbient, new Color(0.1f, 0.12f, 0.2f), num4);
		RenderSettings.ambientIntensity = Mathf.Lerp(_dayAmbientStrength, 0.35f, num4);
		if (!((Object)(object)val17 != (Object)null) || !(((Component)val17).transform.position.y < -0.9f))
		{
			Color val30 = Color.Lerp(_dayFog, _skyNow, cycle ? ((1f - num15) * 0.85f) : 0f);
			RenderSettings.fogColor = Color.Lerp(val30, NightFogColor, num4);
			RenderSettings.fogDensity = Mathf.Lerp(_dayFogDensity, _dayFogDensity * Mathf.Max(0.1f, NightFogDensityMul), num4);
		}
	}

	private static Camera Eye()
	{
		Camera val = null;
		Camera[] allCameras = Camera.allCameras;
		foreach (Camera val2 in allCameras)
		{
			if (!((Object)(object)val2 == (Object)null) && ((Behaviour)val2).isActiveAndEnabled && !((Object)(object)val2.targetTexture != (Object)null) && ((Object)(object)val == (Object)null || val2.depth > val.depth))
			{
				val = val2;
			}
		}
		return ((Object)(object)val != (Object)null) ? val : Camera.main;
	}

	private void OnEnable()
	{
		RenderPipelineManager.beginCameraRendering += DaylightForPhotos;
		RenderPipelineManager.endCameraRendering += NightAfterPhotos;
	}

	private void OnDisable()
	{
		RenderPipelineManager.beginCameraRendering -= DaylightForPhotos;
		RenderPipelineManager.endCameraRendering -= NightAfterPhotos;
	}

	private void DaylightForPhotos(ScriptableRenderContext ctx, Camera cam)
	{
		//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_004b: 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_006c: 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_0077: Unknown result type (might be due to invalid IL or missing references)
		//IL_008f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a7: 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_016e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0174: Invalid comparison between Unknown and I4
		//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0201: Unknown result type (might be due to invalid IL or missing references)
		//IL_0225: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)cam == (Object)null || (Object)(object)cam.targetTexture == (Object)null || !_tookWorld)
		{
			return;
		}
		_photoSwap = true;
		_photoAmbient = RenderSettings.ambientLight;
		_photoAmbientStrength = RenderSettings.ambientIntensity;
		_photoFog = RenderSettings.fogColor;
		_photoReflStrength = RenderSettings.reflectionIntensity;
		_photoReflTexture = RenderSettings.customReflectionTexture;
		_photoReflMode = RenderSettings.defaultReflectionMode;
		RenderSettings.ambientLight = _dayAmbient;
		RenderSettings.ambientIntensity = _dayAmbientStrength;
		RenderSettings.fogColor = _dayFog;
		RenderSettings.reflectionIntensity = _dayReflection;
		RenderSettings.defaultReflectionMode = _dayReflMode;
		RenderSettings.customReflectionTexture = _dayReflTexture;
		foreach (ProbeMemory probe in _probes)
		{
			if ((Object)(object)probe.P != (Object)null)
			{
				probe.P.mode = probe.Mode;
				probe.P.customBakedTexture = probe.Baked;
			}
		}
		_photoIntensity.Clear();
		_photoColor.Clear();
		_photoAimWas.Clear();
		Light[] lights = _lights;
		foreach (Light val in lights)
		{
			if (!((Object)(object)val == (Object)null) && (int)val.type == 1)
			{
				_photoIntensity[val] = val.intensity;
				_photoColor[val] = val.color;
				_photoAimWas[val] = ((Component)val).transform.rotation;
				if (_dayIntensity.TryGetValue(val, out var value))
				{
					val.intensity = value;
				}
				if (_dayColor.TryGetValue(val, out var value2))
				{
					val.color = value2;
				}
				if (_dayAim.TryGetValue(val, out var value3))
				{
					((Component)val).transform.rotation = value3;
				}
			}
		}
	}

	private void NightAfterPhotos(ScriptableRenderContext ctx, Camera cam)
	{
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_004a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0062: Unknown result type (might be due to invalid IL or missing references)
		//IL_0104: Unknown result type (might be due to invalid IL or missing references)
		//IL_0163: Unknown result type (might be due to invalid IL or missing references)
		if (!_photoSwap || (Object)(object)cam == (Object)null || (Object)(object)cam.targetTexture == (Object)null)
		{
			return;
		}
		_photoSwap = false;
		RenderSettings.ambientLight = _photoAmbient;
		RenderSettings.ambientIntensity = _photoAmbientStrength;
		RenderSettings.fogColor = _photoFog;
		RenderSettings.reflectionIntensity = _photoReflStrength;
		RenderSettings.defaultReflectionMode = _photoReflMode;
		RenderSettings.customReflectionTexture = _photoReflTexture;
		foreach (KeyValuePair<Light, float> item in _photoIntensity)
		{
			if ((Object)(object)item.Key != (Object)null)
			{
				item.Key.intensity = item.Value;
			}
		}
		foreach (KeyValuePair<Light, Color> item2 in _photoColor)
		{
			if ((Object)(object)item2.Key != (Object)null)
			{
				item2.Key.color = item2.Value;
			}
		}
		foreach (KeyValuePair<Light, Quaternion> photoAimWa in _photoAimWas)
		{
			if ((Object)(object)photoAimWa.Key != (Object)null)
			{
				((Component)photoAimWa.Key).transform.rotation = photoAimWa.Value;
			}
		}
		foreach (ProbeMemory probe in _probes)
		{
			if ((Object)(object)probe.P != (Object)null && (Object)(object)_envCube != (Object)null)
			{
				probe.P.mode = (ReflectionProbeMode)2;
				probe.P.customBakedTexture = (Texture)(object)_envCube;
			}
		}
	}

	private void GiveBackTheDay()
	{
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_008b: Unknown result type (might be due to invalid IL or missing references)
		foreach (KeyValuePair<Camera, CameraClearFlags> item in _wasFlagsBy)
		{
			if ((Object)(object)item.Key != (Object)null)
			{
				item.Key.clearFlags = item.Value;
			}
		}
		foreach (KeyValuePair<Camera, Color> item2 in _wasBackgroundBy)
		{
			if ((Object)(object)item2.Key != (Object)null)
			{
				item2.Key.backgroundColor = item2.Value;
			}
		}
		_wasFlagsBy.Clear();
		_wasBackgroundBy.Clear();
		if ((Object)(object)_wasSkybox != (Object)null)
		{
			RenderSettings.skybox = _wasSkybox;
			_wasSkybox = null;
		}
	}

	private void OnDestroy()
	{
		//IL_008f: Unknown result type (might be due to invalid IL or missing references)
		//IL_011c: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0281: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_02fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_034c: Unknown result type (might be due to invalid IL or missing references)
		foreach (Renderer item in _hiddenSky)
		{
			if ((Object)(object)item != (Object)null)
			{
				item.enabled = true;
			}
		}
		foreach (CloudPaint cloud in _clouds)
		{
			if ((Object)(object)cloud.M != (Object)null)
			{
				for (int i = 0; i < cloud.Ids.Length; i++)
				{
					cloud.M.SetColor(cloud.Ids[i], cloud.Day[i]);
				}
			}
		}
		foreach (CloudPaint item2 in _water)
		{
			if ((Object)(object)item2.M != (Object)null)
			{
				for (int j = 0; j < item2.Ids.Length; j++)
				{
					item2.M.SetColor(item2.Ids[j], item2.Day[j]);
				}
				if (item2.DepthFadeId >= 0)
				{
					item2.M.SetFloat(item2.DepthFadeId, item2.DepthFadeDay);
				}
			}
		}
		GiveBackTheDay();
		foreach (KeyValuePair<Light, Color> item3 in _dayColor)
		{
			if ((Object)(object)item3.Key != (Object)null)
			{
				item3.Key.color = item3.Value;
			}
		}
		foreach (KeyValuePair<Light, float> item4 in _dayIntensity)
		{
			if ((Object)(object)item4.Key != (Object)null)
			{
				item4.Key.intensity = item4.Value;
			}
		}
		foreach (KeyValuePair<Light, Quaternion> item5 in _dayAim)
		{
			if ((Object)(object)item5.Key != (Object)null)
			{
				((Component)item5.Key).transform.rotation = item5.Value;
			}
		}
		if (_tookWorld)
		{
			RenderSettings.ambientLight = _dayAmbient;
			RenderSettings.ambientIntensity = _dayAmbientStrength;
			RenderSettings.fogColor = _dayFog;
			RenderSettings.fogDensity = _dayFogDensity;
			RenderSettings.reflectionIntensity = _dayReflection;
		}
		if (_tookRefl)
		{
			RenderSettings.defaultReflectionMode = _dayReflMode;
			RenderSettings.customReflectionTexture = _dayReflTexture;
		}
		foreach (ProbeMemory probe in _probes)
		{
			if ((Object)(object)probe.P != (Object)null)
			{
				probe.P.mode = probe.Mode;
				probe.P.customBakedTexture = probe.Baked;
			}
		}
	}
}

HTFWeather.dll

Decompiled 10 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.Networking;
using UnityEngine.Rendering;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("HTFWeather")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("HTFWeather")]
[assembly: AssemblyTitle("HTFWeather")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
[BepInPlugin("yoxi.htf.weather", "HTF Weather", "1.0.0")]
public class WeatherPlugin : BaseUnityPlugin
{
	public const string Id = "yoxi.htf.weather";

	internal static ManualLogSource Log;

	private ConfigEntry<float> _volume;

	private ConfigEntry<bool> _thunder;

	private ConfigEntry<bool> _lightning;

	private GameObject _rig;

	private float _poll;

	private void Awake()
	{
		Log = ((BaseUnityPlugin)this).Logger;
		_volume = ((BaseUnityPlugin)this).Config.Bind<float>("Weather", "Volume", 0.7f, "Weather audio volume (0 = silent).");
		_thunder = ((BaseUnityPlugin)this).Config.Bind<bool>("Weather", "ThunderSounds", true, "Play thunder. Off = storms stay silent (visuals unchanged).");
		_lightning = ((BaseUnityPlugin)this).Config.Bind<bool>("Weather", "LightningStrikes", true, "Lightning strikes and flashes. Off = no bolts, no flashes, no thunder from strikes.");
	}

	private void Update()
	{
		//IL_0060: Unknown result type (might be due to invalid IL or missing references)
		//IL_006a: Expected O, but got Unknown
		_poll -= Time.deltaTime;
		if (_poll > 0f)
		{
			return;
		}
		_poll = 2f;
		bool flag = Object.FindObjectsByType<IslandManager>((FindObjectsInactive)0, (FindObjectsSortMode)0).Length != 0;
		if (flag && (Object)(object)_rig == (Object)null)
		{
			_rig = new GameObject("HTFWeather");
			Object.DontDestroyOnLoad((Object)(object)_rig);
			WeatherKeeper weatherKeeper = _rig.AddComponent<WeatherKeeper>();
			weatherKeeper.Volume = Mathf.Clamp01(_volume.Value);
			weatherKeeper.ThunderOn = _thunder.Value;
			weatherKeeper.LightningOn = _lightning.Value;
			weatherKeeper.SavePrefs = delegate(float vol, bool th, bool li)
			{
				_volume.Value = Mathf.Clamp01(vol);
				_thunder.Value = th;
				_lightning.Value = li;
			};
			Log.LogInfo((object)"Weather rig deployed.");
		}
		else if (!flag && (Object)(object)_rig != (Object)null)
		{
			Object.Destroy((Object)(object)_rig);
			_rig = null;
			Log.LogInfo((object)"Weather stands down.");
		}
	}
}
[DefaultExecutionOrder(500)]
public class WeatherKeeper : MonoBehaviour
{
	public float StormChance = 0.3f;

	public float EpochSeconds = 480f;

	public float Intensity = 1f;

	public float Volume = 0.7f;

	public bool ThunderOn = true;

	public bool LightningOn = true;

	public Action<float, bool, bool> SavePrefs;

	private bool _devMenu;

	private int _state;

	public int Override = -1;

	private bool _menuOpen;

	private CursorLockMode _wasLock;

	private bool _wasCursor;

	private Rect _menuRect = new Rect(60f, 60f, 370f, 360f);

	private float _w;

	private Func<double> _clock;

	private double _localClock;

	private ParticleSystem _rain;

	private ParticleSystem _splash;

	private ParticleSystem _spray;

	private float _splashBudget;

	private ParticleSystemRenderer _rainRenderer;

	private GameObject _veilRoot;

	private Material _veilMat;

	private float _veilSpin;

	private bool _debugOpen;

	private AudioSource _rainA;

	private AudioSource _rainB;

	private AudioSource _stormLayer;

	private AudioSource _wind;

	private AudioLowPassFilter _rainFilter;

	private AudioSource _thunderVoice;

	private readonly List<AudioClip> _thunderFiles = new List<AudioClip>();

	private bool _realRain;

	private bool _realStorm;

	private bool _realWind;

	private float _lastDelay = 2f;

	private float _nextStrike = 12f;

	private const float FlashTime = 0.45f;

	private float _flash;

	private Light _flashLight;

	private float _pendingThunder = -1f;

	private Color _overcastNow = new Color(0.52f, 0.54f, 0.58f);

	private Transform _deckA;

	private Transform _deckB;

	private MeshRenderer _shadeR;

	private MeshRenderer _deckAR;

	private MeshRenderer _deckBR;

	private Material _shadeMat;

	private Material _deckAMat;

	private Material _deckBMat;

	private float _skySearch;

	private float _spinA;

	private float _spinB;

	private Vector3 _boltTop;

	private Vector3 _gale;

	private float _flashScale = 1f;

	private float _sheetTimer = 18f;

	private float _reFlash = -1f;

	private Vector3 _stormCenter;

	private bool _centerSet;

	private float _localK = 1f;

	private bool _tookFogLine;

	private bool _baseFogOn;

	private float _baseFogStart;

	private float _baseFogEnd;

	private float _lidA;

	private bool _truthLogged;

	private float _footprint = 380f;

	private double _nowSeconds;

	private static Type _nkType;

	private Component _nightKeeperRef;

	private PropertyInfo _nkTime;

	private PropertyInfo _nkOffset;

	private float _nkSearch;

	private int _segIndex = -1;

	private double _segStart;

	private double _segEnd;

	private float _lastClearLen = -1f;

	private LineRenderer _bolt;

	private LineRenderer _branchA;

	private LineRenderer _branchB;

	private Material _boltMat;

	private bool _tookBase;

	private readonly Dictionary<Light, float> _baseIntensity = new Dictionary<Light, float>();

	private float _baseFogDensity;

	private Color _baseFogColor;

	private Color _baseAmbient;

	private float _baseAmbientStrength;

	private bool _dayNightPresent;

	private float _rescan;

	private Light[] _lights = (Light[])(object)new Light[0];

	private static readonly long DaySalt = (long)(DateTime.UtcNow.Date - new DateTime(2020, 1, 1)).TotalDays * 7919;

	private static bool _waterHeightBroken;

	private static MethodInfo _setData;

	private static int _inputMode;

	private Rect _playerRect = new Rect(60f, 60f, 300f, 210f);

	private GUISkin _skin;

	private GUIStyle _clockStyle;

	private void Start()
	{
		_clock = MakeNetClock();
		BuildRain();
		BuildAudio();
	}

	private int StateOfEpoch(long epoch)
	{
		if ((epoch & 1) == 0)
		{
			return 0;
		}
		ulong num = (ulong)((epoch + DaySalt) * 2654435761u + -7046029254386353131L);
		num ^= num >> 29;
		num *= 13787848793156543929uL;
		num ^= num >> 32;
		float num2 = (float)(num % 10000) / 10000f;
		if (num2 < 0.35f)
		{
			return 2;
		}
		if (num2 < 0.7f)
		{
			return 1;
		}
		return 0;
	}

	private float DurOf(int st)
	{
		return st switch
		{
			1 => 150f, 
			2 => 120f, 
			_ => Mathf.Max(120f, EpochSeconds), 
		};
	}

	private int StateAt(double seconds)
	{
		if (_segIndex < 0 || seconds < _segStart || _lastClearLen != EpochSeconds)
		{
			_lastClearLen = EpochSeconds;
			_segIndex = 0;
			_segStart = 0.0;
			_segEnd = DurOf(StateOfEpoch(0L));
		}
		while (seconds >= _segEnd)
		{
			_segIndex++;
			_segStart = _segEnd;
			_segEnd += DurOf(StateOfEpoch(_segIndex));
		}
		return StateOfEpoch(_segIndex);
	}

	private bool DarkEnough()
	{
		//IL_009c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a6: Expected O, but got Unknown
		try
		{
			if ((Object)(object)_nightKeeperRef == (Object)null)
			{
				_nkSearch -= Time.deltaTime;
				if (_nkSearch > 0f)
				{
					return true;
				}
				_nkSearch = 5f;
				if (_nkType == null)
				{
					_nkType = Type.GetType("NightKeeper, HTFDayNight") ?? Type.GetType("NightKeeper, HTFMapLoader");
				}
				if (_nkType == null)
				{
					return true;
				}
				_nightKeeperRef = (Component)Object.FindFirstObjectByType(_nkType);
				if ((Object)(object)_nightKeeperRef == (Object)null)
				{
					return true;
				}
				_nkTime = _nkType.GetProperty("TimeOfDay");
				_nkOffset = _nkType.GetProperty("TimeOffset");
			}
			if (_nkTime == null)
			{
				return true;
			}
			float num = (float)_nkTime.GetValue(_nightKeeperRef, null);
			if (_nkOffset != null)
			{
				num -= (float)_nkOffset.GetValue(_nightKeeperRef, null);
			}
			num = Mathf.Repeat(num, 1f);
			return num >= 0.44f || num <= 0.02f;
		}
		catch (Exception)
		{
			return true;
		}
	}

	private float LocalK(Camera eye)
	{
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0030: 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)
		if (!_centerSet || (Object)(object)eye == (Object)null)
		{
			return 1f;
		}
		Vector3 val = ((Component)eye).transform.position - _stormCenter;
		val.y = 0f;
		return Mathf.Clamp01(1f - (((Vector3)(ref val)).magnitude - _footprint) / 300f);
	}

	private static float WaterHeightAt(Vector3 pos)
	{
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		if (_waterHeightBroken)
		{
			return 0f;
		}
		try
		{
			float waterHeight = WaterManager.GetWaterHeight(pos);
			return (float.IsNaN(waterHeight) || float.IsInfinity(waterHeight)) ? 0f : waterHeight;
		}
		catch (Exception)
		{
			_waterHeightBroken = true;
			return 0f;
		}
	}

	private static bool Near(Vector3 a, Vector3 b)
	{
		//IL_0019: 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_0020: Unknown result type (might be due to invalid IL or missing references)
		a.y = 0f;
		b.y = 0f;
		Vector3 val = a - b;
		return ((Vector3)(ref val)).magnitude < 500f;
	}

	private double SharedSeconds()
	{
		if (_clock != null)
		{
			double num = _clock();
			if (num >= 0.0)
			{
				return num;
			}
		}
		_localClock += Time.deltaTime;
		return _localClock;
	}

	private void LateUpdate()
	{
		//IL_004e: 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_018d: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0151: Unknown result type (might be due to invalid IL or missing references)
		//IL_025a: Unknown result type (might be due to invalid IL or missing references)
		//IL_025f: Unknown result type (might be due to invalid IL or missing references)
		if (Pressed((KeyCode)288))
		{
			_menuOpen = !_menuOpen;
			if (_menuOpen)
			{
				_devMenu = Held((KeyCode)304) || Held((KeyCode)303);
				_wasLock = Cursor.lockState;
				_wasCursor = Cursor.visible;
				Cursor.lockState = (CursorLockMode)0;
				Cursor.visible = true;
			}
			else
			{
				CloseMenu();
			}
		}
		if (_menuOpen)
		{
			Cursor.lockState = (CursorLockMode)0;
			Cursor.visible = true;
		}
		_nowSeconds = SharedSeconds();
		int num = StateAt(_nowSeconds);
		if (num == 2 && !DarkEnough())
		{
			num = 1;
		}
		_state = ((Override >= 0) ? Override : num);
		float num2 = ((_state == 2) ? 1f : ((_state == 1) ? 0.45f : 0f));
		_w = Mathf.MoveTowards(_w, num2, Time.deltaTime / 20f);
		float num3 = _w * Intensity;
		Camera val = Eye();
		if ((Object)(object)val != (Object)null)
		{
			((Component)this).transform.position = ((Component)val).transform.position;
		}
		float num4 = Mathf.PerlinNoise(Time.time * 0.006f, 77.7f) * 6.2832f;
		_gale = new Vector3(Mathf.Cos(num4), 0f, Mathf.Sin(num4)) * (1.2f + 3.8f * Mathf.Clamp01(num3));
		_localK = LocalK(val);
		float w = num3 * _localK;
		if (_w > 0.95f && !_truthLogged)
		{
			_truthLogged = true;
			WeatherPlugin.Log.LogInfo((object)("STORM TRUTH: shade=" + (((Object)(object)_shadeMat != (Object)null) ? ("on a=" + _lidA.ToString("0.00")) : "MISSING") + " localK=" + _localK.ToString("0.00") + " fogMode=" + ((object)RenderSettings.fogMode/*cast due to .constrained prefix*/).ToString() + " fogOn=" + RenderSettings.fog + " dens=" + RenderSettings.fogDensity.ToString("0.0000") + " end=" + RenderSettings.fogEndDistance.ToString("0") + " night=" + (_dayNightPresent ? "y" : "n") + " far=" + (((Object)(object)val != (Object)null) ? val.farClipPlane.ToString("0") : "?")));
		}
		else if (_w < 0.1f)
		{
			_truthLogged = false;
		}
		Rain(w, val);
		Clouds(num3, val);
		Darken(w, val);
		Lightning(num3, val);
		Sound(w);
	}

	private void BuildRain()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Expected O, but got Unknown
		//IL_0034: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_0056: 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)
		//IL_0079: Unknown result type (might be due to invalid IL or missing references)
		//IL_008b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_010a: Unknown result type (might be due to invalid IL or missing references)
		//IL_011b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0120: Unknown result type (might be due to invalid IL or missing references)
		//IL_0128: Unknown result type (might be due to invalid IL or missing references)
		//IL_0139: 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)
		//IL_016b: Unknown result type (might be due to invalid IL or missing references)
		//IL_017d: Unknown result type (might be due to invalid IL or missing references)
		//IL_018f: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b3: Expected O, but got Unknown
		//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0200: Unknown result type (might be due to invalid IL or missing references)
		//IL_0217: Unknown result type (might be due to invalid IL or missing references)
		//IL_0238: Unknown result type (might be due to invalid IL or missing references)
		//IL_023d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0265: Unknown result type (might be due to invalid IL or missing references)
		//IL_0272: Unknown result type (might be due to invalid IL or missing references)
		//IL_0277: Unknown result type (might be due to invalid IL or missing references)
		//IL_0291: Unknown result type (might be due to invalid IL or missing references)
		//IL_0296: Unknown result type (might be due to invalid IL or missing references)
		//IL_029f: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_02bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_02eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_048d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0494: Expected O, but got Unknown
		//IL_04bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_04c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_04d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_04e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_04fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_051c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0521: Unknown result type (might be due to invalid IL or missing references)
		//IL_0549: Unknown result type (might be due to invalid IL or missing references)
		//IL_055a: Unknown result type (might be due to invalid IL or missing references)
		//IL_055f: Unknown result type (might be due to invalid IL or missing references)
		//IL_057b: Unknown result type (might be due to invalid IL or missing references)
		//IL_058c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0591: Unknown result type (might be due to invalid IL or missing references)
		//IL_059a: Unknown result type (might be due to invalid IL or missing references)
		//IL_05ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_05b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_05db: Unknown result type (might be due to invalid IL or missing references)
		//IL_05ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_05f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_05fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0603: Expected O, but got Unknown
		//IL_060d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0617: Unknown result type (might be due to invalid IL or missing references)
		//IL_061c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0623: Unknown result type (might be due to invalid IL or missing references)
		//IL_062d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0632: Unknown result type (might be due to invalid IL or missing references)
		//IL_0651: Unknown result type (might be due to invalid IL or missing references)
		//IL_0656: Unknown result type (might be due to invalid IL or missing references)
		//IL_0667: Unknown result type (might be due to invalid IL or missing references)
		//IL_066c: Unknown result type (might be due to invalid IL or missing references)
		//IL_067d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0682: Unknown result type (might be due to invalid IL or missing references)
		//IL_0691: Unknown result type (might be due to invalid IL or missing references)
		//IL_03c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_03d8: Expected O, but got Unknown
		//IL_03f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0791: Unknown result type (might be due to invalid IL or missing references)
		//IL_0798: Expected O, but got Unknown
		//IL_07c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_07e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_07e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_07f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_080f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0821: Unknown result type (might be due to invalid IL or missing references)
		//IL_0842: Unknown result type (might be due to invalid IL or missing references)
		//IL_0847: Unknown result type (might be due to invalid IL or missing references)
		//IL_086f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0880: Unknown result type (might be due to invalid IL or missing references)
		//IL_0885: Unknown result type (might be due to invalid IL or missing references)
		//IL_08a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_08b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_08b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_08c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0705: Unknown result type (might be due to invalid IL or missing references)
		//IL_070a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0718: Expected O, but got Unknown
		//IL_0745: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject("Rain");
		val.transform.SetParent(((Component)this).transform, false);
		val.transform.localPosition = new Vector3(0f, 22f, 0f);
		_rain = val.AddComponent<ParticleSystem>();
		MainModule main = _rain.main;
		((MainModule)(ref main)).loop = true;
		((MainModule)(ref main)).startLifetime = MinMaxCurve.op_Implicit(1.35f);
		((MainModule)(ref main)).startSpeed = MinMaxCurve.op_Implicit(0f);
		((MainModule)(ref main)).startSize = MinMaxCurve.op_Implicit(0.065f);
		((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(new Color(0.75f, 0.82f, 0.95f, 0.55f));
		((MainModule)(ref main)).maxParticles = 4200;
		((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1;
		((MainModule)(ref main)).gravityModifier = MinMaxCurve.op_Implicit(3.2f);
		ShapeModule shape = _rain.shape;
		((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)5;
		((ShapeModule)(ref shape)).scale = new Vector3(64f, 1f, 64f);
		EmissionModule emission = _rain.emission;
		((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(0f);
		CollisionModule collision = _rain.collision;
		((CollisionModule)(ref collision)).enabled = true;
		((CollisionModule)(ref collision)).type = (ParticleSystemCollisionType)1;
		((CollisionModule)(ref collision)).mode = (ParticleSystemCollisionMode)0;
		((CollisionModule)(ref collision)).quality = (ParticleSystemCollisionQuality)0;
		((CollisionModule)(ref collision)).dampen = MinMaxCurve.op_Implicit(1f);
		((CollisionModule)(ref collision)).bounce = MinMaxCurve.op_Implicit(0f);
		((CollisionModule)(ref collision)).lifetimeLoss = MinMaxCurve.op_Implicit(1f);
		((CollisionModule)(ref collision)).radiusScale = 0.5f;
		GameObject val2 = new GameObject("RainSpatter");
		val2.transform.SetParent(val.transform, false);
		ParticleSystem val3 = val2.AddComponent<ParticleSystem>();
		MainModule main2 = val3.main;
		((MainModule)(ref main2)).loop = false;
		((MainModule)(ref main2)).startLifetime = MinMaxCurve.op_Implicit(0.24f);
		((MainModule)(ref main2)).startSpeed = new MinMaxCurve(0.9f, 1.8f);
		((MainModule)(ref main2)).startSize = new MinMaxCurve(0.09f, 0.14f);
		((MainModule)(ref main2)).startColor = MinMaxGradient.op_Implicit(new Color(0.88f, 0.92f, 1f, 0.85f));
		((MainModule)(ref main2)).maxParticles = 2200;
		((MainModule)(ref main2)).simulationSpace = (ParticleSystemSimulationSpace)1;
		((MainModule)(ref main2)).gravityModifier = MinMaxCurve.op_Implicit(2.4f);
		ShapeModule shape2 = val3.shape;
		((ShapeModule)(ref shape2)).shapeType = (ParticleSystemShapeType)0;
		((ShapeModule)(ref shape2)).radius = 0.02f;
		EmissionModule emission2 = val3.emission;
		((EmissionModule)(ref emission2)).rateOverTime = MinMaxCurve.op_Implicit(0f);
		((EmissionModule)(ref emission2)).SetBursts((Burst[])(object)new Burst[1]
		{
			new Burst(0f, (short)2)
		});
		ParticleSystemRenderer component = val2.GetComponent<ParticleSystemRenderer>();
		((Renderer)component).shadowCastingMode = (ShadowCastingMode)0;
		((Renderer)component).receiveShadows = false;
		SubEmittersModule subEmitters = _rain.subEmitters;
		((SubEmittersModule)(ref subEmitters)).enabled = true;
		((SubEmittersModule)(ref subEmitters)).AddSubEmitter(val3, (ParticleSystemSubEmitterType)1, (ParticleSystemSubEmitterProperties)0);
		_rainRenderer = val.GetComponent<ParticleSystemRenderer>();
		_rainRenderer.renderMode = (ParticleSystemRenderMode)1;
		_rainRenderer.velocityScale = 0.09f;
		_rainRenderer.lengthScale = 0.9f;
		((Renderer)_rainRenderer).shadowCastingMode = (ShadowCastingMode)0;
		((Renderer)_rainRenderer).receiveShadows = false;
		Material[] array = Resources.FindObjectsOfTypeAll<Material>();
		foreach (Material val4 in array)
		{
			if (!((Object)(object)val4 != (Object)null) || !((Object)(object)val4.shader != (Object)null) || !(((Object)val4.shader).name == "HTF/NightSky") || !((Object)(object)val4.GetTexture("_MainTex") != (Object)null))
			{
				continue;
			}
			Material val5 = new Material(val4)
			{
				name = "RainStreak"
			};
			val5.SetColor("_Tint", new Color(1f, 1f, 1f, 0.34f));
			val5.SetFloat("_Glow", 0.7f);
			val5.renderQueue = 2990;
			((Renderer)_rainRenderer).sharedMaterial = val5;
			ParticleSystemRenderer[] componentsInChildren = ((Component)this).GetComponentsInChildren<ParticleSystemRenderer>(true);
			foreach (ParticleSystemRenderer val6 in componentsInChildren)
			{
				if (((Object)((Component)val6).gameObject).name == "RainSpatter")
				{
					((Renderer)val6).sharedMaterial = val5;
				}
			}
			break;
		}
		GameObject val7 = new GameObject("RainSplash");
		val7.transform.SetParent(((Component)this).transform, false);
		_splash = val7.AddComponent<ParticleSystem>();
		MainModule main3 = _splash.main;
		((MainModule)(ref main3)).loop = true;
		((MainModule)(ref main3)).startLifetime = MinMaxCurve.op_Implicit(0.45f);
		((MainModule)(ref main3)).startSpeed = MinMaxCurve.op_Implicit(0f);
		((MainModule)(ref main3)).startSize = new MinMaxCurve(0.22f, 0.5f);
		((MainModule)(ref main3)).startColor = MinMaxGradient.op_Implicit(new Color(0.82f, 0.88f, 0.98f, 0.85f));
		((MainModule)(ref main3)).maxParticles = 1600;
		((MainModule)(ref main3)).simulationSpace = (ParticleSystemSimulationSpace)1;
		((MainModule)(ref main3)).gravityModifier = MinMaxCurve.op_Implicit(0f);
		ShapeModule shape3 = _splash.shape;
		((ShapeModule)(ref shape3)).shapeType = (ParticleSystemShapeType)5;
		((ShapeModule)(ref shape3)).scale = new Vector3(46f, 0.01f, 46f);
		EmissionModule emission3 = _splash.emission;
		((EmissionModule)(ref emission3)).rateOverTime = MinMaxCurve.op_Implicit(0f);
		SizeOverLifetimeModule sizeOverLifetime = _splash.sizeOverLifetime;
		((SizeOverLifetimeModule)(ref sizeOverLifetime)).enabled = true;
		((SizeOverLifetimeModule)(ref sizeOverLifetime)).size = new MinMaxCurve(1f, AnimationCurve.Linear(0f, 0.3f, 1f, 1f));
		ColorOverLifetimeModule colorOverLifetime = _splash.colorOverLifetime;
		((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled = true;
		Gradient val8 = new Gradient();
		val8.colorKeys = (GradientColorKey[])(object)new GradientColorKey[2]
		{
			new GradientColorKey(Color.white, 0f),
			new GradientColorKey(Color.white, 1f)
		};
		val8.alphaKeys = (GradientAlphaKey[])(object)new GradientAlphaKey[3]
		{
			new GradientAlphaKey(0.9f, 0f),
			new GradientAlphaKey(0.5f, 0.45f),
			new GradientAlphaKey(0f, 1f)
		};
		((ColorOverLifetimeModule)(ref colorOverLifetime)).color = MinMaxGradient.op_Implicit(val8);
		ParticleSystemRenderer component2 = val7.GetComponent<ParticleSystemRenderer>();
		component2.renderMode = (ParticleSystemRenderMode)2;
		((Renderer)component2).shadowCastingMode = (ShadowCastingMode)0;
		((Renderer)component2).receiveShadows = false;
		if ((Object)(object)((Renderer)_rainRenderer).sharedMaterial != (Object)null && ((Object)((Renderer)_rainRenderer).sharedMaterial).name == "RainStreak")
		{
			Material val9 = new Material(((Renderer)_rainRenderer).sharedMaterial)
			{
				name = "SplashRing"
			};
			val9.SetTexture("_MainTex", (Texture)(object)RingTex());
			val9.SetColor("_Tint", new Color(1f, 1f, 1f, 0.75f));
			if (val9.HasProperty("_Glow"))
			{
				val9.SetFloat("_Glow", 0.9f);
			}
			val9.renderQueue = 2991;
			((Renderer)component2).sharedMaterial = val9;
		}
		GameObject val10 = new GameObject("RainSpray");
		val10.transform.SetParent(val7.transform, false);
		val10.transform.localRotation = Quaternion.Euler(-90f, 0f, 0f);
		_spray = val10.AddComponent<ParticleSystem>();
		MainModule main4 = _spray.main;
		((MainModule)(ref main4)).loop = true;
		((MainModule)(ref main4)).startLifetime = MinMaxCurve.op_Implicit(0.3f);
		((MainModule)(ref main4)).startSpeed = new MinMaxCurve(1.2f, 2.2f);
		((MainModule)(ref main4)).startSize = MinMaxCurve.op_Implicit(0.11f);
		((MainModule)(ref main4)).startColor = MinMaxGradient.op_Implicit(new Color(0.85f, 0.9f, 1f, 0.7f));
		((MainModule)(ref main4)).maxParticles = 1500;
		((MainModule)(ref main4)).simulationSpace = (ParticleSystemSimulationSpace)1;
		((MainModule)(ref main4)).gravityModifier = MinMaxCurve.op_Implicit(2.6f);
		ShapeModule shape4 = _spray.shape;
		((ShapeModule)(ref shape4)).shapeType = (ParticleSystemShapeType)5;
		((ShapeModule)(ref shape4)).scale = new Vector3(46f, 46f, 0.1f);
		EmissionModule emission4 = _spray.emission;
		((EmissionModule)(ref emission4)).rateOverTime = MinMaxCurve.op_Implicit(0f);
		ParticleSystemRenderer component3 = val10.GetComponent<ParticleSystemRenderer>();
		((Renderer)component3).shadowCastingMode = (ShadowCastingMode)0;
		((Renderer)component3).receiveShadows = false;
		if ((Object)(object)((Renderer)_rainRenderer).sharedMaterial != (Object)null && ((Object)((Renderer)_rainRenderer).sharedMaterial).name == "RainStreak")
		{
			((Renderer)component3).sharedMaterial = ((Renderer)_rainRenderer).sharedMaterial;
		}
	}

	private static Texture2D RingTex()
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_000d: Expected O, but got Unknown
		//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
		Texture2D val = new Texture2D(64, 64, (TextureFormat)4, false);
		((Texture)val).wrapMode = (TextureWrapMode)1;
		for (int i = 0; i < 64; i++)
		{
			for (int j = 0; j < 64; j++)
			{
				float num = ((float)j + 0.5f) / 64f - 0.5f;
				float num2 = ((float)i + 0.5f) / 64f - 0.5f;
				float num3 = Mathf.Sqrt(num * num + num2 * num2) * 2f;
				float num4 = Mathf.Exp(0f - Mathf.Pow((num3 - 0.62f) * 6.5f, 2f));
				float num5 = Mathf.Exp((0f - num3) * num3 * 30f) * 0.7f;
				val.SetPixel(j, i, new Color(1f, 1f, 1f, Mathf.Clamp01(num4 + num5)));
			}
		}
		val.Apply();
		return val;
	}

	private void Rain(float w, Camera eye)
	{
		//IL_003e: 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_005d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0283: Unknown result type (might be due to invalid IL or missing references)
		//IL_0288: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d9: 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_00ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0108: 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_011c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0125: Unknown result type (might be due to invalid IL or missing references)
		//IL_0127: 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)
		//IL_0182: Unknown result type (might be due to invalid IL or missing references)
		//IL_0191: Unknown result type (might be due to invalid IL or missing references)
		//IL_015e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0163: Unknown result type (might be due to invalid IL or missing references)
		//IL_016d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0172: Unknown result type (might be due to invalid IL or missing references)
		//IL_0177: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_0204: Unknown result type (might be due to invalid IL or missing references)
		//IL_0209: Unknown result type (might be due to invalid IL or missing references)
		//IL_0243: Unknown result type (might be due to invalid IL or missing references)
		//IL_024e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0250: Unknown result type (might be due to invalid IL or missing references)
		//IL_0258: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)_rain == (Object)null)
		{
			return;
		}
		float num = 0.7f + 0.5f * Mathf.PerlinNoise(Time.time * 0.13f, 9.1f);
		EmissionModule emission = _rain.emission;
		((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(Mathf.Lerp(0f, 2800f, Mathf.Clamp01(w)) * num);
		if ((Object)(object)_splash != (Object)null && (Object)(object)eye != (Object)null)
		{
			_splashBudget += Mathf.Lerp(0f, 260f, Mathf.Clamp01(w)) * num * Time.deltaTime;
			Vector3 position = ((Component)eye).transform.position;
			Vector3 val2 = default(Vector3);
			RaycastHit val3 = default(RaycastHit);
			Vector3 val4 = default(Vector3);
			while (_splashBudget >= 1f)
			{
				_splashBudget -= 1f;
				Vector2 val = Random.insideUnitCircle * 17f;
				((Vector3)(ref val2))..ctor(position.x + val.x, position.y + 28f, position.z + val.y);
				float num2 = WaterHeightAt(val2);
				bool flag;
				if (Physics.Raycast(val2, Vector3.down, ref val3, 90f, -1, (QueryTriggerInteraction)1) && ((RaycastHit)(ref val3)).point.y > num2 + 0.05f)
				{
					val4 = ((RaycastHit)(ref val3)).point + Vector3.up * 0.03f;
					flag = false;
				}
				else
				{
					((Vector3)(ref val4))..ctor(val2.x, num2 + 0.02f, val2.z);
					flag = true;
				}
				EmitParams val5 = default(EmitParams);
				((EmitParams)(ref val5)).position = val4;
				EmitParams val6 = val5;
				_splash.Emit(val6, 1);
				if (flag && (Object)(object)_spray != (Object)null && Random.value < 0.6f)
				{
					val5 = default(EmitParams);
					((EmitParams)(ref val5)).position = val4 + Vector3.up * 0.02f;
					((EmitParams)(ref val5)).velocity = new Vector3(Random.Range(-0.4f, 0.4f), Random.Range(1.1f, 2f), Random.Range(-0.4f, 0.4f));
					EmitParams val7 = val5;
					_spray.Emit(val7, 1);
				}
			}
		}
		VelocityOverLifetimeModule velocityOverLifetime = _rain.velocityOverLifetime;
		((VelocityOverLifetimeModule)(ref velocityOverLifetime)).enabled = true;
		((VelocityOverLifetimeModule)(ref velocityOverLifetime)).space = (ParticleSystemSimulationSpace)1;
		((VelocityOverLifetimeModule)(ref velocityOverLifetime)).x = MinMaxCurve.op_Implicit(_gale.x * 0.85f);
		((VelocityOverLifetimeModule)(ref velocityOverLifetime)).z = MinMaxCurve.op_Implicit(_gale.z * 0.85f);
	}

	private void Darken(float w, Camera eye)
	{
		//IL_0269: Unknown result type (might be due to invalid IL or missing references)
		//IL_0280: Unknown result type (might be due to invalid IL or missing references)
		//IL_0206: Unknown result type (might be due to invalid IL or missing references)
		//IL_020c: Invalid comparison between Unknown and I4
		//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_009a: 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_00ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_03bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_03c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_03c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_03cb: 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_0233: Unknown result type (might be due to invalid IL or missing references)
		//IL_023a: Unknown result type (might be due to invalid IL or missing references)
		//IL_023f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0249: Unknown result type (might be due to invalid IL or missing references)
		//IL_024f: Unknown result type (might be due to invalid IL or missing references)
		//IL_02da: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_037b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0381: Invalid comparison between Unknown and I4
		//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f1: 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_0137: 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)
		//IL_0143: Unknown result type (might be due to invalid IL or missing references)
		//IL_0450: Unknown result type (might be due to invalid IL or missing references)
		//IL_0456: Unknown result type (might be due to invalid IL or missing references)
		//IL_046b: Unknown result type (might be due to invalid IL or missing references)
		//IL_04a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_011e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0120: Unknown result type (might be due to invalid IL or missing references)
		//IL_010c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0111: Unknown result type (might be due to invalid IL or missing references)
		//IL_04c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_04cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_04d9: Unknown result type (might be due to invalid IL or missing references)
		_rescan -= Time.deltaTime;
		if (_rescan <= 0f)
		{
			_rescan = 2f;
			_lights = Object.FindObjectsByType<Light>((FindObjectsInactive)0, (FindObjectsSortMode)0);
			_dayNightPresent = (Object)(object)GameObject.Find("NightSky") != (Object)null;
			if (_state == 0 && _w < 0.02f)
			{
				_centerSet = false;
			}
			else if (!_centerSet)
			{
				Vector3 position = ((Component)this).transform.position;
				Vector3 val;
				float num;
				if ((Object)(object)Island.CurIsland != (Object)null && Near(Island.IslandPos, position))
				{
					val = Island.IslandPos;
					num = Island.IslandSize;
				}
				else if ((Object)(object)Island.CurIsland != (Object)null && Near(((Component)Island.CurIsland).transform.position, position))
				{
					val = ((Component)Island.CurIsland).transform.position;
					num = Island.IslandSize;
				}
				else
				{
					val = position;
					num = 380f;
				}
				_stormCenter = new Vector3(val.x, 0f, val.z);
				_footprint = Mathf.Max(450f, num + 220f);
				_centerSet = true;
				WeatherPlugin.Log.LogInfo((object)("Storm anchored at " + ((Vector3)(ref _stormCenter)).ToString("0") + ", footprint " + _footprint.ToString("0") + "m."));
			}
		}
		float num2 = Mathf.Clamp01(w);
		float num3 = Mathf.Lerp(1f, 0.25f, num2);
		if (_dayNightPresent)
		{
			Light[] lights = _lights;
			foreach (Light val2 in lights)
			{
				if ((Object)(object)val2 != (Object)null && (int)val2.type == 1)
				{
					val2.intensity *= num3;
					val2.color = Color.Lerp(val2.color, Color.Lerp(val2.color, GreyOf(val2.color), 0.6f), num2);
				}
			}
			RenderSettings.ambientLight *= num3 * Mathf.Lerp(1f, 0.8f, num2);
			RenderSettings.ambientIntensity *= num3 * Mathf.Lerp(1f, 0.8f, num2);
			if (!((Object)(object)eye != (Object)null) || !(((Component)eye).transform.position.y < -0.9f))
			{
				RenderSettings.fogColor = Color.Lerp(RenderSettings.fogColor, _overcastNow, 0.92f * num2);
				RenderSettings.fogDensity = Mathf.Max(RenderSettings.fogDensity * Mathf.Lerp(1f, 3.5f, num2), 0.011f * num2 * num2);
				FogLine(num2);
			}
			return;
		}
		if (!_tookBase && w < 0.01f)
		{
			_baseIntensity.Clear();
			Light[] lights2 = _lights;
			foreach (Light val3 in lights2)
			{
				if ((Object)(object)val3 != (Object)null && (int)val3.type == 1)
				{
					_baseIntensity[val3] = val3.intensity;
				}
			}
			_baseFogDensity = RenderSettings.fogDensity;
			_baseFogColor = RenderSettings.fogColor;
			_baseAmbient = RenderSettings.ambientLight;
			_baseAmbientStrength = RenderSettings.ambientIntensity;
			_tookBase = true;
		}
		if (!_tookBase)
		{
			return;
		}
		foreach (KeyValuePair<Light, float> item in _baseIntensity)
		{
			if ((Object)(object)item.Key != (Object)null)
			{
				item.Key.intensity = item.Value * num3;
			}
		}
		RenderSettings.ambientLight = _baseAmbient * num3 * Mathf.Lerp(1f, 0.8f, num2);
		RenderSettings.ambientIntensity = _baseAmbientStrength * num3 * Mathf.Lerp(1f, 0.8f, num2);
		if (!((Object)(object)eye != (Object)null) || !(((Component)eye).transform.position.y < -0.9f))
		{
			RenderSettings.fogColor = Color.Lerp(_baseFogColor, _overcastNow, 0.92f * num2);
			RenderSettings.fogDensity = Mathf.Max(_baseFogDensity * Mathf.Lerp(1f, 3.5f, num2), 0.011f * num2 * num2);
			FogLine(num2);
		}
	}

	private void FogLine(float k)
	{
		//IL_004f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0055: Invalid comparison between Unknown and I4
		if (!_tookFogLine)
		{
			_baseFogOn = RenderSettings.fog;
			_baseFogStart = RenderSettings.fogStartDistance;
			_baseFogEnd = RenderSettings.fogEndDistance;
			_tookFogLine = true;
		}
		RenderSettings.fog = k > 0.02f || _baseFogOn;
		if ((int)RenderSettings.fogMode == 1)
		{
			RenderSettings.fogStartDistance = Mathf.Lerp(_baseFogStart, 12f, k);
			RenderSettings.fogEndDistance = Mathf.Lerp(_baseFogEnd, 170f, k);
		}
	}

	private static Color GreyOf(Color c)
	{
		//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_0020: Unknown result type (might be due to invalid IL or missing references)
		float grayscale = ((Color)(ref c)).grayscale;
		return new Color(grayscale * 0.96f, grayscale, grayscale * 1.05f);
	}

	private void Clouds(float w, Camera eye)
	{
		//IL_0011: 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_0030: 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_02a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0315: Unknown result type (might be due to invalid IL or missing references)
		//IL_035c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0361: Unknown result type (might be due to invalid IL or missing references)
		//IL_0378: Unknown result type (might be due to invalid IL or missing references)
		//IL_037d: Unknown result type (might be due to invalid IL or missing references)
		//IL_03de: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_03cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_03d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0412: Unknown result type (might be due to invalid IL or missing references)
		//IL_0417: Unknown result type (might be due to invalid IL or missing references)
		//IL_0423: Unknown result type (might be due to invalid IL or missing references)
		//IL_0435: Unknown result type (might be due to invalid IL or missing references)
		//IL_043a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0466: Unknown result type (might be due to invalid IL or missing references)
		//IL_0474: Unknown result type (might be due to invalid IL or missing references)
		_overcastNow = Color.Lerp(new Color(0.52f, 0.54f, 0.58f), new Color(0.275f, 0.285f, 0.315f), Mathf.Clamp01(w));
		if ((Object)(object)_shadeMat != (Object)null && (Object)(object)_shadeR == (Object)null)
		{
			_shadeMat = null;
			_deckAMat = null;
			_deckBMat = null;
			WeatherPlugin.Log.LogInfo((object)"Storm sky was rebuilt - re-adopting.");
		}
		if ((Object)(object)_shadeMat == (Object)null)
		{
			_skySearch -= Time.deltaTime;
			if (_skySearch > 0f)
			{
				return;
			}
			_skySearch = 3f;
			GameObject val = GameObject.Find("NightSky");
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			Transform val2 = val.transform.Find("StormShade");
			_deckA = val.transform.Find("StormCloudsA");
			_deckB = val.transform.Find("StormCloudsB");
			if ((Object)(object)val2 == (Object)null || (Object)(object)_deckA == (Object)null || (Object)(object)_deckB == (Object)null)
			{
				WeatherPlugin.Log.LogWarning((object)"This sky bundle has no storm in it - rebuild and re-export the sky from Unity (the build menu does it) to get storm visuals.");
				_skySearch = 60f;
				return;
			}
			_shadeR = ((Component)val2).GetComponent<MeshRenderer>();
			_deckAR = ((Component)_deckA).GetComponent<MeshRenderer>();
			_deckBR = ((Component)_deckB).GetComponent<MeshRenderer>();
			((Renderer)_shadeR).SetPropertyBlock((MaterialPropertyBlock)null);
			((Renderer)_deckAR).SetPropertyBlock((MaterialPropertyBlock)null);
			((Renderer)_deckBR).SetPropertyBlock((MaterialPropertyBlock)null);
			_shadeMat = ((Renderer)_shadeR).material;
			_deckAMat = ((Renderer)_deckAR).material;
			_deckBMat = ((Renderer)_deckBR).material;
			WeatherPlugin.Log.LogInfo((object)"Storm sky adopted from the bundle.");
			BuildVeils();
		}
		float num = Mathf.Clamp01(w);
		float num2 = Mathf.SmoothStep(0f, 1f, Mathf.Clamp01(_localK * 1.6f));
		float num3 = (_lidA = Mathf.Clamp01(num * 2.2f) * num2);
		float num4 = FlashK();
		float num5 = Mathf.Lerp(1f, 0.44f, num);
		float num6 = 1f + num4 * 0.9f;
		_shadeMat.SetColor("_Tint", new Color(num5 * num6, num5 * num6, num5 * 1.04f * num6, num3));
		_deckAMat.SetColor("_Tint", new Color(num5 * num6, num5 * num6, num5 * 1.04f * num6, num3 * 0.95f));
		_deckBMat.SetColor("_Tint", new Color(num5 * 0.9f * num6, num5 * 0.9f * num6, num5 * 0.95f * num6, num3 * 0.9f));
		_spinA += Time.deltaTime * 0.35f;
		_spinB -= Time.deltaTime * 0.55f;
		_deckA.localRotation = Quaternion.AngleAxis(_spinA, Vector3.up);
		_deckB.localRotation = Quaternion.AngleAxis(_spinB, Vector3.up);
		if ((Object)(object)_veilRoot != (Object)null)
		{
			_veilRoot.transform.position = (Vector3)(_centerSet ? _stormCenter : new Vector3(((Component)this).transform.position.x, 0f, ((Component)this).transform.position.z));
			_veilSpin += Time.deltaTime * 0.55f;
			_veilRoot.transform.rotation = Quaternion.AngleAxis(_veilSpin, Vector3.up);
			Color val3 = _overcastNow * (1.05f + num4 * 0.5f);
			val3.a = Mathf.Clamp01((num - 0.15f) * 1.3f) * 0.5f;
			_veilMat.SetColor("_Tint", val3);
			_veilRoot.SetActive(val3.a > 0.02f);
		}
	}

	private void BuildVeils()
	{
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: Expected O, but got Unknown
		//IL_004f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0054: Unknown result type (might be due to invalid IL or missing references)
		//IL_0065: Expected O, but got Unknown
		//IL_0153: Unknown result type (might be due to invalid IL or missing references)
		//IL_0164: Unknown result type (might be due to invalid IL or missing references)
		//IL_0169: Unknown result type (might be due to invalid IL or missing references)
		//IL_018d: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)_veilRoot != (Object)null) && !((Object)(object)_shadeMat == (Object)null))
		{
			_veilRoot = new GameObject("RainVeils");
			Object.DontDestroyOnLoad((Object)(object)_veilRoot);
			_veilMat = new Material(_shadeMat.shader)
			{
				name = "RainVeil"
			};
			_veilMat.SetTexture("_MainTex", (Texture)(object)VeilTex());
			if (_veilMat.HasProperty("_HorizonFade"))
			{
				_veilMat.SetFloat("_HorizonFade", 0f);
			}
			_veilMat.renderQueue = 2958;
			Random random = new Random(1337);
			for (int i = 0; i < 7; i++)
			{
				GameObject val = GameObject.CreatePrimitive((PrimitiveType)5);
				((Object)val).name = "RainVeil" + i;
				Object.Destroy((Object)(object)val.GetComponent<Collider>());
				val.transform.SetParent(_veilRoot.transform, false);
				float num = (float)i / 7f * 360f + (float)random.NextDouble() * 30f;
				float num2 = 250f + (float)(i % 3) * 75f;
				val.transform.localPosition = Quaternion.Euler(0f, num, 0f) * new Vector3(0f, 46f, num2);
				val.transform.localRotation = Quaternion.Euler(0f, num + 90f, 0f);
				val.transform.localScale = new Vector3(220f + (float)random.NextDouble() * 90f, 95f + (float)random.NextDouble() * 20f, 1f);
				MeshRenderer component = val.GetComponent<MeshRenderer>();
				((Renderer)component).sharedMaterial = _veilMat;
				((Renderer)component).shadowCastingMode = (ShadowCastingMode)0;
				((Renderer)component).receiveShadows = false;
			}
		}
	}

	private static Texture2D VeilTex()
	{
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Expected O, but got Unknown
		//IL_009b: Unknown result type (might be due to invalid IL or missing references)
		Texture2D val = new Texture2D(64, 128, (TextureFormat)4, false);
		((Texture)val).wrapMode = (TextureWrapMode)1;
		for (int i = 0; i < 128; i++)
		{
			for (int j = 0; j < 64; j++)
			{
				float num = (float)j / 64f;
				float num2 = (float)i / 128f;
				float num3 = Mathf.Sin(num * (float)Math.PI);
				float num4 = 0.55f + 0.45f * Mathf.PerlinNoise((float)j * 0.9f, 3.3f);
				float num5 = num3 * num4 * Mathf.Lerp(0.25f, 1f, num2);
				val.SetPixel(j, i, new Color(1f, 1f, 1f, num5 * 0.8f));
			}
		}
		val.Apply();
		return val;
	}

	private float FlashK()
	{
		if (_flash <= 0f)
		{
			return 0f;
		}
		return Mathf.Clamp01(_flash / 0.45f) * _flashScale * (0.55f + Mathf.PingPong(Time.time * 41f, 0.45f));
	}

	private void Lightning(float w, Camera eye)
	{
		//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f4: Expected O, but got Unknown
		//IL_021e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0269: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c5: 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)
		//IL_02d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0340: Unknown result type (might be due to invalid IL or missing references)
		//IL_0354: Unknown result type (might be due to invalid IL or missing references)
		//IL_035b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0360: Unknown result type (might be due to invalid IL or missing references)
		//IL_036b: Unknown result type (might be due to invalid IL or missing references)
		//IL_037f: Unknown result type (might be due to invalid IL or missing references)
		//IL_038c: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_03be: Invalid comparison between Unknown and I4
		//IL_03e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_03f7: Unknown result type (might be due to invalid IL or missing references)
		if (!LightningOn)
		{
			_flash = 0f;
			_pendingThunder = -1f;
			_reFlash = -1f;
			if ((Object)(object)_flashLight != (Object)null)
			{
				((Behaviour)_flashLight).enabled = false;
			}
			ShowBolt(on: false, 0f);
			return;
		}
		if (w > 0.7f)
		{
			_nextStrike -= Time.deltaTime;
			if (_nextStrike <= 0f)
			{
				_nextStrike = 35f + (float)new Random((int)(Time.time * 613f)).NextDouble() * 40f;
				Strike(fromMenu: false);
			}
		}
		if (w > 0.35f)
		{
			_sheetTimer -= Time.deltaTime;
			if (_sheetTimer <= 0f)
			{
				_sheetTimer = 55f + Random.value * 55f;
				_flash = 0.27f;
				_flashScale = 0.35f;
				_lastDelay = 3.2f + Random.value * 1.4f;
				_pendingThunder = _lastDelay;
			}
		}
		if (_reFlash > 0f)
		{
			_reFlash -= Time.deltaTime;
			if (_reFlash <= 0f)
			{
				_flash = 0.35999998f;
				AimBolt();
			}
		}
		if (_flash > 0f)
		{
			_flash -= Time.deltaTime;
			float num = FlashK();
			if ((Object)(object)_flashLight == (Object)null)
			{
				GameObject val = new GameObject("LightningFlash");
				val.transform.SetParent(((Component)this).transform, false);
				val.transform.localPosition = new Vector3(0f, 60f, 0f);
				_flashLight = val.AddComponent<Light>();
				_flashLight.type = (LightType)2;
				_flashLight.range = 400f;
				_flashLight.color = new Color(0.92f, 0.94f, 1f);
				_flashLight.shadows = (LightShadows)0;
			}
			((Behaviour)_flashLight).enabled = true;
			_flashLight.intensity = num * 9f;
			if (_boltTop != Vector3.zero)
			{
				((Component)_flashLight).transform.position = _boltTop + Vector3.down * 18f;
			}
			bool flag = _flashScale > 0.6f && _flash > 0.17999999f;
			ShowBolt(flag, num);
			if (_dayNightPresent || _tookBase)
			{
				float num2 = num * (0.3f + 0.7f * _localK);
				RenderSettings.ambientLight += new Color(0.65f, 0.7f, 0.95f) * num2;
				RenderSettings.fogColor = Color.Lerp(RenderSettings.fogColor, new Color(0.62f, 0.68f, 0.88f), num2 * 0.55f);
				Light[] lights = _lights;
				foreach (Light val2 in lights)
				{
					if ((Object)(object)val2 != (Object)null && (int)val2.type == 1)
					{
						val2.intensity += num2 * 1.3f;
						val2.color = Color.Lerp(val2.color, Color.white, num2 * 0.5f);
					}
				}
			}
		}
		else
		{
			if ((Object)(object)_flashLight != (Object)null)
			{
				((Behaviour)_flashLight).enabled = false;
			}
			ShowBolt(on: false, 0f);
		}
		if (!(_pendingThunder > 0f))
		{
			return;
		}
		_pendingThunder -= Time.deltaTime;
		if (_pendingThunder <= 0f && (Object)(object)_thunderVoice != (Object)null)
		{
			float num3 = Mathf.InverseLerp(1.2f, 3.8f, _lastDelay);
			_thunderVoice.pitch = 0.9f + Random.value * 0.2f - num3 * 0.15f;
			if (ThunderOn)
			{
				AudioClip val3 = ((_thunderFiles.Count > 0) ? _thunderFiles[Random.Range(0, _thunderFiles.Count)] : SynthThunder(Random.Range(1, 999999)));
				_thunderVoice.PlayOneShot(val3, Volume * Mathf.Lerp(0.5f, 0.18f, num3) * (0.4f + 0.6f * _localK));
			}
			_pendingThunder = -1f;
		}
	}

	private void Strike(bool fromMenu)
	{
		_flash = 0.45f;
		_flashScale = 1f;
		AimBolt();
		if (!fromMenu)
		{
			_lastDelay = 1.2f + (float)new Random((int)(Time.time * 271f)).NextDouble() * 2.6f;
			_pendingThunder = _lastDelay;
		}
		else
		{
			_lastDelay = 1.2f;
			_pendingThunder = 1f;
		}
		_reFlash = ((Random.value < 0.35f) ? 0.55f : (-1f));
	}

	private void EnsureBolt()
	{
		//IL_00db: Unknown result type (might be due to invalid IL or missing references)
		//IL_0081: Unknown result type (might be due to invalid IL or missing references)
		//IL_0086: Unknown result type (might be due to invalid IL or missing references)
		//IL_0097: Expected O, but got Unknown
		if ((Object)(object)_bolt != (Object)null || (Object)(object)_boltMat != (Object)null)
		{
			return;
		}
		Material[] array = Resources.FindObjectsOfTypeAll<Material>();
		foreach (Material val in array)
		{
			if ((Object)(object)val != (Object)null && (Object)(object)val.shader != (Object)null && ((Object)val.shader).name == "HTF/NightSky" && (Object)(object)val.GetTexture("_MainTex") != (Object)null)
			{
				_boltMat = new Material(val)
				{
					name = "BoltGlow"
				};
				break;
			}
		}
		if (!((Object)(object)_boltMat == (Object)null))
		{
			_boltMat.SetTexture("_MainTex", (Texture)(object)Texture2D.whiteTexture);
			_boltMat.SetColor("_Tint", Color.white);
			_boltMat.renderQueue = 2992;
			if (_boltMat.HasProperty("_Glow"))
			{
				_boltMat.SetFloat("_Glow", 2.5f);
			}
			_bolt = NewBolt("Bolt", 1.7f);
			_branchA = NewBolt("BoltBranchA", 0.6f);
			_branchB = NewBolt("BoltBranchB", 0.6f);
		}
	}

	private LineRenderer NewBolt(string name, float width)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Expected O, but got Unknown
		GameObject val = new GameObject(name);
		val.transform.SetParent(((Component)this).transform.parent, false);
		LineRenderer val2 = val.AddComponent<LineRenderer>();
		((Renderer)val2).material = _boltMat;
		val2.startWidth = width;
		val2.endWidth = width * 0.35f;
		val2.useWorldSpace = true;
		val2.numCapVertices = 2;
		((Renderer)val2).shadowCastingMode = (ShadowCastingMode)0;
		((Renderer)val2).receiveShadows = false;
		((Renderer)val2).enabled = false;
		return val2;
	}

	private void AimBolt()
	{
		//IL_0035: 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_003a: 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)
		//IL_006e: 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_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_007b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0082: Unknown result type (might be due to invalid IL or missing references)
		//IL_009d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00db: Unknown result type (might be due to invalid IL or missing references)
		//IL_0100: Unknown result type (might be due to invalid IL or missing references)
		//IL_0105: Unknown result type (might be due to invalid IL or missing references)
		//IL_010a: Unknown result type (might be due to invalid IL or missing references)
		//IL_010c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0113: Unknown result type (might be due to invalid IL or missing references)
		//IL_0118: Unknown result type (might be due to invalid IL or missing references)
		//IL_011e: 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_0122: Unknown result type (might be due to invalid IL or missing references)
		//IL_0127: 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_013b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0140: Unknown result type (might be due to invalid IL or missing references)
		//IL_0160: Unknown result type (might be due to invalid IL or missing references)
		//IL_0161: Unknown result type (might be due to invalid IL or missing references)
		//IL_016e: Unknown result type (might be due to invalid IL or missing references)
		//IL_016f: Unknown result type (might be due to invalid IL or missing references)
		//IL_019b: Unknown result type (might be due to invalid IL or missing references)
		//IL_01af: Unknown result type (might be due to invalid IL or missing references)
		EnsureBolt();
		if (!((Object)(object)_bolt == (Object)null))
		{
			Vector3 val = (_centerSet ? _stormCenter : ((Component)this).transform.position);
			float num = _footprint * 0.55f;
			Vector3 val2 = (_boltTop = val + new Vector3(Random.Range(0f - num, num), 95f + Random.Range(0f, 45f), Random.Range(0f - num, num)));
			Vector3 val3 = default(Vector3);
			((Vector3)(ref val3))..ctor(val2.x + Random.Range(-30f, 30f), 0f, val2.z + Random.Range(-30f, 30f));
			Vector3[] array = (Vector3[])(object)new Vector3[14];
			Vector3 val4 = Vector3.zero;
			for (int i = 0; i < array.Length; i++)
			{
				float num2 = (float)i / (float)(array.Length - 1);
				val4 += new Vector3(Random.Range(-7f, 7f), 0f, Random.Range(-7f, 7f));
				val4 *= 0.82f;
				array[i] = Vector3.Lerp(val2, val3, num2) + val4 * Mathf.Sin(num2 * 3.1416f);
			}
			array[0] = val2;
			array[^1] = val3;
			_bolt.positionCount = array.Length;
			_bolt.SetPositions(array);
			AimBranch(_branchA, array[4]);
			AimBranch(_branchB, array[8]);
		}
	}

	private static void AimBranch(LineRenderer lr, Vector3 from)
	{
		//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_0043: 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)
		//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_005e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0063: 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_00a0: 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)
		//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)lr == (Object)null))
		{
			Vector3[] array = (Vector3[])(object)new Vector3[5];
			Vector3 val = new Vector3(Random.Range(-1f, 1f), -1.6f, Random.Range(-1f, 1f));
			Vector3 normalized = ((Vector3)(ref val)).normalized;
			array[0] = from;
			for (int i = 1; i < array.Length; i++)
			{
				array[i] = array[i - 1] + normalized * Random.Range(6f, 14f) + new Vector3(Random.Range(-4f, 4f), 0f, Random.Range(-4f, 4f));
			}
			lr.positionCount = array.Length;
			lr.SetPositions(array);
		}
	}

	private void ShowBolt(bool on, float k)
	{
		//IL_0099: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)_bolt == (Object)null))
		{
			((Renderer)_bolt).enabled = on;
			if ((Object)(object)_branchA != (Object)null)
			{
				((Renderer)_branchA).enabled = on;
			}
			if ((Object)(object)_branchB != (Object)null)
			{
				((Renderer)_branchB).enabled = on;
			}
			if (on && (Object)(object)_boltMat != (Object)null)
			{
				_boltMat.SetColor("_Tint", new Color(1f, 1f, 1f, Mathf.Clamp01(k * 1.3f)));
			}
		}
	}

	private void BuildAudio()
	{
		_rainA = ((Component)this).gameObject.AddComponent<AudioSource>();
		_rainA.clip = SynthRainLoop(11, 7.31f, 9f);
		_rainA.loop = true;
		_rainA.volume = 0f;
		_rainA.spatialBlend = 0f;
		_rainA.Play();
		_rainB = ((Component)this).gameObject.AddComponent<AudioSource>();
		_rainB.clip = SynthRainLoop(29, 11.17f, 4f);
		_rainB.loop = true;
		_rainB.volume = 0f;
		_rainB.spatialBlend = 0f;
		_rainB.pitch = 0.93f;
		_rainB.Play();
		_rainFilter = ((Component)this).gameObject.AddComponent<AudioLowPassFilter>();
		_rainFilter.cutoffFrequency = 1600f;
		_stormLayer = ((Component)this).gameObject.AddComponent<AudioSource>();
		_stormLayer.loop = true;
		_stormLayer.volume = 0f;
		_stormLayer.spatialBlend = 0f;
		_wind = ((Component)this).gameObject.AddComponent<AudioSource>();
		_wind.loop = true;
		_wind.volume = 0f;
		_wind.spatialBlend = 0f;
		_thunderVoice = ((Component)this).gameObject.AddComponent<AudioSource>();
		_thunderVoice.spatialBlend = 0f;
		((MonoBehaviour)this).StartCoroutine(LoadRealAudio());
	}

	private IEnumerator LoadRealAudio()
	{
		string dir = Path.Combine(Path.GetDirectoryName(typeof(WeatherPlugin).Assembly.Location), "HTFWeatherAudio");
		if (!Directory.Exists(dir))
		{
			dir = Path.Combine(Paths.PluginPath, "HTFWeatherAudio");
		}
		if (!Directory.Exists(dir))
		{
			yield break;
		}
		string[] files = Directory.GetFiles(dir);
		foreach (string file in files)
		{
			string name = Path.GetFileNameWithoutExtension(file).ToLowerInvariant();
			AudioType type = AudioTypeOf(file);
			if ((int)type == 0)
			{
				continue;
			}
			UnityWebRequest req = UnityWebRequestMultimedia.GetAudioClip("file:///" + file.Replace('\\', '/'), type);
			try
			{
				yield return req.SendWebRequest();
				if ((int)req.result != 1)
				{
					WeatherPlugin.Log.LogWarning((object)("Could not load " + file + ": " + req.error));
					continue;
				}
				AudioClip clip = DownloadHandlerAudioClip.GetContent(req);
				if ((Object)(object)clip == (Object)null)
				{
					continue;
				}
				((Object)clip).name = name;
				switch (name)
				{
				case "rain":
					_rainA.clip = clip;
					_rainA.pitch = 1f;
					_rainA.Play();
					if ((Object)(object)_rainB != (Object)null)
					{
						_rainB.volume = 0f;
					}
					_realRain = true;
					break;
				case "storm":
					_stormLayer.clip = clip;
					_stormLayer.Play();
					_realStorm = true;
					break;
				case "wind":
					_wind.clip = clip;
					_wind.Play();
					_realWind = true;
					break;
				default:
					if (name.StartsWith("thunder"))
					{
						_thunderFiles.Add(clip);
					}
					break;
				}
				WeatherPlugin.Log.LogInfo((object)("Weather audio loaded: " + name));
			}
			finally
			{
				((IDisposable)req)?.Dispose();
			}
		}
	}

	private static AudioType AudioTypeOf(string file)
	{
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_004f: 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_0048: Unknown result type (might be due to invalid IL or missing references)
		return (AudioType)(Path.GetExtension(file).ToLowerInvariant() switch
		{
			".ogg" => 14, 
			".wav" => 20, 
			".mp3" => 13, 
			_ => 0, 
		});
	}

	private void Sound(float w)
	{
		float num = Mathf.Clamp01(w) * Volume;
		float num2 = (_realRain ? 0.55f : 0.2f);
		if ((Object)(object)_rainA != (Object)null)
		{
			_rainA.volume = num * num2;
		}
		if ((Object)(object)_rainB != (Object)null && !_realRain)
		{
			_rainB.volume = num * 0.16f;
		}
		if ((Object)(object)_stormLayer != (Object)null && _realStorm)
		{
			_stormLayer.volume = Mathf.Clamp01((w - 0.5f) * 2f) * 0.6f * Volume;
		}
		if ((Object)(object)_wind != (Object)null && _realWind)
		{
			float num3 = 0.6f + 0.4f * Mathf.PerlinNoise(Time.time * 0.15f, 8.2f);
			_wind.volume = Mathf.Clamp01(w * 1.4f) * 0.45f * num3 * Volume;
		}
		if ((Object)(object)_rainFilter != (Object)null)
		{
			_rainFilter.cutoffFrequency = (_realRain ? 22000f : (1100f + 900f * Mathf.PerlinNoise(Time.time * 0.11f, 3.7f) + 600f * Mathf.Clamp01(w)));
		}
	}

	private static AudioClip SynthRainLoop(int seed, float seconds, float dropsPerSec)
	{
		int num = (int)(22050f * seconds);
		float[] array = new float[num];
		Random random = new Random(seed);
		float num2 = 0f;
		float num3 = 0f;
		float num4 = 0f;
		for (int i = 0; i < num; i++)
		{
			float num5 = (float)i / 22050f;
			float num6 = (float)(random.NextDouble() * 2.0 - 1.0);
			num2 += 0.02f * (num6 - num2);
			num3 += 0.24f * (num6 - num3);
			num4 += 0.07f * (num6 - num4);
			float num7 = 0.85f + 0.15f * Mathf.Sin(num5 * 0.7f + (float)seed);
			array[i] = (num2 * 2f + (num3 - num4) * 0.8f) * 0.16f * num7;
		}
		int num8 = (int)(seconds * dropsPerSec);
		for (int j = 0; j < num8; j++)
		{
			int num9 = random.Next(num - 2756);
			float num10 = 0.03f + (float)random.NextDouble() * 0.05f;
			float num11 = 900f + (float)random.NextDouble() * 2200f;
			int num12 = 551;
			for (int k = 0; k < num12; k++)
			{
				float num13 = (float)k / 22050f;
				array[num9 + k] += Mathf.Sin(num13 * num11 * 6.28f) * Mathf.Exp((0f - num13) * 220f) * num10;
			}
		}
		int num14 = 22050;
		for (int l = 0; l < num14; l++)
		{
			float num15 = (float)l / (float)num14;
			array[l] = array[l] * num15 + array[num - num14 + l] * (1f - num15);
		}
		float[] array2 = new float[num - num14];
		Array.Copy(array, array2, num - num14);
		return Clip("Rain" + seed, array2, 22050);
	}

	private static AudioClip SynthWindLoop(int seed, float seconds)
	{
		int num = (int)(22050f * seconds);
		float[] array = new float[num];
		Random random = new Random(seed);
		float num2 = 0f;
		float num3 = 0f;
		float num4 = 0f;
		for (int i = 0; i < num; i++)
		{
			float num5 = (float)i / 22050f;
			float num6 = (float)(random.NextDouble() * 2.0 - 1.0);
			num2 += 0.015f * (num6 - num2);
			num3 += 0.05f * (num6 - num3);
			num4 += 0.6f * (num3 - num4);
			float num7 = 0.65f + 0.35f * Mathf.Sin(num5 * 0.9f + (float)seed) * Mathf.Sin(num5 * 0.37f + 1.3f);
			array[i] = (num2 * 3.2f + num4 * 0.8f) * 0.5f * num7;
		}
		int num8 = 22050;
		for (int j = 0; j < num8; j++)
		{
			float num9 = (float)j / (float)num8;
			array[j] = array[j] * num9 + array[num - num8 + j] * (1f - num9);
		}
		float[] array2 = new float[num - num8];
		Array.Copy(array, array2, num - num8);
		return Clip("Wind" + seed, array2, 22050);
	}

	private static AudioClip SynthThunder(int seed)
	{
		int num = 121275;
		float[] array = new float[num];
		Random random = new Random(seed);
		float num2 = 0f;
		float num3 = 0f;
		float num4 = 0.05f + (float)random.NextDouble() * 0.09f;
		float num5 = 1.1f + (float)random.NextDouble() * 0.9f;
		float num6 = 11f + (float)random.NextDouble() * 12f;
		for (int i = 0; i < num; i++)
		{
			float num7 = (float)i / 22050f;
			float num8 = (float)(random.NextDouble() * 2.0 - 1.0);
			num2 += 0.04f * (num8 - num2);
			num3 += 0.3f * (num8 - num3);
			float num9 = num3 * (Mathf.Exp((0f - num7) * 11f) + 0.7f * Mathf.Exp((0f - Mathf.Max(0f, num7 - num4)) * 13f) * ((num7 > num4) ? 1f : 0f));
			float num10 = num2 * 5f * Mathf.Exp((0f - num7) * 0.9f) * (0.65f + 0.35f * Mathf.Sin(num7 * num6 + (float)seed));
			float num11 = num2 * 2.6f * Mathf.Exp((0f - Mathf.Max(0f, num7 - num5)) * 1.6f) * ((num7 > num5) ? 1f : 0f);
			array[i] = Mathf.Clamp(num9 * 0.55f + num10 + num11, -1f, 1f) * 0.55f;
		}
		return Clip("Thunder", array, 22050);
	}

	private static AudioClip Clip(string name, float[] samples, int rate)
	{
		AudioClip val = AudioClip.Create(name, samples.Length, 1, rate, false);
		if (_setData == null)
		{
			_setData = typeof(AudioClip).GetMethod("SetData", new Type[2]
			{
				typeof(float[]),
				typeof(int)
			});
		}
		_setData.Invoke(val, new object[2] { samples, 0 });
		return val;
	}

	private unsafe static bool Pressed(KeyCode key)
	{
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_0077: Unknown result type (might be due to invalid IL or missing references)
		if (_inputMode <= 1)
		{
			try
			{
				bool keyDown = Input.GetKeyDown(key);
				_inputMode = 1;
				return keyDown;
			}
			catch (Exception)
			{
				_inputMode = 2;
			}
		}
		if (_inputMode == 2)
		{
			try
			{
				Keyboard current = Keyboard.current;
				if (current == null)
				{
					return false;
				}
				if (!Enum.TryParse<Key>(((object)(*(KeyCode*)(&key))/*cast due to .constrained prefix*/).ToString(), ignoreCase: true, out Key result))
				{
					return false;
				}
				return ((ButtonControl)current[result]).wasPressedThisFrame;
			}
			catch (Exception)
			{
				_inputMode = -1;
			}
		}
		return false;
	}

	private unsafe static bool Held(KeyCode key)
	{
		//IL_0012: 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)
		if (_inputMode <= 1)
		{
			try
			{
				return Input.GetKey(key);
			}
			catch (Exception)
			{
			}
		}
		try
		{
			Keyboard current = Keyboard.current;
			if (current == null)
			{
				return false;
			}
			if (!Enum.TryParse<Key>(((object)(*(KeyCode*)(&key))/*cast due to .constrained prefix*/).ToString(), ignoreCase: true, out Key result))
			{
				return false;
			}
			return ((ButtonControl)current[result]).isPressed;
		}
		catch (Exception)
		{
			return false;
		}
	}

	private void CloseMenu()
	{
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		_menuOpen = false;
		Cursor.lockState = _wasLock;
		Cursor.visible = _wasCursor;
		if (SavePrefs != null)
		{
			SavePrefs(Volume, ThunderOn, LightningOn);
		}
	}

	private static Rect OnScreen(Rect r)
	{
		//IL_0063: 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_0067: Unknown result type (might be due to invalid IL or missing references)
		((Rect)(ref r)).x = Mathf.Clamp(((Rect)(ref r)).x, 0f, Mathf.Max(0f, (float)Screen.width - ((Rect)(ref r)).width));
		((Rect)(ref r)).y = Mathf.Clamp(((Rect)(ref r)).y, 0f, Mathf.Max(0f, (float)Screen.height - ((Rect)(ref r)).height));
		return r;
	}

	private void EnsureSkin()
	{
		//IL_006e: 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_00ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_0104: 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_0143: Unknown result type (might be due to invalid IL or missing references)
		//IL_0154: Unknown result type (might be due to invalid IL or missing references)
		//IL_0156: Unknown result type (might be due to invalid IL or missing references)
		//IL_0192: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ce: Expected O, but got Unknown
		//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e3: Expected O, but got Unknown
		//IL_0232: Unknown result type (might be due to invalid IL or missing references)
		//IL_0240: Unknown result type (might be due to invalid IL or missing references)
		//IL_0252: Unknown result type (might be due to invalid IL or missing references)
		//IL_0263: Unknown result type (might be due to invalid IL or missing references)
		//IL_026d: Expected O, but got Unknown
		//IL_0276: Unknown result type (might be due to invalid IL or missing references)
		//IL_0280: Expected O, but got Unknown
		//IL_0291: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_02bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_031a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0324: Expected O, but got Unknown
		if (!((Object)(object)_skin != (Object)null))
		{
			_skin = Object.Instantiate<GUISkin>(GUI.skin);
			Color val = default(Color);
			((Color)(ref val))..ctor(0.95f, 0.93f, 0.87f);
			Color textColor = default(Color);
			((Color)(ref textColor))..ctor(1f, 0.58f, 0.25f);
			Texture2D background = RoundedTex(44, 44, 12, new Color(0.1f, 0.09f, 0.13f, 0.94f), 2, new Color(0.93f, 0.9f, 0.84f, 0.9f));
			Texture2D background2 = RoundedTex(24, 24, 7, new Color(0.23f, 0.21f, 0.28f, 0.95f), 1, new Color(0.93f, 0.9f, 0.84f, 0.5f));
			Texture2D background3 = RoundedTex(24, 24, 7, new Color(0.95f, 0.55f, 0.2f, 0.95f), 1, new Color(1f, 1f, 1f, 0.8f));
			Texture2D background4 = RoundedTex(16, 12, 5, new Color(0.21f, 0.19f, 0.25f, 0.9f), 1, new Color(0.93f, 0.9f, 0.84f, 0.4f));
			Texture2D background5 = RoundedTex(16, 16, 7, val, 0, Color.clear);
			GUIStyle window = _skin.window;
			window.normal.background = background;
			window.onNormal.background = background;
			window.normal.textColor = textColor;
			window.onNormal.textColor = textColor;
			window.fontSize = 14;
			window.fontStyle = (FontStyle)1;
			window.border = new RectOffset(14, 14, 14, 14);
			window.padding = new RectOffset(14, 14, 28, 14);
			GUIStyle button = _skin.button;
			button.normal.background = background2;
			button.hover.background = background3;
			button.active.background = background3;
			button.focused.background = background2;
			button.normal.textColor = val;
			button.hover.textColor = Color.white;
			button.active.textColor = Color.white;
			button.border = new RectOffset(8, 8, 8, 8);
			button.padding = new RectOffset(10, 10, 5, 5);
			_skin.label.normal.textColor = val;
			_skin.toggle.normal.textColor = val;
			_skin.toggle.onNormal.textColor = textColor;
			_skin.toggle.hover.textColor = Color.white;
			_skin.toggle.onHover.textColor = textColor;
			GUIStyle horizontalSlider = _skin.horizontalSlider;
			horizontalSlider.normal.background = background4;
			horizontalSlider.border = new RectOffset(6, 6, 5, 5);
			horizontalSlider.fixedHeight = 14f;
			GUIStyle horizontalSliderThumb = _skin.horizontalSliderThumb;
			horizontalSliderThumb.normal.background = background5;
			horizontalSliderThumb.hover.background = background5;
			horizontalSliderThumb.active.background = background5;
			horizontalSliderThumb.fixedWidth = 16f;
			horizontalSliderThumb.fixedHeight = 16f;
		}
	}

	private static Texture2D RoundedTex(int wpx, int hpx, int radius, Color fill, int border, Color edge)
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Expected O, but got Unknown
		//IL_007b: 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_00df: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00da: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
		Texture2D val = new Texture2D(wpx, hpx, (TextureFormat)4, false);
		((Texture)val).wrapMode = (TextureWrapMode)1;
		for (int i = 0; i < hpx; i++)
		{
			for (int j = 0; j < wpx; j++)
			{
				float num = Mathf.Max((float)Mathf.Max(radius - j, j - (wpx - 1 - radius)), 0f);
				float num2 = Mathf.Max((float)Mathf.Max(radius - i, i - (hpx - 1 - radius)), 0f);
				float num3 = Mathf.Sqrt(num * num + num2 * num2);
				Color val2 = ((!(num3 > (float)radius + 0.5f)) ? ((border > 0 && num3 > (float)(radius - border) + 0.5f) ? edge : ((border <= 0 || (j >= border && i >= border && j < wpx - border && i < hpx - border)) ? fill : edge)) : Color.clear);
				val.SetPixel(j, i, val2);
			}
		}
		val.Apply();
		return val;
	}

	private void OnGUI()
	{
		//IL_0070: Unknown result type (might be due to invalid IL or missing references)
		//IL_007c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0090: Expected O, but got Unknown
		//IL_008b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0090: Unknown result type (might be due to invalid IL or missing references)
		//IL_0095: 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_0049: Unknown result type (might be due to invalid IL or missing references)
		//IL_005d: Expected O, but got Unknown
		//IL_0058: 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)
		EnsureSkin();
		GUISkin skin = GUI.skin;
		GUI.skin = _skin;
		DrawStormClock();
		if (_menuOpen)
		{
			if (_devMenu)
			{
				_menuRect = OnScreen(GUILayout.Window(823477, _menuRect, new WindowFunction(DrawMenu), "Weather Dev", Array.Empty<GUILayoutOption>()));
			}
			else
			{
				_playerRect = OnScreen(GUILayout.Window(823478, _playerRect, new WindowFunction(DrawPlayerMenu), "Weather", Array.Empty<GUILayoutOption>()));
			}
		}
		GUI.skin = skin;
	}

	private void DrawStormClock()
	{
		//IL_0136: Unknown result type (might be due to invalid IL or missing references)
		//IL_0137: Unknown result type (might be due to invalid IL or missing references)
		//IL_0174: Unknown result type (might be due to invalid IL or missing references)
		//IL_017f: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f8: Expected O, but got Unknown
		if (_state == 0 && _w < 0.05f)
		{
			return;
		}
		string text = ((Override >= 0) ? ((Override == 2) ? "Storm (forced)" : ((Override == 1) ? "Rain (forced)" : "")) : ((_state == 2) ? ("Storm " + FmtClock((float)(_segEnd - _nowSeconds))) : ((_state != 1) ? "Clearing" : ("Rain " + FmtClock((float)(_segEnd - _nowSeconds))))));
		if (!string.IsNullOrEmpty(text))
		{
			if (_clockStyle == null)
			{
				_clockStyle = new GUIStyle(GUI.skin.label);
				_clockStyle.alignment = (TextAnchor)6;
				_clockStyle.fontSize = 13;
			}
			Rect val = default(Rect);
			((Rect)(ref val))..ctor(12f, (float)Screen.height - 30f, 260f, 22f);
			Rect val2 = val;
			((Rect)(ref val2)).x = ((Rect)(ref val2)).x + 1f;
			((Rect)(ref val2)).y = ((Rect)(ref val2)).y + 1f;
			GUI.color = new Color(0f, 0f, 0f, 0.65f);
			GUI.Label(val2, text, _clockStyle);
			GUI.color = new Color(1f, 1f, 1f, 0.85f);
			GUI.Label(val, text, _clockStyle);
			GUI.color = Color.white;
		}
	}

	private static string FmtClock(float sec)
	{
		if (sec < 0f)
		{
			sec = 0f;
		}
		int num = (int)(sec / 60f);
		int num2 = (int)(sec % 60f);
		return num + ":" + num2.ToString("00");
	}

	private void DrawPlayerMenu(int id)
	{
		GUILayout.Label("Weather now: " + StateName(_state), Array.Empty<GUILayoutOption>());
		GUILayout.Space(8f);
		GUILayout.Label("Volume  " + Mathf.RoundToInt(Volume * 100f) + "%", Array.Empty<GUILayoutOption>());
		Volume = GUILayout.HorizontalSlider(Volume, 0f, 1f, Array.Empty<GUILayoutOption>());
		GUILayout.Space(8f);
		ThunderOn = GUILayout.Toggle(ThunderOn, "  Thunder sounds", Array.Empty<GUILayoutOption>());
		GUILayout.Space(2f);
		LightningOn = GUILayout.Toggle(LightningOn, "  Lightning strikes", Array.Empty<GUILayoutOption>());
		GUILayout.Space(10f);
		if (GUILayout.Button("Save and close", Array.Empty<GUILayoutOption>()))
		{
			CloseMenu();
		}
		GUI.DragWindow();
	}

	private void DrawMenu(int id)
	{
		//IL_0173: Unknown result type (might be due to invalid IL or missing references)
		//IL_0286: Unknown result type (might be due to invalid IL or missing references)
		//IL_028b: Unknown result type (might be due to invalid IL or missing references)
		//IL_03c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_03cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0401: Unknown result type (might be due to invalid IL or missing references)
		//IL_0411: Unknown result type (might be due to invalid IL or missing references)
		string text = ((Override < 0) ? "AUTO (shared forecast)" : ((Override == 0) ? "forced CLEAR" : ((Override == 1) ? "forced RAIN" : "forced STORM")));
		GUILayout.Label("Mode: " + text + "   blend: " + _w.ToString("0.00"), Array.Empty<GUILayoutOption>());
		int num = StateAt(_nowSeconds);
		GUILayout.Label("Forecast: " + StateName(num) + " > " + StateName(StateOfEpoch(_segIndex + 1)) + " > " + StateName(StateOfEpoch(_segIndex + 2)) + "   (" + FmtTime((float)(_segEnd - _nowSeconds)) + " left)", Array.Empty<GUILayoutOption>());
		if (num == 2 && Override < 0 && !DarkEnough())
		{
			GUILayout.Label("(storm spell is WAITING ON THE LIGHT - rolling as rain until late afternoon)", Array.Empty<GUILayoutOption>());
		}
		bool flag = _w * Intensity > 0.7f;
		GUILayout.Label("Wind: " + ((Vector3)(ref _gale)).magnitude.ToString("0.0") + " m/s " + Compass(_gale) + "   next bolt: " + (flag ? (Mathf.Max(0f, _nextStrike).ToString("0") + "s") : "-") + "   storm sky: " + (((Object)(object)_shadeMat != (Object)null) ? "adopted" : "searching"), Array.Empty<GUILayoutOption>());
		_debugOpen = GUILayout.Toggle(_debugOpen, "Debug info", Array.Empty<GUILayoutOption>());
		Camera val = Eye();
		if (_debugOpen)
		{
			GUILayout.Label("Truth: shade " + (((Object)(object)_shadeMat != (Object)null) ? ("on a=" + _lidA.ToString("0.00")) : "MISSING") + "  localK " + _localK.ToString("0.00") + "  fog " + ((object)RenderSettings.fogMode/*cast due to .constrained prefix*/).ToString() + " d=" + RenderSettings.fogDensity.ToString("0.0000") + " end=" + RenderSettings.fogEndDistance.ToString("0") + "  far=" + (((Object)(object)val != (Object)null) ? val.farClipPlane.ToString("0") : "?"), Array.Empty<GUILayoutOption>());
		}
		if (_debugOpen && (Object)(object)_shadeR != (Object)null)
		{
			GUILayout.Label("Shade: vis=" + ((Renderer)_shadeR).isVisible + " on=" + (((Renderer)_shadeR).enabled && ((Component)_shadeR).gameObject.activeInHierarchy) + " q=" + _shadeMat.renderQueue + " scale=" + ((Component)_shadeR).transform.lossyScale.x.ToString("0.00") + " dist=" + (((Object)(object)val != (Object)null) ? Vector3.Distance(((Component)val).transform.position, ((Component)_shadeR).transform.position).ToString("0") : "?") + "  deckA vis=" + ((Object)(object)_deckAR != (Object)null && ((Renderer)_deckAR).isVisible) + " q=" + (((Object)(object)_deckAMat != (Object)null) ? _deckAMat.renderQueue.ToString() : "?"), Array.Empty<GUILayoutOption>());
		}
		GUILayout.Label("Audio: " + (_realRain ? "rain file" : "synth rain") + (_realStorm ? " + storm file" : "") + (_realWind ? " + wind file" : "") + " | thunder: " + ((_thunderFiles.Count > 0) ? (_thunderFiles.Count + " file(s)") : "synth"), Array.Empty<GUILayoutOption>());
		GUILayout.Space(4f);
		GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
		if (GUILayout.Button("Auto", Array.Empty<GUILayoutOption>()))
		{
			Override = -1;
		}
		if (GUILayout.Button("Clear", Array.Empty<GUILayoutOption>()))
		{
			Override = 0;
		}
		if (GUILayout.Button("Rain", Array.Empty<GUILayoutOption>()))
		{
			Override = 1;
		}
		if (GUILayout.Button("Storm", Array.Empty<GUILayoutOption>()))
		{
			Override = 2;
		}
		GUILayout.EndHorizontal();
		if (GUILayout.Button("Snap blend (skip the slow roll-in)", Array.Empty<GUILayoutOption>()))
		{
			_w = ((_state == 2) ? 1f : ((_state == 1) ? 0.45f : 0f));
		}
		GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
		if (GUILayout.Button("Bolt strike NOW", Array.Empty<GUILayoutOption>()))
		{
			Strike(fromMenu: true);
		}
		if (GUILayout.Button("Distant sheet flash", Array.Empty<GUILayoutOption>()))
		{
			_flash = 0.27f;
			_flashScale = 0.35f;
			_lastDelay = 3.4f;
			_pendingThunder = _lastDelay;
		}
		GUILayout.EndHorizontal();
		GUILayout.Space(4f);
		GUILayout.Label("Volume: " + Volume.ToString("0.00") + "   (saved when you close this menu)", Array.Empty<GUILayoutOption>());
		Volume = GUILayout.HorizontalSlider(Volume, 0f, 1f, Array.Empty<GUILayoutOption>());
		GUILayout.Space(4f);
		GUILayout.Label("Forced states are local to you - Auto returns to the shared forecast.", Array.Empty<GUILayoutOption>());
		GUI.DragWindow();
	}

	private static string StateName(int st)
	{
		return st switch
		{
			1 => "rain", 
			2 => "STORM", 
			_ => "clear", 
		};
	}

	private static string FmtTime(float sec)
	{
		if (sec >= 90f)
		{
			return Mathf.CeilToInt(sec / 60f) + " min";
		}
		return Mathf.CeilToInt(sec) + "s";
	}

	private static string Compass(Vector3 v)
	{
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		if (((Vector3)(ref v)).sqrMagnitude < 0.01f)
		{
			return "calm";
		}
		float num = Mathf.Atan2(v.x, v.z) * 57.29578f;
		if (num < 0f)
		{
			num += 360f;
		}
		string[] array = new string[8] { "N", "NE", "E", "SE", "S", "SW", "W", "NW" };
		return "to the " + array[Mathf.RoundToInt(num / 45f) % 8];
	}

	private static Camera Eye()
	{
		Camera val = null;
		Camera[] allCameras = Camera.allCameras;
		foreach (Camera val2 in allCameras)
		{
			if (!((Object)(object)val2 == (Object)null) && ((Behaviour)val2).isActiveAndEnabled && !((Object)(object)val2.targetTexture != (Object)null) && ((Object)(object)val == (Object)null || val2.depth > val.depth))
			{
				val = val2;
			}
		}
		return ((Object)(object)val != (Object)null) ? val : Camera.main;
	}

	private static Func<double> MakeNetClock()
	{
		try
		{
			Type type = Type.GetType("FishNet.InstanceFinder, FishNet.Runtime");
			if (type == null)
			{
				return null;
			}
			PropertyInfo tmProp = type.GetProperty("TimeManager", BindingFlags.Static | BindingFlags.Public);
			if (tmProp == null)
			{
				return null;
			}
			PropertyInfo tickProp = null;
			PropertyInfo deltaProp = null;
			return delegate
			{
				try
				{
					object value = tmProp.GetValue(null, null);
					if (value == null)
					{
						return -1.0;
					}
					if (tickProp == null)
					{
						tickProp = value.GetType().GetProperty("Tick");
						deltaProp = value.GetType().GetProperty("TickDelta");
					}
					if (tickProp == null || deltaProp == null)
					{
						return -1.0;
					}
					uint num = Convert.ToUInt32(tickProp.GetValue(value, null));
					if (num == 0)
					{
						return -1.0;
					}
					return (double)num * Convert.ToDouble(deltaProp.GetValue(value, null));
				}
				catch (Exception)
				{
					return -1.0;
				}
			};
		}
		catch (Exception)
		{
			return null;
		}
	}

	private void OnDestroy()
	{
		//IL_0037: 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_007b: Unknown result type (might be due to invalid IL or missing references)
		//IL_018b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0197: Unknown result type (might be due to invalid IL or missing references)
		Color val = default(Color);
		((Color)(ref val))..ctor(1f, 1f, 1f, 0f);
		if ((Object)(object)_shadeMat != (Object)null)
		{
			_shadeMat.SetColor("_Tint", val);
		}
		if ((Object)(object)_deckAMat != (Object)null)
		{
			_deckAMat.SetColor("_Tint", val);
		}
		if ((Object)(object)_deckBMat != (Object)null)
		{
			_deckBMat.SetColor("_Tint", val);
		}
		if ((Object)(object)_veilRoot != (Object)null)
		{
			Object.Destroy((Object)(object)_veilRoot);
		}
		if ((Object)(object)_bolt != (Object)null)
		{
			Object.Destroy((Object)(object)((Component)_bolt).gameObject);
		}
		if ((Object)(object)_branchA != (Object)null)
		{
			Object.Destroy((Object)(object)((Component)_branchA).gameObject);
		}
		if ((Object)(object)_branchB != (Object)null)
		{
			Object.Destroy((Object)(object)((Component)_branchB).gameObject);
		}
		if (!_dayNightPresent && _tookBase)
		{
			foreach (KeyValuePair<Light, float> item in _baseIntensity)
			{
				if ((Object)(object)item.Key != (Object)null)
				{
					item.Key.intensity = item.Value;
				}
			}
			RenderSettings.fogDensity = _baseFogDensity;
			RenderSettings.fogColor = _baseFogColor;
			RenderSettings.ambientLight = _baseAmbient;
			RenderSettings.ambientIntensity = _baseAmbientStrength;
		}
		if (_tookFogLine)
		{
			RenderSettings.fog = _baseFogOn;
			RenderSettings.fogStartDistance = _baseFogStart;
			RenderSettings.fogEndDistance = _baseFogEnd;
		}
	}
}