Decompiled source of PhotoMod v1.0.0

PhotoMod.dll

Decompiled 5 hours ago
using System;
using System.Buffers.Binary;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Numerics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.Json;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using AskaPhotoMod.Core;
using AskaShared.Game;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using BepInEx.Unity.IL2CPP.Utils;
using Cinemachine;
using Fusion;
using HarmonyLib;
using Il2CppInterop.Runtime;
using Il2CppInterop.Runtime.Injection;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem.Collections.Generic;
using Il2CppSystem.Threading.Tasks;
using Microsoft.CodeAnalysis;
using SSSGame;
using SSSGame.InputContext;
using SSSGame.Network;
using SSSGame.Weather;
using SandSailorStudio;
using SandSailorStudio.Localization;
using SandSailorStudio.Storage;
using Steamworks;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.Rendering;
using UnityEngine.Rendering.HighDefinition;
using UnityEngine.SceneManagement;
using UnityEngine.VFX;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("PhotoMod")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+7f1b23a20317209a29872d4a6e3a46ca8a15ccfb")]
[assembly: AssemblyProduct("Photo Mod")]
[assembly: AssemblyTitle("PhotoMod")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte flag)
		{
			NullableFlags = new byte[1] { flag };
		}

		public NullableAttribute(byte[] flags)
		{
			NullableFlags = flags;
		}
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte flag)
		{
			Flag = flag;
		}
	}
}
namespace AskaPhotoMod
{
	[HarmonyPatch(typeof(WeatherSystem), "_CheckNightDayTransition")]
	internal static class DayEventHold
	{
		private static IntPtr _visitWeather;

		private static bool _entryIsNight;

		private static bool _pinned;

		private static int _lastSunriseDay;

		private static int _lastNighfallDay;

		private static int _lastSeasonChangeMessageDay;

		private static bool PhotoModeActive => GamePorts.PhotoModeActive;

		[HarmonyPrefix]
		private static void Prefix(WeatherSystem __instance)
		{
			if (!PhotoModeActive && _visitWeather == IntPtr.Zero)
			{
				return;
			}
			if (_visitWeather != IntPtr.Zero && _visitWeather != ((Il2CppObjectBase)__instance).Pointer)
			{
				_visitWeather = IntPtr.Zero;
			}
			if (PhotoModeActive)
			{
				if (_visitWeather == IntPtr.Zero)
				{
					_visitWeather = ((Il2CppObjectBase)__instance).Pointer;
					_entryIsNight = __instance._isNight;
				}
			}
			else
			{
				if (_visitWeather == IntPtr.Zero)
				{
					return;
				}
				_visitWeather = IntPtr.Zero;
				if (__instance._isNight == _entryIsNight)
				{
					return;
				}
			}
			_pinned = true;
			_lastSunriseDay = __instance._lastSunriseDay;
			_lastNighfallDay = __instance._lastNighfallDay;
			_lastSeasonChangeMessageDay = __instance._lastSeasonChangeMessageDay;
			int lastSeasonChangeMessageDay = (__instance._lastNighfallDay = (__instance._lastSunriseDay = __instance.dayOfYear));
			__instance._lastSeasonChangeMessageDay = lastSeasonChangeMessageDay;
		}

		[HarmonyPostfix]
		private static void Postfix(WeatherSystem __instance)
		{
			if (_pinned)
			{
				_pinned = false;
				__instance._lastSunriseDay = _lastSunriseDay;
				__instance._lastNighfallDay = _lastNighfallDay;
				__instance._lastSeasonChangeMessageDay = _lastSeasonChangeMessageDay;
			}
		}
	}
	internal sealed class FogAndExposure
	{
		private const float MinMeanFreePath = 1f;

		private float _fog = 1f;

		private float _exposure;

		private bool _instantExposure;

		private float _gameMeanFreePath;

		private float _gameCompensation;

		private int _meanFreePathReleasedFrame = -1;

		private int _compensationReleasedFrame = -1;

		public float Fog => _fog;

		public float Exposure => _exposure;

		public bool InstantExposure
		{
			get
			{
				return _instantExposure;
			}
			set
			{
				_instantExposure = value;
				ApplyExposureOverride();
			}
		}

		public void SetFog(float multiple, Camera camera)
		{
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Expected O, but got Unknown
			Fog fog = ModVolume.Fog;
			if (multiple == 1f)
			{
				((VolumeComponent)fog).active = false;
				((VolumeParameter)fog.enabled).overrideState = false;
				ReleaseMeanFreePath(fog);
			}
			else if (multiple == 0f)
			{
				((VolumeParameter<bool>)(object)fog.enabled).Override(false);
				ReleaseMeanFreePath(fog);
				((VolumeComponent)fog).active = true;
			}
			else
			{
				if (!((VolumeParameter)fog.meanFreePath).overrideState && Time.frameCount > _meanFreePathReleasedFrame)
				{
					_gameMeanFreePath = ((VolumeParameter<float>)(object)GameStack(camera).GetComponent<Fog>().meanFreePath).value;
					ManualLogSource log = Plugin.Log;
					bool flag = default(bool);
					BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(58, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Fog override on: the game's fog mean free path here is ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(_gameMeanFreePath, "0.#");
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" m.");
					}
					log.LogInfo(val);
				}
				((VolumeParameter<bool>)(object)fog.enabled).Override(true);
				((VolumeParameter<float>)(object)fog.meanFreePath).Override(Mathf.Max(1f, _gameMeanFreePath / multiple));
				((VolumeComponent)fog).active = true;
			}
			_fog = multiple;
		}

		public void SetExposure(float stops, Camera camera)
		{
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Expected O, but got Unknown
			Exposure exposure = ModVolume.Exposure;
			if (stops == 0f)
			{
				if (((VolumeParameter)exposure.compensation).overrideState)
				{
					((VolumeParameter)exposure.compensation).overrideState = false;
					_compensationReleasedFrame = Time.frameCount;
				}
			}
			else
			{
				if (!((VolumeParameter)exposure.compensation).overrideState && Time.frameCount > _compensationReleasedFrame)
				{
					_gameCompensation = ((VolumeParameter<float>)(object)GameStack(camera).GetComponent<Exposure>().compensation).value;
					ManualLogSource log = Plugin.Log;
					bool flag = default(bool);
					BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(70, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Exposure override on: the game's exposure compensation here is ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(_gameCompensation, "0.##");
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" stops.");
					}
					log.LogInfo(val);
				}
				((VolumeParameter<float>)(object)exposure.compensation).Override(_gameCompensation + stops);
			}
			_exposure = stops;
			ApplyExposureOverride();
		}

		private void ApplyExposureOverride()
		{
			Exposure exposure = ModVolume.Exposure;
			if (_instantExposure)
			{
				((VolumeParameter<AdaptationMode>)(object)exposure.adaptationMode).Override((AdaptationMode)0);
			}
			else
			{
				((VolumeParameter)exposure.adaptationMode).overrideState = false;
			}
			((VolumeComponent)exposure).active = _instantExposure || _exposure != 0f;
		}

		private void ReleaseMeanFreePath(Fog fog)
		{
			if (((VolumeParameter)fog.meanFreePath).overrideState)
			{
				((VolumeParameter)fog.meanFreePath).overrideState = false;
				_meanFreePathReleasedFrame = Time.frameCount;
			}
		}

		private static VolumeStack GameStack(Camera camera)
		{
			return HDCamera.GetOrCreate(camera, 0).volumeStack ?? throw new InvalidOperationException("Camera '" + ((Object)camera).name + "' has no HDRP volume stack");
		}
	}
	internal sealed class GamePorts : ICameraPort, ISubjectsPort, IInputPort, IWorldPort, ISessionInfoPort, ISaveGatePort, IEffectsPort
	{
		private const int PhotoContextPriority = 10000;

		private static Context _photoContext;

		private InputManager _inputManager;

		private readonly PhysicalLensRig _lens = new PhysicalLensRig();

		private const float InsideRadius = 0.01f;

		private Mesh _baked;

		private readonly HashSet<IntPtr> _pickRoots = new HashSet<IntPtr>();

		private readonly List<Transform> _pickRootList = new List<Transform>();

		private readonly List<Transform> _hitSkinned = new List<Transform>();

		private readonly List<Vector3> _pickVertices = new List<Vector3>();

		private readonly List<int> _pickTriangles = new List<int>();

		internal const int CollisionMask = -2147481600;

		private readonly SubjectHider _hider = new SubjectHider();

		private readonly FogAndExposure _fogAndExposure = new FogAndExposure();

		private WeatherOverride? _forcedWeather;

		private bool _debugEventBeforeForce;

		private ProgressingWeatherConditionConfig _debugConfigBeforeForce;

		private float _debugProgressBeforeForce;

		private float _snowBaselineBeforeForce;

		private float _wetnessBaselineBeforeForce;

		private const int SettleDelayFrames = 2;

		private const float SettleStepSeconds = 0.05f;

		private const uint SettleSteps = 40u;

		private int _settleFrame = -1;

		private Season? _seasonPreset;

		private SuperSeason _superSeasonBeforePreset;

		internal static bool PhotoModeActive;

		public bool BrainEnabled
		{
			get
			{
				return ((Behaviour)Brain()).enabled;
			}
			set
			{
				((Behaviour)Brain()).enabled = value;
			}
		}

		public CameraPose Pose
		{
			get
			{
				//IL_000c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0011: Unknown result type (might be due to invalid IL or missing references)
				//IL_0012: Unknown result type (might be due to invalid IL or missing references)
				//IL_0017: Unknown result type (might be due to invalid IL or missing references)
				//IL_0018: Unknown result type (might be due to invalid IL or missing references)
				//IL_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)
				//IL_002f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0035: Unknown result type (might be due to invalid IL or missing references)
				//IL_003b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0041: Unknown result type (might be due to invalid IL or missing references)
				Transform transform = ((Component)GameCamera()).transform;
				Vector3 position = transform.position;
				Quaternion rotation = transform.rotation;
				return new CameraPose(new Vector3(position.x, position.y, position.z), new Quaternion(rotation.x, rotation.y, rotation.z, rotation.w));
			}
			set
			{
				//IL_002f: 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)
				((Component)GameCamera()).transform.SetPositionAndRotation(new Vector3(value.Position.X, value.Position.Y, value.Position.Z), new Quaternion(value.Rotation.X, value.Rotation.Y, value.Rotation.Z, value.Rotation.W));
			}
		}

		public float FieldOfView => GameCamera().fieldOfView;

		public bool PhysicalLens
		{
			get
			{
				return _lens.IsOn;
			}
			set
			{
				if (value)
				{
					_lens.SwitchOn(GameCamera());
				}
				else
				{
					_lens.SwitchOff();
				}
			}
		}

		public Vector3 CharacterPosition
		{
			get
			{
				//IL_0019: Unknown result type (might be due to invalid IL or missing references)
				//IL_001e: Unknown result type (might be due to invalid IL or missing references)
				//IL_001f: 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_002b: Unknown result type (might be due to invalid IL or missing references)
				Vector3 position = ((Component)(LocalPlayerTool.LocalCharacter ?? throw new InvalidOperationException("No local character"))).transform.position;
				return new Vector3(position.x, position.y, position.z);
			}
		}

		public bool HudHidden
		{
			get
			{
				return Manager().HideAllUI;
			}
			set
			{
				Manager().HideAllUI = value;
			}
		}

		public bool GameInputBlocked
		{
			get
			{
				if ((Object)(object)_photoContext != (Object)null)
				{
					return Manager().HasContext(_photoContext);
				}
				return false;
			}
			set
			{
				if (value)
				{
					Manager().AddContext(PhotoContext());
				}
				else
				{
					Manager().RemoveContext(PhotoContext());
				}
			}
		}

		public bool CursorFree
		{
			get
			{
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				//IL_000d: Invalid comparison between Unknown and I4
				if (Cursor.visible)
				{
					return (int)Cursor.lockState != 1;
				}
				return false;
			}
			set
			{
				Cursor.lockState = (CursorLockMode)(!value);
				Cursor.visible = value;
			}
		}

		public bool ClockFrozen
		{
			get
			{
				return !Weather().TimeRunningEnabled;
			}
			set
			{
				Weather().TimeRunningEnabled = !value;
			}
		}

		public float TimeScale
		{
			get
			{
				return Time.timeScale;
			}
			set
			{
				Time.timeScale = value;
			}
		}

		public bool SimulationPaused
		{
			get
			{
				return (Runner()._simulation ?? throw new InvalidOperationException("NetworkRunner has no simulation")).IsPaused;
			}
			set
			{
				Runner().SinglePlayerPause(value);
			}
		}

		public float TimeOfDay
		{
			get
			{
				return Weather().TimeOfDay;
			}
			set
			{
				WeatherSystem obj = Weather();
				obj.SetGameTime(value);
				MustUpdateWeather(obj);
			}
		}

		public float Fog
		{
			get
			{
				return _fogAndExposure.Fog;
			}
			set
			{
				_fogAndExposure.SetFog(value, GameCamera());
			}
		}

		public float Exposure
		{
			get
			{
				return _fogAndExposure.Exposure;
			}
			set
			{
				_fogAndExposure.SetExposure(value, GameCamera());
			}
		}

		public bool InstantExposure
		{
			get
			{
				return _fogAndExposure.InstantExposure;
			}
			set
			{
				_fogAndExposure.InstantExposure = value;
			}
		}

		public WeatherOverride? ForcedWeather
		{
			get
			{
				return _forcedWeather;
			}
			set
			{
				//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ff: Expected O, but got Unknown
				WeatherSystem val = Weather();
				if (value.HasValue)
				{
					WeatherOverride valueOrDefault = value.GetValueOrDefault();
					bool num = _forcedWeather?.Preset != valueOrDefault.Preset;
					ProgressingWeatherConditionConfig debugWeatherCondition = ((num && valueOrDefault.Preset != WeatherPreset.Clear) ? WeatherEventConfig(valueOrDefault.Preset) : null);
					if (!_forcedWeather.HasValue)
					{
						_debugEventBeforeForce = val.debugWeatherEvent;
						_debugConfigBeforeForce = val.debugWeatherCondition;
						_debugProgressBeforeForce = val.weatherConditionProgressDebug;
						_snowBaselineBeforeForce = val.debugSnowBeforeStorm;
						_wetnessBaselineBeforeForce = val.debugWetnessBeforeStorm;
						val.debugSnowBeforeStorm = val.Snow;
						val.debugWetnessBeforeStorm = val.Wetness;
					}
					if (num)
					{
						val.debugWeatherCondition = debugWeatherCondition;
						ManualLogSource log = Plugin.Log;
						bool flag = default(bool);
						BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(23, 1, ref flag);
						if (flag)
						{
							((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Weather preset ");
							((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<WeatherPreset>(valueOrDefault.Preset);
							((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" forced.");
						}
						log.LogInfo(val2);
					}
					val.weatherConditionProgressDebug = valueOrDefault.DebugProgress;
					val.debugWeatherEvent = true;
				}
				else if (_forcedWeather.HasValue)
				{
					val.Snow = val.debugSnowBeforeStorm;
					val.Wetness = val.debugWetnessBeforeStorm;
					val.debugWeatherEvent = _debugEventBeforeForce;
					val.debugWeatherCondition = _debugConfigBeforeForce;
					val.weatherConditionProgressDebug = _debugProgressBeforeForce;
					val.debugSnowBeforeStorm = _snowBaselineBeforeForce;
					val.debugWetnessBeforeStorm = _wetnessBaselineBeforeForce;
					Plugin.Log.LogInfo((object)"Weather back on the game's forecast.");
				}
				_forcedWeather = value;
				val.ForceRefresh();
				RequestPrecipitationSettle();
			}
		}

		public float Snow
		{
			get
			{
				return Weather().Snow;
			}
			set
			{
				WeatherSystem val = Weather();
				if (_forcedWeather.HasValue)
				{
					val.debugSnowBeforeStorm = value;
					val.ForceRefresh();
				}
				else
				{
					val.Snow = value;
					MustUpdateWeather(val);
				}
			}
		}

		public float Wetness
		{
			get
			{
				return Weather().Wetness;
			}
			set
			{
				Weather().Wetness = value;
			}
		}

		public Season? SeasonPreset
		{
			get
			{
				return _seasonPreset;
			}
			set
			{
				//IL_0106: Unknown result type (might be due to invalid IL or missing references)
				//IL_010d: Expected O, but got Unknown
				//IL_0075: Unknown result type (might be due to invalid IL or missing references)
				//IL_007c: Expected O, but got Unknown
				WeatherSystem val = Weather();
				bool flag = default(bool);
				if (value.HasValue)
				{
					Season valueOrDefault = value.GetValueOrDefault();
					if (!_seasonPreset.HasValue)
					{
						_superSeasonBeforePreset = val.CurrentSuperSeason;
					}
					SuperSeason val2 = SuperSeasonFrom(val, valueOrDefault);
					val.CurrentSuperSeason = null;
					val.CurrentSuperSeason = val2;
					if (_seasonPreset != valueOrDefault)
					{
						ManualLogSource log = Plugin.Log;
						BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(55, 2, ref flag);
						if (flag)
						{
							((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Season preset ");
							((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<Season>(valueOrDefault);
							((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(": super season built from base season '");
							BepInExInfoLogInterpolatedStringHandler obj = val3;
							SeasonConfig config = ((Season)val2).config;
							((BepInExLogInterpolatedStringHandler)obj).AppendFormatted<string>((config != null) ? ((Object)config).name : null);
							((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("'.");
						}
						log.LogInfo(val3);
					}
				}
				else if (_seasonPreset.HasValue)
				{
					val.CurrentSuperSeason = null;
					if (_superSeasonBeforePreset != null)
					{
						val.CurrentSuperSeason = _superSeasonBeforePreset;
					}
					ManualLogSource log2 = Plugin.Log;
					BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(44, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Season preset off: super season '");
						BepInExInfoLogInterpolatedStringHandler obj2 = val3;
						SuperSeason superSeasonBeforePreset = _superSeasonBeforePreset;
						object obj3;
						if (superSeasonBeforePreset == null)
						{
							obj3 = null;
						}
						else
						{
							SeasonConfig config2 = ((Season)superSeasonBeforePreset).config;
							obj3 = ((config2 != null) ? ((Object)config2).name : null);
						}
						if (obj3 == null)
						{
							obj3 = "none";
						}
						((BepInExLogInterpolatedStringHandler)obj2).AppendFormatted<string>((string)obj3);
						((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("' put back.");
					}
					log2.LogInfo(val3);
					_superSeasonBeforePreset = null;
				}
				if (_seasonPreset != value)
				{
					RequestPrecipitationSettle();
				}
				_seasonPreset = value;
				MustUpdateWeather(val);
			}
		}

		public float? FoliageTint
		{
			get
			{
				return SeasonTint.Override;
			}
			set
			{
				WeatherSystem ws = Weather();
				SeasonTint.Override = value;
				MustUpdateWeather(ws);
			}
		}

		public bool IsSinglePlayer => (int)SessionRole() == 1;

		bool ISessionInfoPort.PhotoModeActive
		{
			get
			{
				return PhotoModeActive;
			}
			set
			{
				PhotoModeActive = value;
				if (value)
				{
					_settleFrame = -1;
				}
			}
		}

		public bool SaveInProgress
		{
			get
			{
				Task savingTask = (Object.FindObjectOfType<StorageManager>() ?? throw new InvalidOperationException("StorageManager not found"))._savingTask;
				if (savingTask != null)
				{
					return !savingTask.IsCompleted;
				}
				return false;
			}
		}

		public void SetLens(RenderedLens lens)
		{
			_lens.Apply(lens);
		}

		public Vector3? SurfaceAt(Vector2 viewportPoint)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: 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_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			Ray ray = GameCamera().ViewportPointToRay(new Vector3(viewportPoint.X, viewportPoint.Y, 0f));
			float? num = PickDistance(ray);
			if (!num.HasValue)
			{
				return null;
			}
			Vector3 point = ((Ray)(ref ray)).GetPoint(num.Value);
			return new Vector3(point.x, point.y, point.z);
		}

		private float? PickDistance(Ray ray)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: 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_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			RaycastHit[] array = Il2CppArrayBase<RaycastHit>.op_Implicit((Il2CppArrayBase<RaycastHit>)(object)Physics.RaycastAll(ray, float.PositiveInfinity, -5, (QueryTriggerInteraction)2));
			float num = float.PositiveInfinity;
			_hitSkinned.Clear();
			RaycastHit[] array2 = array;
			for (int i = 0; i < array2.Length; i++)
			{
				RaycastHit val = array2[i];
				Transform val2 = SkinnedSubject(((RaycastHit)(ref val)).collider);
				_hitSkinned.Add(val2);
				if ((Object)(object)val2 == (Object)null && !((RaycastHit)(ref val)).collider.isTrigger && ((RaycastHit)(ref val)).distance < num)
				{
					num = ((RaycastHit)(ref val)).distance;
				}
			}
			_pickRoots.Clear();
			_pickRootList.Clear();
			for (int j = 0; j < array.Length; j++)
			{
				if ((Object)(object)_hitSkinned[j] != (Object)null && ((RaycastHit)(ref array[j])).distance <= num)
				{
					AddPickRoot(_hitSkinned[j]);
				}
			}
			foreach (Collider item in (Il2CppArrayBase<Collider>)(object)Physics.OverlapSphere(((Ray)(ref ray)).origin, 0.01f, -5, (QueryTriggerInteraction)2))
			{
				Transform val3 = SkinnedSubject(item);
				if (val3 != null)
				{
					AddPickRoot(val3);
				}
			}
			float num2 = default(float);
			foreach (Transform pickRoot in _pickRootList)
			{
				foreach (SkinnedMeshRenderer componentsInChild in ((Component)pickRoot).GetComponentsInChildren<SkinnedMeshRenderer>())
				{
					if (!((Renderer)componentsInChild).enabled)
					{
						continue;
					}
					Bounds bounds = ((Renderer)componentsInChild).bounds;
					if (((Bounds)(ref bounds)).IntersectRay(ray, ref num2) && !(num2 >= num))
					{
						float? num3 = MeshDistance(componentsInChild, ray);
						if (num3 < num)
						{
							num = num3.Value;
						}
					}
				}
			}
			if (!float.IsPositiveInfinity(num))
			{
				return num;
			}
			return null;
		}

		private static Transform SkinnedSubject(Collider collider)
		{
			Component componentInParent = (Component)(object)((Component)collider).GetComponentInParent<Character>();
			if ((Object)(object)componentInParent == (Object)null)
			{
				componentInParent = (Component)(object)((Component)collider).GetComponentInParent<Creature>();
			}
			if ((Object)(object)componentInParent != (Object)null && SubjectHider.IsDen(componentInParent))
			{
				return null;
			}
			if (!((Object)(object)componentInParent != (Object)null) || !((Object)(object)componentInParent.GetComponentInChildren<SkinnedMeshRenderer>(true) != (Object)null))
			{
				return null;
			}
			return componentInParent.transform;
		}

		private void AddPickRoot(Transform root)
		{
			if (_pickRoots.Add(((Il2CppObjectBase)root).Pointer))
			{
				_pickRootList.Add(root);
			}
		}

		private float? MeshDistance(SkinnedMeshRenderer skin, Ray ray)
		{
			//IL_0026: 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_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Expected O, but got Unknown
			//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_0054: 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_005b: 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_006a: 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_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: 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_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: 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_0115: Unknown result type (might be due to invalid IL or missing references)
			if (_baked == null)
			{
				_baked = new Mesh();
			}
			skin.BakeMesh(_baked, true);
			Matrix4x4 localToWorldMatrix = ((Component)skin).transform.localToWorldMatrix;
			_pickVertices.Clear();
			foreach (Vector3 item in (Il2CppArrayBase<Vector3>)(object)_baked.vertices)
			{
				Vector3 val = ((Matrix4x4)(ref localToWorldMatrix)).MultiplyPoint3x4(item);
				_pickVertices.Add(new Vector3(val.x, val.y, val.z));
			}
			_pickTriangles.Clear();
			foreach (int item2 in (Il2CppArrayBase<int>)(object)_baked.triangles)
			{
				_pickTriangles.Add(item2);
			}
			Vector3 origin = ((Ray)(ref ray)).origin;
			Vector3 direction = ((Ray)(ref ray)).direction;
			return RayMesh.Nearest(new Vector3(origin.x, origin.y, origin.z), new Vector3(direction.x, direction.y, direction.z), _pickVertices, _pickTriangles);
		}

		public float? CollisionDistance(Vector3 from, Vector3 to)
		{
			//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_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: 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_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: 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_006d: 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)
			Vector3 val = default(Vector3);
			((Vector3)(ref val))..ctor(from.X, from.Y, from.Z);
			Vector3 val2 = new Vector3(to.X, to.Y, to.Z) - val;
			float magnitude = ((Vector3)(ref val2)).magnitude;
			if (magnitude == 0f)
			{
				return null;
			}
			Vector3 val3 = val2 / magnitude;
			if (Physics.CheckSphere(val, 0.3f, -2147481600, (QueryTriggerInteraction)1))
			{
				RaycastHit val4 = default(RaycastHit);
				if (!Physics.Raycast(val, val3, ref val4, magnitude, -2147481600, (QueryTriggerInteraction)1))
				{
					return null;
				}
				return ((RaycastHit)(ref val4)).distance;
			}
			RaycastHit val5 = default(RaycastHit);
			if (!Physics.SphereCast(val, 0.3f, val3, ref val5, magnitude - 0.3f, -2147481600, (QueryTriggerInteraction)1))
			{
				return null;
			}
			return ((RaycastHit)(ref val5)).distance + 0.3f;
		}

		public bool IsHidden(Subject subject)
		{
			return _hider.IsHidden(subject);
		}

		public void SetHidden(Subject subject, bool hidden)
		{
			_hider.SetHidden(subject, hidden);
		}

		public void HideNew(Subject subject)
		{
			_hider.HideNew(subject);
		}

		public void StepHiding()
		{
			_hider.Step();
		}

		public string Clock()
		{
			WeatherSystem instance = WeatherSystem.Instance;
			if (!((Object)(object)instance == (Object)null))
			{
				return $"time of day {instance.TimeOfDay:0.000} h, day of year {instance.dayOfYear}, Days Survived {instance.GetDaysPassed()}";
			}
			return "no weather system";
		}

		private void RequestPrecipitationSettle()
		{
			_settleFrame = Time.frameCount + 2;
		}

		public void StepPrecipitation()
		{
			if (_settleFrame >= 0 && Time.frameCount >= _settleFrame)
			{
				_settleFrame = -1;
				WeatherSystem instance = WeatherSystem.Instance;
				if (Time.timeScale == 0f && !((Object)(object)instance == (Object)null))
				{
					Settle(instance.vfxRainstorm);
					Settle(instance.vfxSnowstorm);
				}
			}
		}

		private static void Settle(VisualEffect vfx)
		{
			if ((Object)(object)vfx != (Object)null && ((Behaviour)vfx).isActiveAndEnabled)
			{
				vfx.Simulate(0.05f, 40u);
			}
		}

		private static ProgressingWeatherConditionConfig WeatherEventConfig(WeatherPreset preset)
		{
			string text = "WeatherEvent_" + preset;
			foreach (ProgressingWeatherConditionConfig item in Resources.FindObjectsOfTypeAll<ProgressingWeatherConditionConfig>())
			{
				if (((Object)item).name == text)
				{
					return item;
				}
			}
			throw new InvalidOperationException("No weather event config named " + text);
		}

		private static SuperSeason SuperSeasonFrom(WeatherSystem ws, Season season)
		{
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: 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_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Expected O, but got Unknown
			if (ws.seasons.Count != 4)
			{
				throw new InvalidOperationException($"WeatherSystem.seasons holds {ws.seasons.Count} base seasons, not 4");
			}
			Season val = ws.seasons[(int)season];
			float num = (float)ws.dayOfYear + ws.timeOfDay / 24f;
			return new SuperSeason
			{
				config = val.config,
				customizationData = val.customizationData,
				weatherEvents = NoWeatherEvents(),
				duration = new Vector2(num - 0.01f, num + 1f),
				transitionTimeStart = 0f,
				transitionTimeEnd = 0f,
				Initialized = false
			};
		}

		private static Il2CppReferenceArray<WeatherEvent> NoWeatherEvents()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: 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_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Expected O, but got Unknown
			return new Il2CppReferenceArray<WeatherEvent>((WeatherEvent[])(object)new WeatherEvent[1]
			{
				new WeatherEvent
				{
					SpawnChanceMultiplier = 1f,
					DurationMultiplier = 1f,
					overrideConfig = null,
					spawnChance = 1f,
					durationLimits = new Vector2(0.1f, 0.1f)
				}
			});
		}

		private static void MustUpdateWeather(WeatherSystem ws)
		{
			ws.MustUpdateNextFrame = 1;
		}

		public float? Get(LensEffect effect)
		{
			switch (effect)
			{
			case LensEffect.Vignette:
				if (!((VolumeComponent)ModVolume.Vignette).active)
				{
					return null;
				}
				return ((VolumeParameter<float>)(object)ModVolume.Vignette.intensity).value;
			case LensEffect.FilmGrain:
				if (!((VolumeComponent)ModVolume.FilmGrain).active)
				{
					return null;
				}
				return ((VolumeParameter<float>)(object)ModVolume.FilmGrain.intensity).value;
			default:
				if (!((VolumeComponent)ModVolume.LensDistortion).active)
				{
					return null;
				}
				return ((VolumeParameter<float>)(object)ModVolume.LensDistortion.intensity).value;
			}
		}

		public void Set(LensEffect effect, float? value)
		{
			switch (effect)
			{
			case LensEffect.Vignette:
				((VolumeComponent)ModVolume.Vignette).active = value.HasValue;
				if (value.HasValue)
				{
					((VolumeParameter<float>)(object)ModVolume.Vignette.intensity).Override(value.Value);
				}
				break;
			case LensEffect.FilmGrain:
				((VolumeComponent)ModVolume.FilmGrain).active = value.HasValue;
				if (value.HasValue)
				{
					((VolumeParameter<float>)(object)ModVolume.FilmGrain.intensity).Override(value.Value);
				}
				break;
			default:
				((VolumeComponent)ModVolume.LensDistortion).active = value.HasValue;
				if (value.HasValue)
				{
					((VolumeParameter<float>)(object)ModVolume.LensDistortion.intensity).Override(value.Value);
				}
				break;
			}
		}

		public Role SessionRole()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			return Session().Parameters.role;
		}

		private static NetworkSession Session()
		{
			return Object.FindObjectOfType<NetworkSession>() ?? throw new InvalidOperationException("NetworkSession not found");
		}

		private static NetworkRunner Runner()
		{
			return Session().runner ?? throw new InvalidOperationException("NetworkSession.runner is null");
		}

		private InputManager Manager()
		{
			if ((Object)(object)_inputManager == (Object)null)
			{
				_inputManager = Object.FindObjectOfType<InputManager>();
			}
			return _inputManager ?? throw new InvalidOperationException("InputManager not found");
		}

		private CinemachineBrain Brain()
		{
			return Manager().brain ?? throw new InvalidOperationException("InputManager.brain is null");
		}

		private Camera GameCamera()
		{
			return Manager().GetCamera() ?? throw new InvalidOperationException("InputManager.GetCamera() is null");
		}

		private static WeatherSystem Weather()
		{
			return WeatherSystem.Instance ?? throw new InvalidOperationException("WeatherSystem.Instance is null");
		}

		private static Context PhotoContext()
		{
			if ((Object)(object)_photoContext != (Object)null)
			{
				return _photoContext;
			}
			_photoContext = ScriptableObject.CreateInstance<Context>();
			((Object)_photoContext).name = "PhotoModPhotoMode";
			((Object)_photoContext).hideFlags = (HideFlags)61;
			_photoContext.inputMaps = new Il2CppStructArray<InputMaps>(0L);
			_photoContext.priority = 10000;
			_photoContext.dontChangeCamera = true;
			_photoContext.additive = false;
			return _photoContext;
		}
	}
	internal sealed class GuideOverlay
	{
		private const float LineWidth = 2f;

		private const float LevelTolerance = 0.25f;

		private const float TickLength = 60f;

		private static readonly Color Dim = new Color(0f, 0f, 0f, 0.6f);

		private static readonly Color Line = new Color(1f, 1f, 1f, 0.75f);

		private static readonly Color Tilted = new Color(1f, 0.82f, 0.45f, 0.95f);

		private static readonly Color Level = new Color(0.45f, 1f, 0.55f, 0.95f);

		private Texture2D _white;

		public void Draw(PhotoModeSession session)
		{
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			GuideSettings guides = session.Guides;
			if (guides.Grid || guides.Level || guides.Frame != null)
			{
				if ((Object)(object)_white == (Object)null)
				{
					_white = new Texture2D(1, 1);
					_white.SetPixel(0, 0, Color.white);
					_white.Apply();
					((Object)_white).hideFlags = (HideFlags)61;
				}
				Matrix4x4 matrix = GUI.matrix;
				Color color = GUI.color;
				GUI.matrix = Matrix4x4.identity;
				float num = Screen.width;
				float num2 = Screen.height;
				Rect val = default(Rect);
				((Rect)(ref val))..ctor(0f, 0f, num, num2);
				if (guides.Frame != null)
				{
					GuideRect guideRect = guides.Frame.FitInside(Screen.width, Screen.height);
					((Rect)(ref val))..ctor(guideRect.X, guideRect.Y, guideRect.Width, guideRect.Height);
					DrawFrame(val, num, num2);
				}
				if (guides.Grid)
				{
					DrawGrid(val);
				}
				if (guides.Level)
				{
					DrawLevel(session.RollDegrees, num, num2);
				}
				GUI.color = color;
				GUI.matrix = matrix;
			}
		}

		private void DrawFrame(Rect frame, float screenWidth, float screenHeight)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			Fill(new Rect(0f, 0f, screenWidth, ((Rect)(ref frame)).y), Dim);
			Fill(new Rect(0f, ((Rect)(ref frame)).yMax, screenWidth, screenHeight - ((Rect)(ref frame)).yMax), Dim);
			Fill(new Rect(0f, ((Rect)(ref frame)).y, ((Rect)(ref frame)).x, ((Rect)(ref frame)).height), Dim);
			Fill(new Rect(((Rect)(ref frame)).xMax, ((Rect)(ref frame)).y, screenWidth - ((Rect)(ref frame)).xMax, ((Rect)(ref frame)).height), Dim);
			Fill(new Rect(((Rect)(ref frame)).x, ((Rect)(ref frame)).y, ((Rect)(ref frame)).width, 2f), Line);
			Fill(new Rect(((Rect)(ref frame)).x, ((Rect)(ref frame)).yMax - 2f, ((Rect)(ref frame)).width, 2f), Line);
			Fill(new Rect(((Rect)(ref frame)).x, ((Rect)(ref frame)).y, 2f, ((Rect)(ref frame)).height), Line);
			Fill(new Rect(((Rect)(ref frame)).xMax - 2f, ((Rect)(ref frame)).y, 2f, ((Rect)(ref frame)).height), Line);
		}

		private void DrawGrid(Rect area)
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 1; i <= 2; i++)
			{
				Fill(new Rect(((Rect)(ref area)).x + ((Rect)(ref area)).width * (float)i / 3f - 1f, ((Rect)(ref area)).y, 2f, ((Rect)(ref area)).height), Line);
				Fill(new Rect(((Rect)(ref area)).x, ((Rect)(ref area)).y + ((Rect)(ref area)).height * (float)i / 3f - 1f, ((Rect)(ref area)).width, 2f), Line);
			}
		}

		private void DrawLevel(float rollDegrees, float screenWidth, float screenHeight)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: 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)
			float num = screenWidth / 2f;
			float num2 = screenHeight / 2f;
			Fill(new Rect(0f, num2 - 1f, 60f, 2f), Line);
			Fill(new Rect(screenWidth - 60f, num2 - 1f, 60f, 2f), Line);
			Matrix4x4 matrix = GUI.matrix;
			GUIUtility.RotateAroundPivot(rollDegrees, new Vector2(num, num2));
			Fill(new Rect(num - screenWidth / 4f, num2 - 1f, screenWidth / 2f, 2f), (Mathf.Abs(rollDegrees) < 0.25f) ? Level : Tilted);
			GUI.matrix = matrix;
		}

		private void Fill(Rect rect, Color color)
		{
			//IL_0000: 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)
			GUI.color = color;
			GUI.DrawTexture(rect, (Texture)(object)_white);
		}
	}
	internal static class ModVolume
	{
		private const float Priority = 20000f;

		private static VolumeProfile _profile;

		private static Volume _volume;

		private static DepthOfField _depthOfField;

		private static Vignette _vignette;

		private static FilmGrain _filmGrain;

		private static LensDistortion _lensDistortion;

		private static Fog _fog;

		private static Exposure _exposure;

		public static DepthOfField DepthOfField
		{
			get
			{
				EnsureVolume();
				return _depthOfField;
			}
		}

		public static Vignette Vignette
		{
			get
			{
				EnsureVolume();
				return _vignette;
			}
		}

		public static FilmGrain FilmGrain
		{
			get
			{
				EnsureVolume();
				return _filmGrain;
			}
		}

		public static LensDistortion LensDistortion
		{
			get
			{
				EnsureVolume();
				return _lensDistortion;
			}
		}

		public static Fog Fog
		{
			get
			{
				EnsureVolume();
				return _fog;
			}
		}

		public static Exposure Exposure
		{
			get
			{
				EnsureVolume();
				return _exposure;
			}
		}

		private static void EnsureVolume()
		{
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_profile == (Object)null)
			{
				_profile = ScriptableObject.CreateInstance<VolumeProfile>();
				((Object)_profile).name = "PhotoModVolumeProfile";
				((Object)_profile).hideFlags = (HideFlags)61;
				_depthOfField = _profile.Add<DepthOfField>(true);
				((VolumeParameter<DepthOfFieldMode>)(object)_depthOfField.focusMode).Override((DepthOfFieldMode)1);
				((VolumeParameter<FocusDistanceMode>)(object)_depthOfField.focusDistanceMode).Override((FocusDistanceMode)1);
				((VolumeParameter<int>)(object)((VolumeComponentWithQuality)_depthOfField).quality).Override(ScalableSettingLevelParameter.LevelCount);
				((VolumeParameter<bool>)(object)_depthOfField.m_PhysicallyBased).Override(true);
				((VolumeComponent)_depthOfField).active = false;
				_vignette = _profile.Add<Vignette>(true);
				((VolumeComponent)_vignette).active = false;
				_filmGrain = _profile.Add<FilmGrain>(true);
				((VolumeParameter<FilmGrainLookup>)(object)_filmGrain.type).Override((FilmGrainLookup)0);
				((VolumeComponent)_filmGrain).active = false;
				_lensDistortion = _profile.Add<LensDistortion>(true);
				((VolumeComponent)_lensDistortion).active = false;
				_fog = _profile.Add<Fog>(false);
				((VolumeComponent)_fog).active = false;
				_exposure = _profile.Add<Exposure>(false);
				((VolumeComponent)_exposure).active = false;
			}
			if (!((Object)(object)_volume != (Object)null))
			{
				_volume = new GameObject("PhotoModVolume").AddComponent<Volume>();
				_volume.isGlobal = true;
				_volume.priority = 20000f;
				_volume.weight = 1f;
				_volume.sharedProfile = _profile;
			}
		}
	}
	internal sealed class PhotoFolder : IOutputPort
	{
		private static readonly Encoding Utf8NoBom = new UTF8Encoding(encoderShouldEmitUTF8Identifier: false);

		internal static readonly string SteamTooLarge = $"Steam does not keep photos wider than {2}x the screen";

		public string Path { get; set; } = string.Empty;

		public void WritePng(string fileName, byte[] png)
		{
			Directory.CreateDirectory(Path);
			File.WriteAllBytes(System.IO.Path.Combine(Path, fileName), png);
		}

		public void WriteSettings(string fileName, string text)
		{
			Directory.CreateDirectory(Path);
			File.WriteAllText(System.IO.Path.Combine(Path, fileName), text, Utf8NoBom);
		}

		public void AddToSteam(string pngFile, int width, int height)
		{
			//IL_0021: 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)
			IL2CPP.il2cpp_thread_attach(IL2CPP.il2cpp_domain_get());
			string fullPath = System.IO.Path.GetFullPath(System.IO.Path.Combine(Path, pngFile));
			if (SteamScreenshots.AddScreenshotToLibrary(fullPath, (string)null, width, height).m_ScreenshotHandle == ScreenshotHandle.Invalid.m_ScreenshotHandle)
			{
				throw new InvalidOperationException("Steam refused " + fullPath + " for its screenshot library.");
			}
		}
	}
	public class PhotoModTool : MonoBehaviour
	{
		private const float StatusSeconds = 4f;

		private GamePorts _ports;

		private PhotoFolder _folder;

		private PhotoModeSession _session;

		private Vector2Control _mouseDelta;

		private PhotoPanel _panel;

		private readonly GuideOverlay _guides = new GuideOverlay();

		internal const int CaptureSettleFrames = 8;

		private bool _capturing;

		private bool _hiddenForCapture;

		private int _visit;

		private Task<CapturedPhoto> _saving;

		private int _progressShown;

		private float _grabbedAt;

		private float _statusUntil;

		private bool _drawFailureLogged;

		private bool InPhotoMode
		{
			get
			{
				if (_session != null)
				{
					return _session.IsActive;
				}
				return false;
			}
		}

		private void Update()
		{
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			if (_saving != null && _saving.IsCompleted)
			{
				FinishSaving();
			}
			if (_saving != null)
			{
				ShowProgress();
			}
			if (_panel != null && _statusUntil > 0f && Time.unscaledTime > _statusUntil)
			{
				_panel.Status = string.Empty;
				_statusUntil = 0f;
			}
			if (!Plugin.ConfigEnabled.Value)
			{
				if (InPhotoMode)
				{
					LeavePhotoMode();
				}
				return;
			}
			bool keyDown = Input.GetKeyDown(Plugin.ConfigPhotoModeKey.Value);
			if (InPhotoMode)
			{
				if (keyDown || Input.GetKeyDown(Plugin.ConfigLeaveKey.Value))
				{
					LeavePhotoMode();
					return;
				}
				if (Input.GetKeyDown(Plugin.ConfigHidePanelKey.Value))
				{
					_session.SetPanelVisible(!_session.PanelVisible);
				}
				if (Input.GetKeyDown(Plugin.ConfigCaptureKey.Value))
				{
					StartCapture();
				}
				if (Input.GetMouseButtonDown(0))
				{
					FocusAt(Vector2.op_Implicit(Input.mousePosition));
				}
				if (_session.PanelVisible && !_ports.CursorFree)
				{
					_ports.CursorFree = true;
				}
				if (_session.HoldFullPause())
				{
					Plugin.Log.LogInfo((object)"Something else resumed the world under Full Pause, so Photo Mode paused it again. Logged once per visit.");
				}
				_session.KeepSubjectsHidden(Time.unscaledDeltaTime);
				_ports.StepHiding();
				_ports.StepPrecipitation();
				FlyCamera();
			}
			else if (keyDown)
			{
				EnterPhotoMode();
			}
		}

		private void OnGUI()
		{
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Expected O, but got Unknown
			if (!InPhotoMode || _hiddenForCapture)
			{
				return;
			}
			try
			{
				_guides.Draw(_session);
				if (!_session.PanelVisible)
				{
					_panel.DrawStatusOnly();
					return;
				}
				switch (_panel.Draw(_session))
				{
				case PanelAction.Capture:
					StartCapture();
					break;
				case PanelAction.HidePanel:
					_session.SetPanelVisible(visible: false);
					break;
				case PanelAction.Exit:
					LeavePhotoMode();
					break;
				case PanelAction.FullPauseOn:
					SetFullPause(on: true);
					break;
				case PanelAction.FullPauseOff:
					SetFullPause(on: false);
					break;
				case PanelAction.SeasonPreset:
					SetSeasonPreset(_panel.ChosenSeason);
					break;
				case PanelAction.WeatherPreset:
					SetWeather(_panel.ChosenWeather);
					break;
				}
			}
			catch (Exception ex)
			{
				if (!_drawFailureLogged)
				{
					_drawFailureLogged = true;
					ManualLogSource log = Plugin.Log;
					bool flag = default(bool);
					BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(46, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Drawing the Photo Panel failed (logged once): ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
					}
					log.LogError(val);
				}
			}
		}

		private void OnDestroy()
		{
			if (InPhotoMode)
			{
				LeavePhotoMode();
			}
		}

		private void FlyCamera()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: 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_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: 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_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: 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)
			if (Input.GetKeyDown(Plugin.ConfigResetCameraKey.Value))
			{
				_session.ResetCamera();
				return;
			}
			Vector2 val = ((Input.GetKey(Plugin.ConfigAimKey.Value) && _mouseDelta != null) ? ((InputControl<Vector2>)(object)_mouseDelta).ReadValue() : Vector2.zero);
			_session.MoveCamera(new CameraInput
			{
				Forward = Axis(Plugin.ConfigForwardKey, Plugin.ConfigBackKey),
				Right = Axis(Plugin.ConfigRightKey, Plugin.ConfigLeftKey),
				Up = Axis(Plugin.ConfigUpKey, Plugin.ConfigDownKey),
				WheelNotches = Math.Sign(Input.mouseScrollDelta.y),
				AimX = val.x,
				AimY = val.y,
				Faster = Input.GetKey(Plugin.ConfigFasterKey.Value),
				Slower = Input.GetKey(Plugin.ConfigSlowerKey.Value)
			}, Time.unscaledDeltaTime);
		}

		private void FocusAt(Vector2 mouse)
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			if ((!_session.PanelVisible || !_panel.Covers(new Vector2(mouse.x, (float)Screen.height - mouse.y))) && !_session.FocusAt(new Vector2(mouse.x / (float)Screen.width, mouse.y / (float)Screen.height)))
			{
				ShowStatus(ModStrings.Get("status.nothing_to_focus"));
			}
		}

		private static float Axis(ConfigEntry<KeyCode> positive, ConfigEntry<KeyCode> negative)
		{
			//IL_0001: 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)
			return (Input.GetKey(positive.Value) ? 1f : 0f) - (Input.GetKey(negative.Value) ? 1f : 0f);
		}

		private void EnterPhotoMode()
		{
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Expected O, but got Unknown
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Expected O, but got Unknown
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Expected O, but got Unknown
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			if (_ports == null)
			{
				_ports = new GamePorts();
			}
			if (_folder == null)
			{
				_folder = new PhotoFolder();
			}
			if (_session == null)
			{
				_session = new PhotoModeSession(_ports, _ports, _ports, _ports, _ports, _ports, new ScreenGrab(), _folder, _ports);
			}
			if (_panel == null)
			{
				_panel = new PhotoPanel();
			}
			_session.RangeLimit = Plugin.ConfigCameraRange.Value;
			_session.AddToSteam = Plugin.ConfigAddToSteam.Value;
			Mouse current = Mouse.current;
			_mouseDelta = (Vector2Control)(object)((current != null) ? ((Pointer)current).delta : null);
			EnterResult enterResult;
			bool flag = default(bool);
			try
			{
				enterResult = _session.Enter();
			}
			catch (Exception ex)
			{
				ManualLogSource log = Plugin.Log;
				BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(57, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Photo Mode could not start, and its changes were undone: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
				}
				log.LogError(val);
				return;
			}
			switch (enterResult)
			{
			case EnterResult.RefusedInMultiplayer:
			{
				ManualLogSource log2 = Plugin.Log;
				BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(58, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Photo Mode is single player only. This session's role is ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<Role>(_ports.SessionRole());
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(".");
				}
				log2.LogWarning(val2);
				ShowRefusal(ModStrings.Get("status.refused_multiplayer"));
				return;
			}
			case EnterResult.RefusedSaveInProgress:
				Plugin.Log.LogWarning((object)"Photo Mode did not start: the game is saving. Nothing was changed. Try again when the save is done.");
				ShowRefusal(ModStrings.Get("status.refused_saving"));
				return;
			}
			_folder.Path = Plugin.ConfigPhotoFolder.Value;
			_panel.Refresh();
			ManualLogSource log3 = Plugin.Log;
			BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(37, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Photo Mode entered in Full Pause at ");
				((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(_ports.Clock());
				((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(".");
			}
			log3.LogInfo(val3);
		}

		private static void ShowRefusal(string text)
		{
			//IL_0031: 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_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Expected O, but got Unknown
			try
			{
				int hashCode = text.GetHashCode();
				float num = 1f;
				Color val = default(Color);
				((Color)(ref val))..ctor(0.85f, 0.2f, 0.18f, 1f);
				NotificationMenu.DisplayStacking((NotificationType)1, (StackingType)0, ref text, ref hashCode, ref num, (Sprite)null, val, val);
			}
			catch (Exception ex)
			{
				ManualLogSource log = Plugin.Log;
				bool flag = default(bool);
				BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(38, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Showing the refusal on screen failed: ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<Exception>(ex);
				}
				log.LogWarning(val2);
			}
		}

		private void LeavePhotoMode()
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Expected O, but got Unknown
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Expected O, but got Unknown
			_visit++;
			bool flag = default(bool);
			foreach (RestoreFailure failure in _session.Leave().Failures)
			{
				ManualLogSource log = Plugin.Log;
				BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(31, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Photo Mode could not restore ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(failure.Step);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(failure.Error);
				}
				log.LogWarning(val);
			}
			ManualLogSource log2 = Plugin.Log;
			BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(20, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Photo Mode left at ");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(_ports.Clock());
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(".");
			}
			log2.LogInfo(val2);
		}

		private void SetFullPause(bool on)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			try
			{
				_session.SetFullPause(on);
			}
			catch (Exception ex)
			{
				ManualLogSource log = Plugin.Log;
				bool flag = default(bool);
				BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(30, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Switching Full Pause ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(on ? "on" : "off");
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" failed: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
				}
				log.LogError(val);
				return;
			}
			Plugin.Log.LogInfo((object)(on ? "Full Pause on." : "Full Pause off: Clock Freeze only."));
		}

		private void SetSeasonPreset(Season? season)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			try
			{
				_session.SetSeasonPreset(season);
			}
			catch (Exception ex)
			{
				ManualLogSource log = Plugin.Log;
				bool flag = default(bool);
				BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(38, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Setting the season preset to ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(season?.ToString() ?? "off");
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" failed: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
				}
				log.LogError(val);
			}
		}

		private void SetWeather(WeatherPreset? preset)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			try
			{
				_session.SetWeather(preset);
			}
			catch (Exception ex)
			{
				ManualLogSource log = Plugin.Log;
				bool flag = default(bool);
				BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(32, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Setting the weather to ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(preset?.ToString() ?? "the game forecast");
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" failed: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
				}
				log.LogError(val);
			}
		}

		private void StartCapture()
		{
			if (!_capturing)
			{
				_capturing = true;
				_hiddenForCapture = true;
				_panel.Status = ModStrings.Get("status.capturing");
				_statusUntil = 0f;
				MonoBehaviourExtensions.StartCoroutine((MonoBehaviour)(object)this, CaptureFrames());
			}
		}

		private IEnumerator CaptureFrames()
		{
			int visit = _visit;
			try
			{
				yield return null;
				if (!InPhotoMode || _visit != visit)
				{
					AbandonCapture();
				}
				else if (CaptureStep(_session.PrepareCapture))
				{
					for (int i = 0; i < 8; i++)
					{
						yield return null;
					}
					yield return (object)new WaitForEndOfFrame();
					if (!InPhotoMode || _visit != visit)
					{
						AbandonCapture();
					}
					else
					{
						CaptureStep(Grab);
					}
				}
			}
			finally
			{
				_hiddenForCapture = false;
			}
		}

		private void AbandonCapture()
		{
			_capturing = false;
			_panel.Status = string.Empty;
		}

		private bool CaptureStep(Action step)
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Expected O, but got Unknown
			try
			{
				step();
				return true;
			}
			catch (Exception ex)
			{
				_capturing = false;
				ShowStatus(ModStrings.Get("status.capture_failed"));
				ManualLogSource log = Plugin.Log;
				bool flag = default(bool);
				BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(16, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Capture failed: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
				}
				log.LogError(val);
				return false;
			}
		}

		private void Grab()
		{
			_saving = _session.Capture(DateTime.Now);
			_progressShown = -1;
			_grabbedAt = Time.realtimeSinceStartup;
			ShowProgress();
		}

		private void FinishSaving()
		{
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Expected O, but got Unknown
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Expected O, but got Unknown
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Expected O, but got Unknown
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Expected O, but got Unknown
			Task<CapturedPhoto> saving = _saving;
			_saving = null;
			_capturing = false;
			bool flag = default(bool);
			if (saving.IsFaulted)
			{
				ShowStatus(ModStrings.Get("status.save_failed"));
				ManualLogSource log = Plugin.Log;
				BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(25, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Saving the photo failed: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(saving.Exception?.InnerException);
				}
				log.LogError(val);
				return;
			}
			CapturedPhoto result = saving.Result;
			ShowStatus(ModStrings.Get("status.saved", result.PngFile));
			ManualLogSource log2 = Plugin.Log;
			BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(42, 6, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Photo saved: ");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(_folder.Path);
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("\\");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(result.PngFile);
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" (");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(result.Width);
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("x");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(result.Height);
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(") and ");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(result.SettingsFile);
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(", ");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<float>(Time.realtimeSinceStartup - _grabbedAt, "0.0");
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" s after the grab");
			}
			log2.LogInfo(val2);
			if (result.SteamSkipped)
			{
				ManualLogSource log3 = Plugin.Log;
				val2 = new BepInExInfoLogInterpolatedStringHandler(26, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(result.PngFile);
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" was not added to Steam: ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(PhotoFolder.SteamTooLarge);
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(".");
				}
				log3.LogInfo(val2);
			}
			if (result.SteamError != null)
			{
				ManualLogSource log4 = Plugin.Log;
				BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(42, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(result.PngFile);
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" is saved, but adding it to Steam failed: ");
					((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<Exception>(result.SteamError);
				}
				log4.LogWarning(val3);
			}
		}

		private void ShowProgress()
		{
			int num = (int)(_session.CaptureProgress * 100f);
			if (num != _progressShown)
			{
				_progressShown = num;
				_panel.Status = ModStrings.Get("status.saving", num);
			}
		}

		private void ShowStatus(string text)
		{
			_panel.Status = text;
			_statusUntil = Time.unscaledTime + 4f;
		}
	}
	internal enum PanelAction
	{
		None,
		Capture,
		HidePanel,
		Exit,
		FullPauseOn,
		FullPauseOff,
		SeasonPreset,
		WeatherPreset
	}
	internal sealed class PhotoPanel
	{
		private sealed class ValueText
		{
			private readonly Func<float, string> _format;

			private readonly GUIContent _content = new GUIContent();

			private float _shown = float.NaN;

			public ValueText(string format)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_000b: Expected O, but got Unknown
				_format = (float value) => string.Format(CultureInfo.InvariantCulture, format, value);
			}

			public ValueText(Func<float, string> format)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_000b: Expected O, but got Unknown
				_format = format;
			}

			public GUIContent For(float value)
			{
				if (value != _shown)
				{
					_shown = value;
					_content.text = _format(value);
				}
				return _content;
			}
		}

		private const float DesignHeight = 1080f;

		private const float Margin = 16f;

		private const float BarHeight = 36f;

		private const float TabWidth = 120f;

		private const float ButtonGap = 8f;

		private const float ColumnWidth = 440f;

		private const float RowHeight = 34f;

		private const float HintHeight = 34f;

		private const float TopBarBottom = 68f;

		private const float HintBarTop = 1022f;

		private static readonly string[] TabKeys = new string[5] { "tab.presets", "tab.camera", "tab.scene", "tab.effects", "tab.composition" };

		private const int PresetsTab = 0;

		private const int CameraTab = 1;

		private const int SceneTab = 2;

		private const int EffectsTab = 3;

		private const int CompositionTab = 4;

		private const float LabelWidth = 150f;

		private const float ValueWidth = 120f;

		private static readonly LensPreset[] Presets = new LensPreset[3]
		{
			LensPreset.Landscape,
			LensPreset.Portrait,
			LensPreset.Macro
		};

		private readonly GUIContent[] _presetNames = (GUIContent[])(object)new GUIContent[Presets.Length];

		private readonly GUIContent[] _presetLenses = (GUIContent[])(object)new GUIContent[Presets.Length];

		private readonly GUIContent _gameLensName = new GUIContent();

		private ValueText _gameLens;

		private ValueText _apertureOff;

		private readonly GUIContent _focalLengthLabel = new GUIContent();

		private readonly GUIContent _apertureLabel = new GUIContent();

		private readonly GUIContent _focusDistanceLabel = new GUIContent();

		private readonly GUIContent _rollLabel = new GUIContent();

		private readonly ValueText _focalLength = new ValueText("{0:0} mm");

		private readonly ValueText _aperture = new ValueText("f/{0:0.#}");

		private readonly ValueText _focusDistance = new ValueText("{0:0.##} m");

		private readonly ValueText _roll = new ValueText("{0:0.#}°");

		private readonly GUIContent _setByTiltShift = new GUIContent();

		private readonly GUIContent _tiltShiftBlurLabel = new GUIContent();

		private readonly ValueText _tiltShiftBlur = new ValueText("{0:0}%");

		private const float TimeStep = 1f / 12f;

		private const float LastTimeOfDay = 23.916666f;

		private readonly GUIContent _timeOfDayLabel = new GUIContent();

		private readonly GUIContent _fogLabel = new GUIContent();

		private readonly GUIContent _exposureLabel = new GUIContent();

		private readonly ValueText _timeOfDay = new ValueText(PhotoModeSession.ClockTime);

		private ValueText _fog;

		private readonly ValueText _exposure = new ValueText("{0:+0.0;-0.0;0} EV");

		private readonly GUIContent[] _effectLabels = (GUIContent[])(object)new GUIContent[LensEffects.All.Length];

		private readonly ValueText[] _effectValues = new ValueText[LensEffects.All.Length];

		private Rect _column;

		private static readonly CaptureSize[] Sizes = new CaptureSize[3]
		{
			CaptureSize.X1,
			CaptureSize.X2,
			CaptureSize.X4
		};

		private readonly GUIContent[] _tabs = (GUIContent[])(object)new GUIContent[TabKeys.Length];

		private readonly GUIContent[] _sizes = (GUIContent[])(object)new GUIContent[Sizes.Length];

		private readonly GUIContent _grid = new GUIContent();

		private readonly GUIContent _hide = new GUIContent();

		private readonly GUIContent _capture = new GUIContent();

		private readonly GUIContent _exit = new GUIContent();

		private readonly GUIContent _captureSizeLabel = new GUIContent();

		private readonly GUIContent _fullPauseLabel = new GUIContent();

		private readonly GUIContent _seasonLabel = new GUIContent();

		private static readonly string[] SeasonKeys = new string[4] { "season.winter", "season.spring", "season.summer", "season.autumn" };

		private readonly GUIContent[] _seasons = (GUIContent[])(object)new GUIContent[SeasonKeys.Length];

		private static readonly string[] HideKeys = new string[3] { "label.hide_player", "label.hide_villagers", "label.hide_creatures" };

		private readonly GUIContent[] _hideLabels = (GUIContent[])(object)new GUIContent[HideKeys.Length];

		private readonly GUIContent _hudLabel = new GUIContent();

		private readonly GUIContent _foliageTintLabel = new GUIContent();

		private readonly GUIContent _tintLabel = new GUIContent();

		private readonly ValueText _tintText = new ValueText("{0:0.00}");

		private float _tint;

		private readonly GUIContent _groundSnowLabel = new GUIContent();

		private readonly ValueText _groundSnow = new ValueText("{0:0.00}");

		private static readonly WeatherPreset[] WeatherPresets = Enum.GetValues<WeatherPreset>();

		private readonly GUIContent _weatherLabel = new GUIContent();

		private readonly GUIContent _gameForecast = new GUIContent();

		private readonly GUIContent[] _weatherPresets = (GUIContent[])(object)new GUIContent[WeatherPresets.Length];

		private readonly GUIContent _strengthLabel = new GUIContent();

		private readonly ValueText _strength = new ValueText("{0:0.00}");

		private readonly GUIContent _gridLabel = new GUIContent();

		private readonly GUIContent _levelLabel = new GUIContent();

		private readonly GUIContent _frameLabel = new GUIContent();

		private readonly GUIContent _on = new GUIContent();

		private readonly GUIContent _off = new GUIContent();

		private readonly GUIContent[] _shapes = (GUIContent[])(object)new GUIContent[StoreShape.All.Length];

		private readonly GUIContent _hints = new GUIContent();

		private readonly GUIContent _status = new GUIContent();

		private Texture2D _background;

		private Texture2D _rule;

		private GUIStyle _button;

		private GUIStyle _selected;

		private GUIStyle _label;

		private GUIStyle _value;

		private GUIStyle _hint;

		private GUIStyle _slider;

		private GUIStyle _thumb;

		private GUIStyle _statusStyle;

		private int _tab;

		private static readonly float FogDoublings = Mathf.Log(16f, 2f);

		public Season? ChosenSeason { get; private set; }

		public WeatherPreset? ChosenWeather { get; private set; }

		public string Status
		{
			get
			{
				return _status.text;
			}
			set
			{
				_status.text = value;
			}
		}

		public PhotoPanel()
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Expected O, but got Unknown
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Expected O, but got Unknown
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Expected O, but got Unknown
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Expected O, but got Unknown
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Expected O, but got Unknown
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Expected O, but got Unknown
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Expected O, but got Unknown
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Expected O, but got Unknown
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Expected O, but got Unknown
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Expected O, but got Unknown
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Expected O, but got Unknown
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Expected O, but got Unknown
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Expected O, but got Unknown
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Expected O, but got Unknown
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Expected O, but got Unknown
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Expected O, but got Unknown
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Expected O, but got Unknown
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Expected O, but got Unknown
			//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e7: Expected O, but got Unknown
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: Expected O, but got Unknown
			//IL_0203: Unknown result type (might be due to invalid IL or missing references)
			//IL_020d: Expected O, but got Unknown
			//IL_021e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0228: Expected O, but got Unknown
			//IL_0229: Unknown result type (might be due to invalid IL or missing references)
			//IL_0233: Expected O, but got Unknown
			//IL_0246: Unknown result type (might be due to invalid IL or missing references)
			//IL_0250: Expected O, but got Unknown
			//IL_0261: Unknown result type (might be due to invalid IL or missing references)
			//IL_026b: Expected O, but got Unknown
			//IL_026c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0276: Expected O, but got Unknown
			//IL_0277: Unknown result type (might be due to invalid IL or missing references)
			//IL_0281: Expected O, but got Unknown
			//IL_0282: Unknown result type (might be due to invalid IL or missing references)
			//IL_028c: Expected O, but got Unknown
			//IL_028d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0297: Expected O, but got Unknown
			//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b4: Expected O, but got Unknown
			//IL_02b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bf: Expected O, but got Unknown
			//IL_02d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d6: Expected O, but got Unknown
			//IL_02f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f6: Expected O, but got Unknown
			//IL_034b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0351: Expected O, but got Unknown
			//IL_037b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0381: Expected O, but got Unknown
			//IL_03bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c2: Expected O, but got Unknown
			//IL_03e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e6: Expected O, but got Unknown
			//IL_0405: Unknown result type (might be due to invalid IL or missing references)
			//IL_040b: Expected O, but got Unknown
			//IL_042a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0430: Expected O, but got Unknown
			//IL_044f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0455: Expected O, but got Unknown
			for (int i = 0; i < _tabs.Length; i++)
			{
				_tabs[i] = new GUIContent();
			}
			for (int j = 0; j < LensEffects.All.Length; j++)
			{
				_effectLabels[j] = new GUIContent();
				_effectValues[j] = new ValueText("{0:0.00}");
			}
			for (int k = 0; k < Sizes.Length; k++)
			{
				_sizes[k] = new GUIContent($"{Sizes[k]}x");
			}
			for (int l = 0; l < Presets.Length; l++)
			{
				PhotoLens photoLens = Presets[l].Lens();
				_presetNames[l] = new GUIContent();
				_presetLenses[l] = new GUIContent(string.Format(CultureInfo.InvariantCulture, "{0:0} mm   f/{1:0.#}   {2:0.##} m", photoLens.FocalLength, photoLens.Aperture, photoLens.FocusDistance));
			}
			for (int m = 0; m < _shapes.Length; m++)
			{
				_shapes[m] = new GUIContent();
			}
			for (int n = 0; n < _weatherPresets.Length; n++)
			{
				_weatherPresets[n] = new GUIContent();
			}
			for (int num = 0; num < _seasons.Length; num++)
			{
				_seasons[num] = new GUIContent();
			}
			for (int num2 = 0; num2 < _hideLabels.Length; num2++)
			{
				_hideLabels[num2] = new GUIContent();
			}
		}

		public void Refresh()
		{
			//IL_004a: 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_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_04da: Unknown result type (might be due to invalid IL or missing references)
			//IL_04fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_051e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0540: Unknown result type (might be due to invalid IL or missing references)
			//IL_05da: Unknown result type (might be due to invalid IL or missing references)
			//IL_0619: Unknown result type (might be due to invalid IL or missing references)
			//IL_0658: Unknown result type (might be due to invalid IL or missing references)
			//IL_0697: Unknown result type (might be due to invalid IL or missing references)
			//IL_06d6: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < _tabs.Length; i++)
			{
				_tabs[i].text = ModStrings.Get(TabKeys[i]);
			}
			_hide.text = ModStrings.Get("button.hide_interface", KeyName(Plugin.ConfigHidePanelKey.Value));
			_capture.text = ModStrings.Get("button.capture", KeyName(Plugin.ConfigCaptureKey.Value));
			_exit.text = ModStrings.Get("button.exit", KeyName(Plugin.ConfigPhotoModeKey.Value));
			_grid.text = ModStrings.Get("label.grid");
			for (int j = 0; j < Presets.Length; j++)
			{
				_presetNames[j].text = ModStrings.Get(PresetKey(Presets[j]));
			}
			_gameLensName.text = ModStrings.Get("value.game");
			string format = ModStrings.Get("value.game_lens");
			_gameLens = new ValueText(format);
			string off = ModStrings.Get("value.off");
			_apertureOff = new ValueText((float _) => off);
			_fog = new ValueText(FogText);
			_focalLengthLabel.text = ModStrings.Get("label.focal_length");
			_apertureLabel.text = ModStrings.Get("label.aperture");
			_focusDistanceLabel.text = ModStrings.Get("label.focus_distance");
			_exposureLabel.text = ModStrings.Get("label.exposure");
			_setByTiltShift.text = ModStrings.Get("value.set_by_tilt_shift");
			_tiltShiftBlurLabel.text = ModStrings.Get("label.tilt_shift_blur");
			_fullPauseLabel.text = ModStrings.Get("label.full_pause");
			_timeOfDayLabel.text = ModStrings.Get("label.time_of_day");
			_fogLabel.text = ModStrings.Get("label.fog");
			_seasonLabel.text = ModStrings.Get("label.season");
			for (int num = 0; num < _seasons.Length; num++)
			{
				_seasons[num].text = ModStrings.Get(SeasonKeys[num]);
			}
			_foliageTintLabel.text = ModStrings.Get("label.foliage_tint");
			_tintLabel.text = ModStrings.Get("label.tint");
			_groundSnowLabel.text = ModStrings.Get("label.ground_snow");
			_weatherLabel.text = ModStrings.Get("label.weather");
			_gameForecast.text = ModStrings.Get("weather.game_forecast");
			for (int num2 = 0; num2 < WeatherPresets.Length; num2++)
			{
				_weatherPresets[num2].text = ModStrings.Get(WeatherKey(WeatherPresets[num2]));
			}
			_strengthLabel.text = ModStrings.Get("label.strength");
			for (int num3 = 0; num3 < _hideLabels.Length; num3++)
			{
				_hideLabels[num3].text = ModStrings.Get(HideKeys[num3]);
			}
			_hudLabel.text = ModStrings.Get("label.show_hud");
			for (int num4 = 0; num4 < LensEffects.All.Length; num4++)
			{
				_effectLabels[num4].text = ModStrings.Get(EffectKey(LensEffects.All[num4]));
			}
			_captureSizeLabel.text = ModStrings.Get("label.capture_size");
			_gridLabel.text = ModStrings.Get("label.grid");
			_levelLabel.text = ModStrings.Get("label.level_line");
			_frameLabel.text = ModStrings.Get("label.crop_presets");
			for (int num5 = 0; num5 < _shapes.Length; num5++)
			{
				StoreShape storeShape = StoreShape.All[num5];
				_shapes[num5].text = $"{ModStrings.Get(ShapeKey(storeShape))} {storeShape.Width}x{storeShape.Height}";
			}
			_rollLabel.text = ModStrings.Get("label.roll");
			_on.text = ModStrings.Get("value.on");
			_off.text = off;
			string value = $"{KeyName(Plugin.ConfigForwardKey.Value)} {KeyName(Plugin.ConfigLeftKey.Value)} {KeyName(Plugin.ConfigBackKey.Value)} {KeyName(Plugin.ConfigRightKey.Value)}";
			_hints.text = $"{KeyName((KeyCode)323)}  {ModStrings.Get("hint.focus")}        {value}  {ModStrings.Get("hint.move")}        {KeyName(Plugin.ConfigAimKey.Value)}  {ModStrings.Get("hint.aim")}        {KeyName(Plugin.ConfigUpKey.Value)}  {ModStrings.Get("hint.up")}        {KeyName(Plugin.ConfigDownKey.Value)}  {ModStrings.Get("hint.down")}        {KeyName(Plugin.ConfigFasterKey.Value)}  {ModStrings.Get("hint.faster")}        {KeyName(Plugin.ConfigSlowerKey.Value)}  {ModStrings.Get("hint.slower")}";
		}

		private unsafe static string KeyName(KeyCode key)
		{
			//IL_0000: 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_0008: Invalid comparison between Unknown and I4
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Invalid comparison between Unknown and I4
			//IL_0014: 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_002c: Expected I4, but got Unknown
			if (key - 303 > 1)
			{
				if (key - 305 > 1)
				{
					return (key - 323) switch
					{
						0 => ModStrings.Get("key.left_click"), 
						1 => ModStrings.Get("key.right_mouse"), 
						2 => ModStrings.Get("key.middle_mouse"), 
						_ => ((object)(*(KeyCode*)(&key))/*cast due to .constrained prefix*/).ToString(), 
					};
				}
				return ModStrings.Get("key.ctrl");
			}
			return ModStrings.Get("key.shift");
		}

		private static string PresetKey(LensPreset preset)
		{
			return preset switch
			{
				LensPreset.Landscape => "preset.landscape", 
				LensPreset.Portrait => "preset.portrait", 
				LensPreset.Macro => "preset.macro", 
				_ => throw new ArgumentOutOfRangeException("preset", preset, null), 
			};
		}

		private static string EffectKey(LensEffect effect)
		{
			return effect switch
			{
				LensEffect.Vignette => "effect.vignette", 
				LensEffect.FilmGrain => "effect.film_grain", 
				LensEffect.LensDistortion => "effect.lens_distortion", 
				_ => throw new ArgumentOutOfRangeException("effect", effect, null), 
			};
		}

		private static string WeatherKey(WeatherPreset preset)
		{
			return preset switch
			{
				WeatherPreset.Clear => "weather.clear", 
				WeatherPreset.Overcast => "weather.overcast", 
				WeatherPreset.SpringClouds => "weather.spring_clouds", 
				WeatherPreset.AutumnClouds => "weather.autumn_clouds", 
				WeatherPreset.Fog => "weather.fog", 
				WeatherPreset.HeavyRain => "weather.heavy_rain", 
				WeatherPreset.SkollThunderstorm => "weather.skoll_thunderstorm", 
				WeatherPreset.Blizzard => "weather.blizzard", 
				_ => throw new ArgumentOutOfRangeException("preset", preset, null), 
			};
		}

		private static string ShapeKey(StoreShape shape)
		{
			if (shape != StoreShape.Title)
			{
				if (shape != StoreShape.Header)
				{
					if (shape != StoreShape.Thumbnail)
					{
						throw new ArgumentOutOfRangeException("shape", shape.Name, null);
					}
					return "shape.thumbnail";
				}
				return "shape.header";
			}
			return "shape.title";
		}

		public PanelAction Draw(PhotoModeSession session)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			EnsureStyles();
			float num = (float)Screen.height / 1080f;
			GUI.matrix = Matrix4x4.Scale(new Vector3(num, num, 1f));
			float width = (float)Screen.width / num;
			PanelAction action = DrawTopBar(width, session);
			DrawColumn(session, ref action);
			DrawHints(width);
			DrawStatus(width);
			return action;
		}

		public void DrawStatusOnly()
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			EnsureStyles();
			float num = (float)Screen.height / 1080f;
			GUI.matrix = Matrix4x4.Scale(new Vector3(num, num, 1f));
			DrawStatus((float)Screen.width / num);
		}

		private PanelAction DrawTopBar(float width, PhotoModeSession session)
		{
			//IL_0010: 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_00e5: Unknown result type (might be due to invalid IL or missing references)
			GUI.DrawTexture(new Rect(0f, 0f, width, 68f), (Texture)(object)_background);
			float num = 16f;
			for (int i = 0; i < _tabs.Length; i++)
			{
				if (GUI.Button(new Rect(num, 16f, 120f, 36f), _tabs[i], (i == _tab) ? _selected : _button))
				{
					_tab = i;
				}
				num += 128f;
			}
			PanelAction action = PanelAction.None;
			float right = width - 16f;
			right = RightButton(right, 120f, _exit, PanelAction.Exit, ref action);
			right = RightButton(right, 170f, _capture, PanelAction.Capture, ref action);
			right = RightButton(right, 210f, _hide, PanelAction.HidePanel, ref action);
			if (GUI.Button(new Rect(right - 90f, 16f, 90f, 36f), _grid, session.Guides.Grid ? _selected : _button))
			{
				session.Guides.Grid = !session.Guides.Grid;
			}
			return action;
		}

		private float RightButton(float right, float buttonWidth, GUIContent content, PanelAction pressed, ref PanelAction action)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			if (GUI.Button(new Rect(right - buttonWidth, 16f, buttonWidth, 36f), content, _button))
			{
				action = pressed;
			}
			return right - buttonWidth - 8f;
		}

		private void DrawColumn(PhotoModeSession session, ref PanelAction action)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			float top = 84f;
			_column = Rect.zero;
			if (_tab == 0)
			{
				DrawPresets(session, top);
			}
			else if (_tab == 1)
			{
				DrawCamera(session, top);
			}
			else if (_tab == 2)
			{
				DrawSceneColumn(session, top, ref action);
			}
			else if (_tab == 3)
			{
				DrawEffects(session, top);
			}
			else if (_tab == 4)
			{
				DrawCompositionColumn(session, top);
			}
		}

		private void DrawSceneColumn(PhotoModeSession session, float top, ref PanelAction action)
		{
			//IL_0024: 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)
			ColumnBackground(top, 13f);
			float num = top + 8f;
			GUI.Label(new Rect(32f, num, 160f, 34f), _fullPauseLabel, _label);
			float num2 = (float)Sizes.Length * 64f - 8f;
			float num3 = 440f - num2;
			bool fullPause = session.FullPause;
			if (GUI.Button(new Rect(num3, num + 2f, num2, 30f), fullPause ? _on : _off, fullPause ? _selected : _button))
			{
				action = (fullPause ? PanelAction.FullPauseOff : PanelAction.FullPauseOn);
			}
			if (Slider(top, 1f, _timeOfDayLabel, _timeOfDay, session.TimeOfDay, session.TimeOfDay, 0f, 23.916666f, out var moved))
			{
				session.SetTimeOfDay(Mathf.Round(moved / (1f / 12f)) * (1f / 12f));
			}
			if (Slider(top, 2f, _fogLabel, _fog, session.Fog, FogPosition(session.Fog), 0f, 2f, out var moved2))
			{
				session.SetFog(FogAt(moved2));
			}
			DrawSeasonRows(session, top, 3, num3, num2, ref action);
			if (Slider(top, 6f, _groundSnowLabel, _groundSnow, session.GroundSnow, session.GroundSnow, 0f, 1f, out var moved3))
			{
				session.SetGroundSnow(Mathf.Round(moved3 * 100f) / 100f);
			}
			DrawWeatherRows(session, top, 7, num3, num2, ref action);
			DrawSubjectRows(session, top, 9, num3, num2);
		}

		private void DrawSubjectRows(PhotoModeSession session, float top, int firstRow, float valueX, float valueWidth)
		{
			for (int i = 0; i < Subjects.All.Length; i++)
			{
				Subject subject = Subjects.All[i];
				bool flag = session.IsHidden(subject);
				if (OnOffRow(top, firstRow + i, _hideLabels[i], valueX, valueWidth, flag))
				{
					session.SetHidden(subject, !flag);
				}
			}
			bool hudShown = session.HudShown;
			if (OnOffRow(top, firstRow + Subjects.All.Length, _hudLabel, valueX, valueWidth, hudShown))
			{
				session.SetHudShown(!hudShown);
			}
		}

		private bool OnOffRow(float top, int row, GUIContent label, float valueX, float valueWidth, bool on)
		{
			//IL_0019: 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)
			float num = RowTop(top, row);
			GUI.Label(new Rect(32f, num, 150f, 34f), label, _label);
			return GUI.Button(new Rect(valueX, num + 2f, valueWidth, 30f), on ? _on : _off, on ? _selected : _button);
		}

		private void DrawWeatherRows(PhotoModeSession session, float top, int firstRow, float valueX, float valueWidth, ref PanelAction action)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			float num = RowTop(top, firstRow);
			GUI.Label(new Rect(32f, num, 150f, 34f), _weatherLabel, _label);
			WeatherPreset? weather = session.Weather;
			object obj;
			if (weather.HasValue)
			{
				WeatherPreset valueOrDefault = weather.GetValueOrDefault();
				obj = _weatherPresets[(int)valueOrDefault];
			}
			else
			{
				obj = _gameForecast;
			}
			GUIContent val = (GUIContent)obj;
			if (GUI.Button(new Rect(valueX - 60f, num + 2f, valueWidth + 60f, 30f), val, weather.HasValue ? _selected : _button))
			{
				int num2;
				if (weather.HasValue)
				{
					WeatherPreset valueOrDefault2 = weather.GetValueOrDefault();
					num2 = (int)(valueOrDefault2 + 1);
				}
				else
				{
					num2 = 0;
				}
				int num3 = num2;
				ChosenWeather = ((num3 < WeatherPresets.Length) ? new WeatherPreset?(WeatherPresets[num3]) : ((WeatherPreset?)null));
				action = PanelAction.WeatherPreset;
			}
			if (Slider(top, firstRow + 1, _strengthLabel, _strength, session.WeatherStrength, session.WeatherStrength, 0f, 1f, out var moved))
			{
				session.SetWeatherStrength(Mathf.Round(moved * 100f) / 100f);
			}
		}

		private static float FogPosition(float fog)
		{
			if (!(fog <= 1f))
			{
				return 1f + Mathf.Log(fog, 2f) / FogDoublings;
			}
			return fog;
		}

		private static float FogAt(float position)
		{
			if (Mathf.Abs(position - 1f) < 0.05f)
			{
				return 1f;
			}
			if (position < 1f)
			{
				return Mathf.Round(position * 20f) / 20f;
			}
			return Mathf.Min(16f, Mathf.Round(Mathf.Pow(2f, (position - 1f) * FogDoublings) * 10f) / 10f);
		}

		private void DrawSeasonRows(PhotoModeSession session, float top, int firstRow, float valueX, float valueWidth, ref PanelAction action)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: 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)
			float num = RowTop(top, firstRow);
			GUI.Label(new Rect(32f, num, 150f, 34f), _seasonLabel, _label);
			Season? seasonPreset = session.SeasonPreset;
			Rect val = new Rect(valueX, num + 2f, valueWidth, 30f);
			object obj;
			if (seasonPreset.HasValue)
			{
				Season valueOrDefault = seasonPreset.GetValueOrDefault();
				obj = _seasons[(int)valueOrDefault];
			}
			else
			{
				obj = _off;
			}
			if (GUI.Button(val, (GUIContent)obj, seasonPreset.HasValue ? _selected : _button))
			{
				ChosenSeason = ((seasonPreset == Season.Autumn) ? ((Season?)null) : ((!seasonPreset.HasValue) ? new Season?(Season.Winter) : (seasonPreset + 1)));
				action = PanelAction.SeasonPreset;
			}
			num = RowTop(top, firstRow + 1);
			GUI.Label(new Rect(32f, num, 150f, 34f), _foliageTintLabel, _label);
			float? foliageTint = session.FoliageTint;
			if (GUI.Button(new Rect(valueX, num + 2f, valueWidth, 30f), foliageTint.HasValue ? _on : _off, foliageTint.HasValue ? _selected : _button))
			{
				session.SetFoliageTint(foliageTint.HasValue ? ((float?)null) : new float?(_tint));
			}
			float num2 = foliageTint ?? _tint;
			if (Slider(top, firstRow + 2, _tintLabel, _tintText, num2, num2, 0f, 1f, out var moved))
			{
				_tint = Mathf.Round(moved * 100f) / 100f;
				session.SetFoliageTint(_tint);
			}
		}

		private static string FogText(float fog)
		{
			if (fog != 0f)
			{
				if (fog != 1f)
				{
					return string.Format(CultureInfo.InvariantCulture, "{0:0.##}x", fog);
				}
				return ModStrings.Get("value.game");
			}
			return ModStrings.Get("value.off");
		}

		private void DrawCompositionColumn(PhotoModeSession session, float top)
		{
			//IL_0026: 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_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0210: Unknown result type (might be due to invalid IL or missing references)
			//IL_0241: Unknown result type (might be due to invalid IL or missing references)
			ColumnBackground(top, 5f);
			float num = top + 8f;
			float num2 = 32f;
			GUI.Label(new Rect(num2, num, 160f, 34f), _captureSizeLabel, _label);
			float num3 = 56f;
			float num4 = 440f - (float)Sizes.Length * (num3 + 8f) + 8f;
			for (int i = 0; i < Sizes.Length; i++)
			{
				GUIStyle val = ((session.CaptureSiz