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)(object)fog.enabled).Override(false); ReleaseMeanFreePath(fog); ((VolumeComponent)fog).active = true; } else { if (!((VolumeParameter)fog.meanFreePath).overrideState && Time.frameCount > _meanFreePathReleasedFrame) { _gameMeanFreePath = ((VolumeParameter)(object)GameStack(camera).GetComponent().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(_gameMeanFreePath, "0.#"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" m."); } log.LogInfo(val); } ((VolumeParameter)(object)fog.enabled).Override(true); ((VolumeParameter)(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)(object)GameStack(camera).GetComponent().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(_gameCompensation, "0.##"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" stops."); } log.LogInfo(val); } ((VolumeParameter)(object)exposure.compensation).Override(_gameCompensation + stops); } _exposure = stops; ApplyExposureOverride(); } private void ApplyExposureOverride() { Exposure exposure = ModVolume.Exposure; if (_instantExposure) { ((VolumeParameter)(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 _pickRoots = new HashSet(); private readonly List _pickRootList = new List(); private readonly List _hitSkinned = new List(); private readonly List _pickVertices = new List(); private readonly List _pickTriangles = new List(); 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(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(valueOrDefault); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(": super season built from base season '"); BepInExInfoLogInterpolatedStringHandler obj = val3; SeasonConfig config = ((Season)val2).config; ((BepInExLogInterpolatedStringHandler)obj).AppendFormatted((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)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() ?? 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.op_Implicit((Il2CppArrayBase)(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)(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()) { 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(); if ((Object)(object)componentInParent == (Object)null) { componentInParent = (Component)(object)((Component)collider).GetComponentInParent(); } if ((Object)(object)componentInParent != (Object)null && SubjectHider.IsDen(componentInParent)) { return null; } if (!((Object)(object)componentInParent != (Object)null) || !((Object)(object)componentInParent.GetComponentInChildren(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)(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)(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()) { 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 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[])(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)(object)ModVolume.Vignette.intensity).value; case LensEffect.FilmGrain: if (!((VolumeComponent)ModVolume.FilmGrain).active) { return null; } return ((VolumeParameter)(object)ModVolume.FilmGrain.intensity).value; default: if (!((VolumeComponent)ModVolume.LensDistortion).active) { return null; } return ((VolumeParameter)(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)(object)ModVolume.Vignette.intensity).Override(value.Value); } break; case LensEffect.FilmGrain: ((VolumeComponent)ModVolume.FilmGrain).active = value.HasValue; if (value.HasValue) { ((VolumeParameter)(object)ModVolume.FilmGrain.intensity).Override(value.Value); } break; default: ((VolumeComponent)ModVolume.LensDistortion).active = value.HasValue; if (value.HasValue) { ((VolumeParameter)(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() ?? 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(); } 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(); ((Object)_photoContext).name = "PhotoModPhotoMode"; ((Object)_photoContext).hideFlags = (HideFlags)61; _photoContext.inputMaps = new Il2CppStructArray(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(); ((Object)_profile).name = "PhotoModVolumeProfile"; ((Object)_profile).hideFlags = (HideFlags)61; _depthOfField = _profile.Add(true); ((VolumeParameter)(object)_depthOfField.focusMode).Override((DepthOfFieldMode)1); ((VolumeParameter)(object)_depthOfField.focusDistanceMode).Override((FocusDistanceMode)1); ((VolumeParameter)(object)((VolumeComponentWithQuality)_depthOfField).quality).Override(ScalableSettingLevelParameter.LevelCount); ((VolumeParameter)(object)_depthOfField.m_PhysicallyBased).Override(true); ((VolumeComponent)_depthOfField).active = false; _vignette = _profile.Add(true); ((VolumeComponent)_vignette).active = false; _filmGrain = _profile.Add(true); ((VolumeParameter)(object)_filmGrain.type).Override((FilmGrainLookup)0); ((VolumeComponent)_filmGrain).active = false; _lensDistortion = _profile.Add(true); ((VolumeComponent)_lensDistortion).active = false; _fog = _profile.Add(false); ((VolumeComponent)_fog).active = false; _exposure = _profile.Add(false); ((VolumeComponent)_exposure).active = false; } if (!((Object)(object)_volume != (Object)null)) { _volume = new GameObject("PhotoModVolume").AddComponent(); _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 _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(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)(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 positive, ConfigEntry 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(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(_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(_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(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(failure.Step); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(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(_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(on ? "on" : "off"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" failed: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(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(season?.ToString() ?? "off"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" failed: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(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(preset?.ToString() ?? "the game forecast"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" failed: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(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(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 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(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(_folder.Path); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("\\"); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(result.PngFile); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" ("); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(result.Width); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("x"); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(result.Height); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(") and "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(result.SettingsFile); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(", "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(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(result.PngFile); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" was not added to Steam: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(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(result.PngFile); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" is saved, but adding it to Steam failed: "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(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 _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 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(); 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.CaptureSize == Sizes[i]) ? _selected : _button); if (GUI.Button(new Rect(num4 + (float)i * (num3 + 8f), num + 2f, num3, 30f), _sizes[i], val)) { session.CaptureSize = Sizes[i]; } } GuideSettings guides = session.Guides; float num5 = (float)Sizes.Length * (num3 + 8f) - 8f; num += 34f; GUI.Label(new Rect(num2, num, 160f, 34f), _gridLabel, _label); if (GUI.Button(new Rect(num4, num + 2f, num5, 30f), guides.Grid ? _on : _off, guides.Grid ? _selected : _button)) { guides.Grid = !guides.Grid; } num += 34f; GUI.Label(new Rect(num2, num, 160f, 34f), _levelLabel, _label); if (GUI.Button(new Rect(num4, num + 2f, num5, 30f), guides.Level ? _on : _off, guides.Level ? _selected : _button)) { guides.Level = !guides.Level; } num += 34f; GUI.Label(new Rect(num2, num, 160f, 34f), _frameLabel, _label); if (GUI.Button(new Rect(num4 - 60f, num + 2f, num5 + 60f, 30f), FrameContent(guides.Frame), (guides.Frame != null) ? _selected : _button)) { guides.Frame = NextFrame(guides.Frame); } if (Slider(top, 4f, _rollLabel, _roll, session.Roll, session.Roll, -180f, 180f, out var moved)) { session.SetRoll(Mathf.Round(moved * 2f) / 2f); } } private float HorizontalSlider(Rect position, float value, float min, float max) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return GUI.HorizontalSlider(position, value, min, max, _slider, _thumb); } private GUIContent FrameContent(StoreShape shape) { if (shape != null) { return _shapes[Array.IndexOf(StoreShape.All, shape)]; } return _off; } private static StoreShape NextFrame(StoreShape shape) { int num = ((shape != null) ? (Array.IndexOf(StoreShape.All, shape) + 1) : 0); if (num >= StoreShape.All.Length) { return null; } return StoreShape.All[num]; } private void ColumnBackground(float top, float rows) { //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_0024: Unknown result type (might be due to invalid IL or missing references) _column = new Rect(16f, top, 440f, rows * 34f + 16f); GUI.DrawTexture(_column, (Texture)(object)_background); } private static float RowTop(float top, float row) { return top + 8f + row * 34f; } private void DrawPresets(PhotoModeSession session, float top) { //IL_0042: 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_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) ColumnBackground(top, Presets.Length + 1); float num = 32f; float num2 = num + 150f; float num3 = 258f; for (int i = 0; i < Presets.Length; i++) { float num4 = RowTop(top, i); GUI.Label(new Rect(num, num4, 150f, 34f), _presetNames[i], _label); if (GUI.Button(new Rect(num2, num4 + 2f, num3, 30f), _presetLenses[i], _button)) { session.ApplyLensPreset(Presets[i]); } } float num5 = RowTop(top, Presets.Length); GUI.Label(new Rect(num, num5, 150f, 34f), _gameLensName, _label); if (GUI.Button(new Rect(num2, num5 + 2f, num3, 30f), _gameLens.For(session.GameFocalLength), _button)) { session.ApplyGameLens(); } } private void DrawCamera(PhotoModeSession session, float top) { //IL_018c: Unknown result type (might be due to invalid IL or missing references) ColumnBackground(top, 5.5f); PhotoLens lens = session.Lens; if (LogSlider(top, 0f, _focalLengthLabel, _focalLength, lens.FocalLength, 8f, 200f, out var moved)) { session.SetFocalLength(Mathf.Round(moved)); } float moved2; if (session.TiltShiftBlur > 0f) { LockedRow(top, 1f, _apertureLabel, Mathf.Log(lens.Aperture), Mathf.Log(1.4f), Mathf.Log(22f), _setByTiltShift); } else if (LogSlider(top, 1f, _apertureLabel, session.DepthOfField ? _aperture : _apertureOff, lens.Aperture, 1.4f, 22f, out moved2)) { session.SetAperture(Mathf.Round(moved2 * 10f) / 10f); } if (LogSlider(top, 2f, _focusDistanceLabel, _focusDistance, lens.FocusDistance, 0.1f, 1000f, out var moved3)) { session.SetFocusDistance(RoundFocusDistance(moved3)); } if (Slider(top, 3f, _exposureLabel, _exposure, session.Exposure, session.Exposure, -5f, 5f, out var moved4)) { session.SetExposure(Mathf.Round(moved4 * 3f) / 3f); } GUI.DrawTexture(new Rect(32f, RowTop(top, 4.25f) - 1f, 408f, 2f), (Texture)(object)_rule); float num = session.TiltShiftBlur * 100f; if (Slider(top, 4.5f, _tiltShiftBlurLabel, _tiltShiftBlur, num, num, 0f, 20f, out var moved5)) { session.SetTiltShiftBlur(Mathf.Round(moved5) / 100f); } } private void LockedRow(float top, float row, GUIContent label, float position, float min, float max, GUIContent value) { //IL_0019: 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_007d: 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); float num2 = 32f + 150f; float num3 = 130f; GUI.enabled = false; HorizontalSlider(new Rect(num2, num + 17f - 6f, num3, 12f), position, min, max); GUI.enabled = true; GUI.Label(new Rect(num2 + num3 + 8f, num, 120f, 34f), value, _value); } private void DrawEffects(PhotoModeSession session, float top) { ColumnBackground(top, LensEffects.All.Length); for (int i = 0; i < LensEffects.All.Length; i++) { LensEffect effect = LensEffects.All[i]; float num = session.EffectValue(effect); if (Slider(top, i, _effectLabels[i], _effectValues[i], num, num, effect.Min(), effect.Max(), out var moved)) { session.SetEffect(effect, Mathf.Round(moved * 100f) / 100f); } } } private bool LogSlider(float top, float row, GUIContent label, ValueText text, float value, float min, float max, out float moved) { float moved2; bool result = Slider(top, row, label, text, value, Mathf.Log(value), Mathf.Log(min), Mathf.Log(max), out moved2); moved = Mathf.Exp(moved2); return result; } private bool Slider(float top, float row, GUIContent label, ValueText text, float value, float position, float min, float max, out float moved) { //IL_0019: 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_007e: 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); float num2 = 32f + 150f; float num3 = 130f; GUI.changed = false; moved = HorizontalSlider(new Rect(num2, num + 17f - 6f, num3, 12f), position, min, max); bool changed = GUI.changed; GUI.Label(new Rect(num2 + num3 + 8f, num, 120f, 34f), text.For(value), _value); return changed; } private static float RoundFocusDistance(float meters) { if (!(meters < 10f)) { if (!(meters < 100f)) { return Mathf.Round(meters); } return Mathf.Round(meters * 10f) / 10f; } return Mathf.Round(meters * 100f) / 100f; } public bool Covers(Vector2 point) { //IL_0000: 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_0012: 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_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) Vector2 val = point / ((float)Screen.height / 1080f); if (!(val.y <= 68f) && !(val.y >= 1022f)) { return ((Rect)(ref _column)).Contains(val); } return true; } private void DrawHints(float width) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) float num = 1030f; GUI.DrawTexture(new Rect(0f, 1022f, width, 58f), (Texture)(object)_background); GUI.Label(new Rect(16f, num, width - 32f, 34f), _hints, _hint); } private void DrawStatus(float width) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) if (!string.IsNullOrEmpty(_status.text)) { GUI.Label(new Rect(width - 520f - 16f, 76f, 520f, 34f), _status, _statusStyle); } } private void EnsureStyles() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Expected O, but got Unknown //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Expected O, but got Unknown //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Expected O, but got Unknown //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0128: 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_0135: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Expected O, but got Unknown //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Expected O, but got Unknown //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Expected O, but got Unknown //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Expected O, but got Unknown //IL_01e0: Unknown result type (might be due to invalid IL or missing references) if (_button == null) { _background = new Texture2D(1, 1); _background.SetPixel(0, 0, new Color(0.06f, 0.07f, 0.08f, 0.82f)); _background.Apply(); ((Object)_background).hideFlags = (HideFlags)61; _rule = new Texture2D(1, 1); _rule.SetPixel(0, 0, new Color(1f, 1f, 1f, 0.3f)); _rule.Apply(); ((Object)_rule).hideFlags = (HideFlags)61; _button = new GUIStyle(GUI.skin.button) { fontSize = 17 }; _selected = new GUIStyle(_button) { fontStyle = (FontStyle)1 }; _selected.normal.textColor = new Color(1f, 0.82f, 0.45f, 1f); _selected.hover.textColor = _selected.normal.textColor; _label = new GUIStyle(GUI.skin.label) { fontSize = 17, alignment = (TextAnchor)3 }; _value = new GUIStyle(_label) { alignment = (TextAnchor)5 }; _hint = new GUIStyle(GUI.skin.label) { fontSize = 16, alignment = (TextAnchor)4 }; _slider = GUI.skin.horizontalSlider; _thumb = GUI.skin.horizontalSliderThumb; _statusStyle = new GUIStyle(GUI.skin.label) { fontSize = 17, alignment = (TextAnchor)5 }; _statusStyle.normal.textColor = new Color(1f, 0.82f, 0.45f, 1f); } } } internal sealed class PhysicalLensRig { private bool _on; private Camera _camera; private HDAdditionalCameraData _cameraData; private bool _physical; private Vector2 _sensorSize; private GateFitMode _gateFit; private float _fieldOfView; private float _focalLength; private float _aperture; private float _focusDistance; private bool _customFrameSettings; private FrameSettings _frameSettings; private FrameSettingsOverrideMask _frameSettingsMask; public bool IsOn => _on; public void SwitchOn(Camera camera) { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: 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_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Expected I4, but got Unknown //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) HDAdditionalCameraData component = ((Component)camera).GetComponent(); if ((Object)(object)component == (Object)null) { throw new InvalidOperationException("Camera '" + ((Object)camera).name + "' has no HDAdditionalCameraData"); } _camera = camera; _cameraData = component; _physical = camera.usePhysicalProperties; _sensorSize = camera.sensorSize; _gateFit = camera.gateFit; _fieldOfView = camera.fieldOfView; _focalLength = camera.focalLength; _aperture = camera.aperture; _focusDistance = camera.focusDistance; _customFrameSettings = component.customRenderingSettings; _frameSettings = component.renderingPathCustomFrameSettings; _frameSettingsMask = component.renderingPathCustomFrameSettingsOverrideMask; _on = true; camera.usePhysicalProperties = true; camera.sensorSize = new Vector2(36f, 24f); camera.gateFit = (GateFitMode)1; FrameSettings renderingPathCustomFrameSettings = component.renderingPathCustomFrameSettings; FrameSettingsOverrideMask renderingPathCustomFrameSettingsOverrideMask = component.renderingPathCustomFrameSettingsOverrideMask; FrameSettingsField[] array = new FrameSettingsField[4]; RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/); FrameSettingsField[] array2 = (FrameSettingsField[])(object)array; foreach (FrameSettingsField val in array2) { ((FrameSettings)(ref renderingPathCustomFrameSettings)).SetEnabled(val, true); ((BitArray128)(ref renderingPathCustomFrameSettingsOverrideMask.mask))[(uint)(int)val] = true; } component.renderingPathCustomFrameSettings = renderingPathCustomFrameSettings; component.renderingPathCustomFrameSettingsOverrideMask = renderingPathCustomFrameSettingsOverrideMask; component.customRenderingSettings = true; ((VolumeComponent)ModVolume.DepthOfField).active = true; } public void Apply(RenderedLens lens) { //IL_0010: 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) _camera.sensorSize = new Vector2(36f, 24f) * lens.SensorScale; _camera.focalLength = lens.FocalLength * lens.SensorScale; _camera.aperture = lens.Aperture; _camera.focusDistance = lens.FocusDistance; ((VolumeParameter)(object)ModVolume.DepthOfField.focusMode).value = (DepthOfFieldMode)(lens.DepthOfField ? 1 : 0); } public void SwitchOff() { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) if (_on) { _on = false; ((VolumeComponent)ModVolume.DepthOfField).active = false; if (!((Object)(object)_camera == (Object)null)) { _cameraData.renderingPathCustomFrameSettings = _frameSettings; _cameraData.renderingPathCustomFrameSettingsOverrideMask = _frameSettingsMask; _cameraData.customRenderingSettings = _customFrameSettings; _camera.sensorSize = _sensorSize; _camera.gateFit = _gateFit; _camera.focalLength = _focalLength; _camera.aperture = _aperture; _camera.focusDistance = _focusDistance; _camera.usePhysicalProperties = _physical; _camera.fieldOfView = _fieldOfView; } } } } [BepInPlugin("mugsy33.photomod", "Photo Mod", "1.0.0")] public class Plugin : BasePlugin { public const string PluginGuid = "mugsy33.photomod"; public const string PluginName = "Photo Mod"; public const string PluginVersion = "1.0.0"; internal static ManualLogSource Log; internal static ConfigEntry ConfigEnabled; internal static ConfigEntry ConfigPhotoModeKey; internal static ConfigEntry ConfigLeaveKey; internal static ConfigEntry ConfigForwardKey; internal static ConfigEntry ConfigBackKey; internal static ConfigEntry ConfigLeftKey; internal static ConfigEntry ConfigRightKey; internal static ConfigEntry ConfigDownKey; internal static ConfigEntry ConfigUpKey; internal static ConfigEntry ConfigAimKey; internal static ConfigEntry ConfigFasterKey; internal static ConfigEntry ConfigSlowerKey; internal static ConfigEntry ConfigResetCameraKey; internal static ConfigEntry ConfigCameraRange; internal static ConfigEntry ConfigCaptureKey; internal static ConfigEntry ConfigHidePanelKey; internal static ConfigEntry ConfigPhotoFolder; internal static ConfigEntry ConfigAddToSteam; internal static readonly bool DebugLogging; public override void Load() { //IL_0292: Unknown result type (might be due to invalid IL or missing references) //IL_029c: Expected O, but got Unknown //IL_02bf: Unknown result type (might be due to invalid IL or missing references) //IL_033a: Unknown result type (might be due to invalid IL or missing references) //IL_0340: Expected O, but got Unknown Log = ((BasePlugin)this).Log; ConfigEnabled = ((BasePlugin)this).Config.Bind("Photo Mod", "Enabled", true, "Master on/off switch for this tool."); ConfigPhotoModeKey = ((BasePlugin)this).Config.Bind("Photo Mod", "PhotoModeKey", (KeyCode)284, "Enters and leaves Photo Mode."); ConfigLeaveKey = ((BasePlugin)this).Config.Bind("Photo Mod", "LeaveKey", (KeyCode)27, "Leaves Photo Mode."); ConfigCaptureKey = ((BasePlugin)this).Config.Bind("Photo Mod", "CaptureKey", (KeyCode)32, "Takes a photo in Photo Mode."); ConfigHidePanelKey = ((BasePlugin)this).Config.Bind("Photo Mod", "HidePanelKey", (KeyCode)104, "Hides and shows the Photo Panel in Photo Mode."); ConfigPhotoFolder = ((BasePlugin)this).Config.Bind("Photo Mod", "PhotoFolder", Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures), "ASKA Photo Mod"), "Folder each photo and its settings file are saved to. Created on the first capture."); ConfigAddToSteam = ((BasePlugin)this).Config.Bind("Photo Mod", "AddToSteam", true, "Also adds each photo to Steam's screenshot library for ASKA. The PNG is always saved to PhotoFolder. " + PhotoFolder.SteamTooLarge + ", so larger photos are not added."); ConfigForwardKey = ((BasePlugin)this).Config.Bind("Camera", "ForwardKey", (KeyCode)119, "In Photo Mode, flies the camera forward."); ConfigBackKey = ((BasePlugin)this).Config.Bind("Camera", "BackKey", (KeyCode)115, "In Photo Mode, flies the camera back."); ConfigLeftKey = ((BasePlugin)this).Config.Bind("Camera", "LeftKey", (KeyCode)97, "In Photo Mode, flies the camera left."); ConfigRightKey = ((BasePlugin)this).Config.Bind("Camera", "RightKey", (KeyCode)100, "In Photo Mode, flies the camera right."); ConfigDownKey = ((BasePlugin)this).Config.Bind("Camera", "DownKey", (KeyCode)113, "In Photo Mode, flies the camera down."); ConfigUpKey = ((BasePlugin)this).Config.Bind("Camera", "UpKey", (KeyCode)101, "In Photo Mode, flies the camera up."); ConfigAimKey = ((BasePlugin)this).Config.Bind("Camera", "AimKey", (KeyCode)324, "In Photo Mode, hold to aim the camera with the mouse."); ConfigFasterKey = ((BasePlugin)this).Config.Bind("Camera", "FasterKey", (KeyCode)304, "In Photo Mode, hold to fly the camera five times faster."); ConfigSlowerKey = ((BasePlugin)this).Config.Bind("Camera", "SlowerKey", (KeyCode)306, "In Photo Mode, hold to fly the camera five times slower."); ConfigResetCameraKey = ((BasePlugin)this).Config.Bind("Camera", "ResetCameraKey", (KeyCode)114, "In Photo Mode, puts the camera back where it was on entering."); ConfigCameraRange = ((BasePlugin)this).Config.Bind("Camera", "Range", 400f, new ConfigDescription("How far, in meters, the camera can fly from where the character stood on entering Photo Mode.", (AcceptableValueBase)(object)new AcceptableValueRange(10f, 10000f), Array.Empty())); ModStrings.Init(Log, "[Photo Mod][strings]"); ClassInjector.RegisterTypeInIl2Cpp(); LocalPlayerTool.Register(Log, "AskaPhotoMod_Tool", Vector3.zero, typeof(PhotoModTool)); Harmony.CreateAndPatchAll(typeof(SaveGate), "mugsy33.photomod"); Harmony.CreateAndPatchAll(typeof(SeasonTint), "mugsy33.photomod"); Harmony.CreateAndPatchAll(typeof(DayEventHold), "mugsy33.photomod"); Harmony.CreateAndPatchAll(typeof(TurnCameraGate), "mugsy33.photomod"); ManualLogSource log = Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(10, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("Photo Mod"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" v"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("1.0.0"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" loaded."); } log.LogInfo(val); } } [HarmonyPatch(typeof(StorageManager), "SaveCurrentSession")] internal static class SaveGate { [HarmonyPrefix] private static bool Prefix(ref Task __result) { if (!GamePorts.PhotoModeActive) { return true; } __result = Task.CompletedTask; Plugin.Log.LogInfo((object)"Photo Mode is active, so the game's save was skipped."); return false; } } internal sealed class ScreenGrab : IFramePort { private static readonly int ArrayHeaderBytes = 4 * IntPtr.Size; public bool DynamicResolution { get { return CameraData().allowDynamicResolution; } set { CameraData().allowDynamicResolution = value; } } public Upscaler Upscaler { get { HDAdditionalCameraData val = CameraData(); if (!val.allowDeepLearningSuperSampling) { if (!val.allowFidelityFX2SuperResolution) { return Upscaler.None; } return Upscaler.Fsr2; } return Upscaler.Dlss; } set { HDAdditionalCameraData obj = CameraData(); obj.allowDeepLearningSuperSampling = value == Upscaler.Dlss; obj.allowFidelityFX2SuperResolution = value == Upscaler.Fsr2; } } public AntiAliasing AntiAliasing { get { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected I4, but got Unknown return (AntiAliasing)CameraData().antialiasing; } set { CameraData().antialiasing = (AntialiasingMode)value; } } private static HDAdditionalCameraData CameraData() { InputManager obj = Object.FindObjectOfType(); return ((Component)(((obj != null) ? obj.GetCamera() : null) ?? throw new InvalidOperationException("The game camera was not found"))).GetComponent() ?? throw new InvalidOperationException("The game camera has no HDAdditionalCameraData"); } public unsafe Frame Grab(int multiplier) { Texture2D val = ScreenCapture.CaptureScreenshotAsTexture(multiplier); try { int width = ((Texture)val).width; int height = ((Texture)val).height; Il2CppStructArray pixels = val.GetPixels32(); if (((Il2CppArrayBase)(object)pixels).Length != width * height) { throw new InvalidOperationException($"GetPixels32 returned {((Il2CppArrayBase)(object)pixels).Length} pixels for a {width}x{height} capture"); } byte[] array = new byte[width * height * 4]; int num = width * 4; byte* ptr = (byte*)(void*)IntPtr.Add(((Il2CppObjectBase)pixels).Pointer, ArrayHeaderBytes); fixed (byte* ptr2 = array) { for (int i = 0; i < height; i++) { Buffer.MemoryCopy(ptr + (long)(height - 1 - i) * (long)num, ptr2 + (long)i * (long)num, num, num); } } return new Frame(width, height, array); } finally { Object.Destroy((Object)(object)val); } } } [HarmonyPatch(typeof(WeatherSystem), "_UpdateSeason")] internal static class SeasonTint { internal static float? Override; private static int _seasonalChange = -1; [HarmonyPostfix] private static void Postfix() { float? num = Override; if (num.HasValue) { float valueOrDefault = num.GetValueOrDefault(); if (_seasonalChange < 0) { _seasonalChange = Shader.PropertyToID("_Global_SeasonalChange"); } Shader.SetGlobalFloat(_seasonalChange, valueOrDefault); } } } internal static class Strings { internal const string TabPresets = "tab.presets"; internal const string TabCamera = "tab.camera"; internal const string TabScene = "tab.scene"; internal const string TabEffects = "tab.effects"; internal const string TabComposition = "tab.composition"; internal const string ButtonHideInterface = "button.hide_interface"; internal const string ButtonCapture = "button.capture"; internal const string ButtonExit = "button.exit"; internal const string PresetLandscape = "preset.landscape"; internal const string PresetPortrait = "preset.portrait"; internal const string PresetMacro = "preset.macro"; internal const string LabelFocalLength = "label.focal_length"; internal const string LabelAperture = "label.aperture"; internal const string LabelFocusDistance = "label.focus_distance"; internal const string LabelExposure = "label.exposure"; internal const string LabelTiltShiftBlur = "label.tilt_shift_blur"; internal const string LabelFullPause = "label.full_pause"; internal const string LabelTimeOfDay = "label.time_of_day"; internal const string LabelFog = "label.fog"; internal const string LabelSeason = "label.season"; internal const string LabelFoliageTint = "label.foliage_tint"; internal const string LabelTint = "label.tint"; internal const string LabelGroundSnow = "label.ground_snow"; internal const string LabelWeather = "label.weather"; internal const string LabelStrength = "label.strength"; internal const string LabelHidePlayer = "label.hide_player"; internal const string LabelHideVillagers = "label.hide_villagers"; internal const string LabelHideCreatures = "label.hide_creatures"; internal const string LabelShowHud = "label.show_hud"; internal const string LabelCaptureSize = "label.capture_size"; internal const string LabelGrid = "label.grid"; internal const string LabelLevelLine = "label.level_line"; internal const string LabelCropPresets = "label.crop_presets"; internal const string LabelRoll = "label.roll"; internal const string ValueOn = "value.on"; internal const string ValueOff = "value.off"; internal const string ValueGame = "value.game"; internal const string ValueGameLens = "value.game_lens"; internal const string ValueSetByTiltShift = "value.set_by_tilt_shift"; internal const string EffectVignette = "effect.vignette"; internal const string EffectFilmGrain = "effect.film_grain"; internal const string EffectLensDistortion = "effect.lens_distortion"; internal const string SeasonWinter = "season.winter"; internal const string SeasonSpring = "season.spring"; internal const string SeasonSummer = "season.summer"; internal const string SeasonAutumn = "season.autumn"; internal const string WeatherGameForecast = "weather.game_forecast"; internal const string WeatherClear = "weather.clear"; internal const string WeatherOvercast = "weather.overcast"; internal const string WeatherSpringClouds = "weather.spring_clouds"; internal const string WeatherAutumnClouds = "weather.autumn_clouds"; internal const string WeatherFog = "weather.fog"; internal const string WeatherHeavyRain = "weather.heavy_rain"; internal const string WeatherSkollThunderstorm = "weather.skoll_thunderstorm"; internal const string WeatherBlizzard = "weather.blizzard"; internal const string ShapeTitle = "shape.title"; internal const string ShapeHeader = "shape.header"; internal const string ShapeThumbnail = "shape.thumbnail"; internal const string HintFocus = "hint.focus"; internal const string HintMove = "hint.move"; internal const string HintAim = "hint.aim"; internal const string HintUp = "hint.up"; internal const string HintDown = "hint.down"; internal const string HintFaster = "hint.faster"; internal const string HintSlower = "hint.slower"; internal const string KeyLeftClick = "key.left_click"; internal const string KeyRightMouse = "key.right_mouse"; internal const string KeyMiddleMouse = "key.middle_mouse"; internal const string KeyShift = "key.shift"; internal const string KeyCtrl = "key.ctrl"; internal const string StatusNothingToFocus = "status.nothing_to_focus"; internal const string StatusRefusedMultiplayer = "status.refused_multiplayer"; internal const string StatusRefusedSaving = "status.refused_saving"; internal const string StatusCapturing = "status.capturing"; internal const string StatusCaptureFailed = "status.capture_failed"; internal const string StatusSaveFailed = "status.save_failed"; internal const string StatusSaved = "status.saved"; internal const string StatusSaving = "status.saving"; } internal sealed class SubjectHider { private sealed class Group { internal readonly string Name; internal bool Hidden; internal readonly List Members = new List(); internal readonly HashSet MemberPointers = new HashSet(); internal readonly List Renderers = new List(); internal readonly List WasEnabled = new List(); internal int Rescan = -1; internal int List = -1; internal int Entry; internal Group(string name) { Name = name; } } private const int SubjectsPerFrame = 4; private const int ListEntriesPerFrame = 32; private readonly Group[] _groups = new Group[3] { new Group("player"), new Group("villagers"), new Group("creatures") }; private readonly HashSet _recorded = new HashSet(); private readonly List _found = new List(); private PopulationManager _population; private int _villagersOffset; private readonly List _spawners = new List(); private int _activeCreaturesOffset; private readonly HashSet _dens = new HashSet(); private readonly Dictionary _listLayouts = new Dictionary(); public bool IsHidden(Subject subject) { return _groups[(int)subject].Hidden; } public void SetHidden(Subject subject, bool hidden) { Group obj = _groups[(int)subject]; if (hidden != obj.Hidden) { if (hidden) { Hide(subject, obj); } else { Show(obj); } } } public void HideNew(Subject subject) { Group obj = _groups[(int)subject]; if (!obj.Hidden) { return; } if (subject == Subject.Player) { if (obj.Rescan < 0) { obj.Rescan = 0; } } else if (obj.List < 0) { Group obj2 = obj; obj2.List = 0; obj.Entry = 0; } } public void Step() { int num = 32; for (int i = 1; i < _groups.Length; i++) { if (num <= 0) { break; } num = Discover((Subject)i, _groups[i], num); } int num2 = 4; Group[] groups = _groups; foreach (Group obj in groups) { while (obj.Rescan >= 0 && num2 > 0) { if (obj.Rescan >= obj.Members.Count) { obj.Rescan = -1; break; } Component val = obj.Members[obj.Rescan++]; num2--; if ((Object)(object)val != (Object)null) { TurnOff(obj, val); } } if (num2 == 0) { break; } } } private void Hide(Subject subject, Group group) { //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Expected O, but got Unknown group.Hidden = true; FindLists(subject); foreach (Component item in Find(subject)) { if ((Object)(object)item != (Object)null && !IsDen(item)) { AddMember(group, item); } } foreach (Component member in group.Members) { TurnOff(group, member); } ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(42, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Hid "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(group.Members.Count); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(group.Name); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(group.Renderers.Count); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" renderers recorded and turned off."); } log.LogInfo(val); } private void Show(Group group) { //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Expected O, but got Unknown int num = 0; int num2 = 0; for (int i = 0; i < group.Renderers.Count; i++) { Renderer val = group.Renderers[i]; _recorded.Remove(((Il2CppObjectBase)val).Pointer); if ((Object)(object)val == (Object)null) { num2++; continue; } val.enabled = group.WasEnabled[i]; num++; } group.Renderers.Clear(); group.WasEnabled.Clear(); group.Members.Clear(); group.MemberPointers.Clear(); group.Rescan = -1; group.List = -1; group.Hidden = false; ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(54, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Showed "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(group.Name); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(": "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(num); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" renderers put back, "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(num2); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" destroyed while hidden."); } log.LogInfo(val2); } private void FindLists(Subject subject) { switch (subject) { case Subject.Villagers: _population = Object.FindObjectOfType(); if ((Object)(object)_population != (Object)null) { _villagersOffset = FieldOffset(((Il2CppObjectBase)_population).Pointer, "_villagers"); } break; case Subject.Creatures: _spawners.Clear(); _dens.Clear(); foreach (CreatureSpawner item in Object.FindObjectsOfType(true)) { _spawners.Add(item); } if (_spawners.Count > 0) { _activeCreaturesOffset = FieldOffset(((Il2CppObjectBase)_spawners[0]).Pointer, "_activeCreatures"); } break; } } private static IEnumerable Find(Subject subject) { return subject switch { Subject.Player => (IEnumerable)(object)new Component[1] { (Component)(LocalPlayerTool.LocalCharacter ?? throw new InvalidOperationException("No local character")) }, Subject.Villagers => (IEnumerable)Object.FindObjectsOfType(true), _ => (IEnumerable)Object.FindObjectsOfType(true), }; } internal static bool IsDen(Component c) { return (Object)(object)((Il2CppObjectBase)c).TryCast() != (Object)null; } private static void AddMember(Group group, Component c) { if (group.MemberPointers.Add(((Il2CppObjectBase)c).Pointer)) { group.Members.Add(c); } } private int Discover(Subject subject, Group group, int entries) { int num = ((subject == Subject.Villagers) ? (((Object)(object)_population != (Object)null) ? 1 : 0) : _spawners.Count); while (group.List >= 0 && entries > 0) { if (group.List >= num) { group.List = -1; if (group.Rescan < 0) { group.Rescan = 0; } break; } IntPtr intPtr = ((subject == Subject.Villagers) ? FieldPointer((Object)(object)_population, _villagersOffset) : (((Object)(object)_spawners[group.List] != (Object)null) ? FieldPointer((Object)(object)_spawners[group.List], _activeCreaturesOffset) : IntPtr.Zero)); entries--; int num2 = 0; IntPtr array = IntPtr.Zero; if (intPtr != IntPtr.Zero) { (num2, array) = ListContents(intPtr); } while (group.Entry < num2 && entries > 0) { AddListed(group, Element(array, group.Entry++), subject == Subject.Creatures); entries--; } if (group.Entry >= num2) { int list = group.List + 1; group.List = list; group.Entry = 0; } } return entries; } private void AddListed(Group group, IntPtr p, bool dens) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Expected O, but got Unknown if (!(p == IntPtr.Zero) && !group.MemberPointers.Contains(p) && !_dens.Contains(p)) { Component c = (Component)(dens ? new Creature(p) : new Villager(p)); if (dens && IsDen(c)) { _dens.Add(p); } else { AddMember(group, c); } } } private void TurnOff(Group group, Component member) { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Expected O, but got Unknown member.GetComponentsInChildren(true, _found); (int Count, IntPtr Items) tuple = ListContents(((Il2CppObjectBase)_found).Pointer); int item = tuple.Count; IntPtr item2 = tuple.Items; for (int i = 0; i < item; i++) { IntPtr intPtr = Element(item2, i); if (_recorded.Add(intPtr)) { Renderer val = new Renderer(intPtr); group.Renderers.Add(val); group.WasEnabled.Add(val.enabled); val.enabled = false; } } } private (int Count, IntPtr Items) ListContents(IntPtr list) { IntPtr key = IL2CPP.il2cpp_object_get_class(list); if (!_listLayouts.TryGetValue(key, out (int, int) value)) { value = (FieldOffset(list, "_items"), FieldOffset(list, "_size")); _listLayouts[key] = value; } return (Count: Marshal.ReadInt32(list + value.Item2), Items: Marshal.ReadIntPtr(list + value.Item1)); } private static IntPtr Element(IntPtr array, int i) { return Marshal.ReadIntPtr(array, (4 + i) * IntPtr.Size); } private static IntPtr FieldPointer(Object owner, int offset) { return Marshal.ReadIntPtr(((Il2CppObjectBase)owner).Pointer + offset); } private static int FieldOffset(IntPtr instance, string name) { IntPtr il2CppField = IL2CPP.GetIl2CppField(IL2CPP.il2cpp_object_get_class(instance), name); if (il2CppField == IntPtr.Zero) { throw new InvalidOperationException("Il2Cpp object has no " + name + " field"); } return (int)IL2CPP.il2cpp_field_get_offset(il2CppField); } } [HarmonyPatch(typeof(InputManager), "TurnCamera")] internal static class TurnCameraGate { [HarmonyPrefix] private static bool Prefix(InputManager __instance) { if (!((Object)(object)__instance.brain == (Object)null)) { return ((Behaviour)__instance.brain).enabled; } return true; } } public static class MyPluginInfo { public const string PLUGIN_GUID = "PhotoMod"; public const string PLUGIN_NAME = "Photo Mod"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace AskaPhotoMod.Core { public readonly record struct CameraInput { public float Forward { get; init; } public float Right { get; init; } public float Up { get; init; } public float WheelNotches { get; init; } public float AimX { get; init; } public float AimY { get; init; } public bool Faster { get; init; } public bool Slower { get; init; } } public readonly record struct CameraPose(Vector3 Position, Quaternion Rotation); public static class CameraRoll { public static float Degrees(Quaternion rotation) { Vector3 vector = Vector3.Transform(Vector3.UnitZ, rotation); Vector3 vector2 = Vector3.Transform(Vector3.UnitX, rotation); Vector3 value = Vector3.Cross(Vector3.UnitY, vector); if (value.LengthSquared() < 1E-08f) { return 0f; } value = Vector3.Normalize(value); Vector3 vector3 = Vector3.Cross(vector, value); return MathF.Atan2(Vector3.Dot(vector2, vector3), Vector3.Dot(vector2, value)) * 180f / (float)Math.PI; } } public sealed record CapturedPhoto(string PngFile, string SettingsFile, int Width, int Height, bool SteamSkipped) { public Exception? SteamError { get; init; } } public enum CaptureSize { X1 = 1, X2 = 2, X4 = 4 } public enum EnterResult { Entered, RefusedInMultiplayer, RefusedSaveInProgress } public sealed class Frame { public int Width { get; } public int Height { get; } public byte[] Rgba { get; } public Frame(int width, int height, byte[] rgba) { if (rgba.Length != width * height * 4) { throw new ArgumentException($"{rgba.Length} bytes is not a {width}x{height} RGBA frame", "rgba"); } Width = width; Height = height; Rgba = rgba; } } internal sealed class FreeFlyCamera { internal const float Speed = 10f; private const float FasterScale = 5f; private const float SlowerScale = 0.2f; private const float WheelStep = 0.5f; internal const float AimRadiansPerUnit = 0.0017453294f; private const float PitchLimit = (float)Math.PI * 89f / 180f; internal const float SphereRadius = 0.3f; private CameraPose _entryPose; private Vector3 _position; private Quaternion _rotation; private float _yaw; private float _pitch; private float _rollDegrees; private Vector3 _rangeCenter; private float _range; public CameraPose Pose => new CameraPose(_position, _rotation); public float YawDegrees => MathF.Atan2(MathF.Sin(_yaw), MathF.Cos(_yaw)) * 180f / (float)Math.PI; public float PitchDegrees => _pitch * 180f / (float)Math.PI; public float RollDegrees { get { return _rollDegrees; } set { _rollDegrees = value; Turn(); } } public void Start(CameraPose entryPose, Vector3 rangeCenter, float range) { _entryPose = entryPose; _rangeCenter = rangeCenter; _range = range; Reset(); } public void Reset() { _position = _entryPose.Position; _rotation = _entryPose.Rotation; Vector3 vector = Vector3.Transform(Vector3.UnitZ, _rotation); _yaw = MathF.Atan2(vector.X, vector.Z); _pitch = MathF.Asin(Math.Clamp(0f - vector.Y, -1f, 1f)); _rollDegrees = 0f; } private void Turn() { _rotation = Quaternion.CreateFromYawPitchRoll(_yaw, _pitch, _rollDegrees * (float)Math.PI / 180f); } public void Move(CameraInput input, float deltaSeconds, ICameraPort collision) { if (input.AimX != 0f || input.AimY != 0f) { _yaw += input.AimX * 0.0017453294f; _pitch = Math.Clamp(_pitch - input.AimY * 0.0017453294f, (float)Math.PI * -89f / 180f, (float)Math.PI * 89f / 180f); Turn(); } Vector3 vector = Vector3.Transform(Vector3.UnitZ, _rotation); Vector3 vector2 = new Vector3(MathF.Cos(_yaw), 0f, 0f - MathF.Sin(_yaw)); Vector3 vector3 = (vector * input.Forward + vector2 * input.Right + Vector3.UnitY * input.Up) * (10f * deltaSeconds); Vector3 vector4 = vector * (input.WheelNotches * 0.5f); _position = StopShortOfCollision(_position, WithinRange(_position + (vector3 + vector4) * SpeedScale(input)), collision); } private static Vector3 StopShortOfCollision(Vector3 from, Vector3 to, ICameraPort collision) { Vector3 vector = to - from; float num = vector.Length(); if (num == 0f) { return from; } Vector3 vector2 = vector / num; float? num2 = collision.CollisionDistance(from, to + vector2 * 0.3f); if (num2.HasValue) { float valueOrDefault = num2.GetValueOrDefault(); return from + vector2 * MathF.Max(0f, valueOrDefault - 0.3f); } return to; } private static float SpeedScale(CameraInput input) { return (input.Faster ? 5f : 1f) * (input.Slower ? 0.2f : 1f); } private Vector3 WithinRange(Vector3 position) { Vector3 vector = position - _rangeCenter; float num = vector.Length(); if (!(num <= _range)) { return _rangeCenter + vector * (_range / num); } return position; } } public sealed class GuideSettings { public bool Grid { get; set; } public bool Level { get; set; } public StoreShape? Frame { get; set; } } public sealed record RestoreFailure(string Step, Exception Error); public sealed record LeaveResult(IReadOnlyList Failures); public enum LensEffect { Vignette, FilmGrain, LensDistortion } public static class LensEffects { public static readonly LensEffect[] All = new LensEffect[3] { LensEffect.Vignette, LensEffect.FilmGrain, LensEffect.LensDistortion }; public static float Min(this LensEffect effect) { if (effect != LensEffect.LensDistortion) { return 0f; } return -1f; } public static float Max(this LensEffect effect) { return 1f; } public static string Label(this LensEffect effect) { return effect switch { LensEffect.Vignette => "Vignette", LensEffect.FilmGrain => "Film grain", _ => "Lens distortion", }; } } public enum LensPreset { Landscape, Portrait, Macro } public static class LensPresets { public static PhotoLens Lens(this LensPreset preset) { return preset switch { LensPreset.Landscape => new PhotoLens(16f, 11f, 50f), LensPreset.Portrait => new PhotoLens(85f, 1.4f, 3f), LensPreset.Macro => new PhotoLens(100f, 1.4f, 1f), _ => throw new ArgumentOutOfRangeException("preset", preset, null), }; } } public readonly record struct PhotoLens(float FocalLength, float Aperture, float FocusDistance) { public float FieldOfView => 2f * MathF.Atan(12f / FocalLength) * 180f / (float)Math.PI; public const float SensorWidth = 36f; public const float SensorHeight = 24f; public const float MinFocalLength = 8f; public const float MaxFocalLength = 200f; public const float MinAperture = 1.4f; public const float MaxAperture = 22f; public const float MinFocusDistance = 0.1f; public const float MaxFocusDistance = 1000f; public PhotoLens Clamped() { return new PhotoLens(Math.Clamp(FocalLength, 8f, 200f), Math.Clamp(Aperture, 1.4f, 22f), Math.Clamp(FocusDistance, 0.1f, 1000f)); } public static float FocalLengthFor(float fieldOfView) { return 12f / MathF.Tan(fieldOfView / 2f * (float)Math.PI / 180f); } } public sealed class PhotoModeSession { private readonly ICameraPort _camera; private readonly ISubjectsPort _subjects; private readonly IInputPort _input; private readonly IWorldPort _world; private readonly ISessionInfoPort _sessionInfo; private readonly ISaveGatePort _saveGate; private readonly IFramePort _frame; private readonly IOutputPort _output; private readonly IEffectsPort _effects; public const float FullPauseTimeScale = 0f; private const float EntryAperture = 11f; private const float EntryFocusDistance = 10f; private readonly RestoreLedger _ledger = new RestoreLedger(); private readonly RestoreLedger _captureLedger = new RestoreLedger(); private bool _captureQualityPrepared; private readonly HashSet _ledgeredSubjects = new HashSet(); private bool _seasonLedgered; private bool _tintLedgered; private readonly HashSet _ledgeredEffects = new HashSet(); private readonly HashSet _ledgeredSceneControls = new HashSet(); private float _entryTimeScale; private bool _entrySimulationPaused; private bool _fullPauseHeldThisVisit; private bool _weatherLedgered; private bool _snowLedgered; private float _entrySnow; private float? _groundSnow; private string? _lastStamp; private int _photosThisStamp; private float _captureProgress; private readonly FreeFlyCamera _flyCamera = new FreeFlyCamera(); public const CaptureSize LargestForSteam = CaptureSize.X2; public const float MaxTiltShiftBlur = 0.2f; public const float TiltShiftAperture = 2.8f; private const float RescanSeconds = 1f; private float _sinceRescan; public const float WinterGroundSnow = 0.85f; private const string Signed1 = "0.#;-0.#;0"; private const string Signed2 = "0.##;-0.##;0"; public bool IsActive { get; private set; } public bool FullPause { get; private set; } public float RangeLimit { get; set; } public CaptureSize CaptureSize { get; set; } = CaptureSize.X2; public bool AddToSteam { get; set; } public bool PanelVisible { get; private set; } public GuideSettings Guides { get; } = new GuideSettings(); public float TiltShiftBlur { get; private set; } public float RollDegrees => CameraRoll.Degrees(_camera.Pose.Rotation); public float Roll => _flyCamera.RollDegrees; public PhotoLens Lens { get; private set; } public float GameFocalLength { get; private set; } public bool DepthOfField { get; private set; } public bool HudShown => !_subjects.HudHidden; public float TimeOfDay { get; private set; } public float Fog { get; private set; } public float Exposure { get; private set; } public WeatherPreset? Weather { get; private set; } public float WeatherStrength { get; private set; } = 1f; public Season? SeasonPreset => _world.SeasonPreset; public float GroundSnow => _groundSnow ?? _entrySnow; public float? FoliageTint => _world.FoliageTint; public float CaptureProgress => Volatile.Read(in _captureProgress); public PhotoModeSession(ICameraPort camera, ISubjectsPort subjects, IInputPort input, IWorldPort world, ISessionInfoPort sessionInfo, ISaveGatePort saveGate, IFramePort frame, IOutputPort output, IEffectsPort effects) { _camera = camera; _subjects = subjects; _input = input; _world = world; _sessionInfo = sessionInfo; _saveGate = saveGate; _frame = frame; _output = output; _effects = effects; } public void SetTiltShiftBlur(float share) { TiltShiftBlur = Math.Clamp(share, 0f, 0.2f); if (TiltShiftBlur > 0f) { DepthOfField = true; } RenderLens(); } public EnterResult Enter() { if (!_sessionInfo.IsSinglePlayer) { return EnterResult.RefusedInMultiplayer; } if (_saveGate.SaveInProgress) { return EnterResult.RefusedSaveInProgress; } try { _ledger.Change("Photo Mode active", () => _sessionInfo.PhotoModeActive, delegate(bool v) { _sessionInfo.PhotoModeActive = v; }, value: true); _ledger.Change("game input", () => _input.GameInputBlocked, delegate(bool v) { _input.GameInputBlocked = v; }, value: true); _ledger.Change("camera brain", () => _camera.BrainEnabled, delegate(bool v) { _camera.BrainEnabled = v; }, value: false); _ledger.Record("camera pose", () => _camera.Pose, delegate(CameraPose v) { _camera.Pose = v; }); _ledger.Change("HUD", () => _subjects.HudHidden, delegate(bool v) { _subjects.HudHidden = v; }, value: true); _ledger.Change("Clock Freeze", () => _world.ClockFrozen, delegate(bool v) { _world.ClockFrozen = v; }, value: true); _entryTimeScale = _world.TimeScale; _ledger.Change("time scale", () => _world.TimeScale, delegate(float v) { _world.TimeScale = v; }, 0f); _entrySimulationPaused = _world.SimulationPaused; _entrySnow = _world.Snow; _ledger.Change("simulation pause", () => _world.SimulationPaused, delegate(bool v) { _world.SimulationPaused = v; }, value: true); _ledger.Change("instant exposure", () => _world.InstantExposure, delegate(bool v) { _world.InstantExposure = v; }, value: true); _ledger.Change("cursor", () => _input.CursorFree, delegate(bool v) { _input.CursorFree = v; }, value: true); float num = PhotoLens.FocalLengthFor(_camera.FieldOfView); _ledger.Change("lens", () => _camera.PhysicalLens, delegate(bool v) { _camera.PhysicalLens = v; }, value: true); _ledger.Change("anti-aliasing", () => _frame.AntiAliasing, delegate(AntiAliasing v) { _frame.AntiAliasing = v; }, AntiAliasing.Taa); TiltShiftBlur = 0f; DepthOfField = true; GameFocalLength = num; ApplyLens(new PhotoLens(num, 11f, 10f)); _flyCamera.Start(_camera.Pose, _subjects.CharacterPosition, RangeLimit); TimeOfDay = _world.TimeOfDay; Fog = _world.Fog; Exposure = _world.Exposure; } catch { _ledger.UndoAll(); throw; } IsActive = true; FullPause = true; _fullPauseHeldThisVisit = false; PanelVisible = true; return EnterResult.Entered; } public void SetFullPause(bool on) { _world.TimeScale = (on ? 0f : _entryTimeScale); _world.SimulationPaused = on || _entrySimulationPaused; FullPause = on; } public bool HoldFullPause() { if (!FullPause || _world.TimeScale == 0f) { return false; } _world.TimeScale = 0f; _world.SimulationPaused = true; bool result = !_fullPauseHeldThisVisit; _fullPauseHeldThisVisit = true; return result; } public void MoveCamera(CameraInput input, float deltaSeconds) { _flyCamera.Move(input, deltaSeconds, _camera); _camera.Pose = _flyCamera.Pose; } public void SetRoll(float degrees) { _flyCamera.RollDegrees = degrees; _camera.Pose = _flyCamera.Pose; } public void ApplyGameLens() { TiltShiftBlur = 0f; DepthOfField = false; ApplyLens(new PhotoLens(GameFocalLength, 11f, 10f)); } public void SetFocalLength(float millimeters) { ApplyLens(Lens with { FocalLength = millimeters }); } public void SetAperture(float fNumber) { DepthOfField = true; ApplyLens(Lens with { Aperture = fNumber }); } public void SetFocusDistance(float meters) { DepthOfField = true; ApplyLens(Lens with { FocusDistance = meters }); } public bool FocusAt(Vector2 viewportPoint) { Vector3? vector = _camera.SurfaceAt(viewportPoint); if (!vector.HasValue) { return false; } CameraPose pose = _flyCamera.Pose; SetFocusDistance(Vector3.Dot(vector.Value - pose.Position, Vector3.Transform(Vector3.UnitZ, pose.Rotation))); return true; } public void ApplyLensPreset(LensPreset preset) { TiltShiftBlur = 0f; DepthOfField = true; ApplyLens(preset.Lens()); } private void ApplyLens(PhotoLens lens) { Lens = lens.Clamped(); RenderLens(); } private void RenderLens() { _camera.SetLens((TiltShiftBlur > 0f) ? new RenderedLens(Lens.FocalLength, 2.8f, Lens.FocusDistance, TiltShiftLensScale(), DepthOfField) : new RenderedLens(Lens.FocalLength, Lens.Aperture, Lens.FocusDistance, 1f, DepthOfField)); } private float TiltShiftLensScale() { double num = TiltShiftBlur * 2.8f * 24f; double num2 = Lens.FocalLength; double num3 = (double)Lens.FocusDistance * 1000.0; return (float)(num * num3 / (num2 * num2 + num * num2)); } public void ResetCamera() { _flyCamera.Reset(); _camera.Pose = _flyCamera.Pose; } public void SetPanelVisible(bool visible) { PanelVisible = visible; _input.CursorFree = visible; } public void SetHudShown(bool shown) { _subjects.HudHidden = !shown; } public bool IsHidden(Subject subject) { return _subjects.IsHidden(subject); } public void SetHidden(Subject subject, bool hidden) { if (_ledgeredSubjects.Add(subject)) { _ledger.Record(subject.ToString() + " hidden", () => _subjects.IsHidden(subject), delegate(bool v) { _subjects.SetHidden(subject, v); }); } _subjects.SetHidden(subject, hidden); } public void KeepSubjectsHidden(float unscaledDeltaSeconds) { if (!IsActive || FullPause) { return; } _sinceRescan += unscaledDeltaSeconds; if (_sinceRescan < 1f) { return; } _sinceRescan = 0f; Subject[] all = Subjects.All; foreach (Subject subject in all) { if (_subjects.IsHidden(subject)) { _subjects.HideNew(subject); } } } public void SetTimeOfDay(float hours) { hours %= 24f; RecordSceneControl("time of day", () => _world.TimeOfDay, delegate(float v) { _world.TimeOfDay = v; }); _world.TimeOfDay = hours; TimeOfDay = hours; Season? seasonPreset = _world.SeasonPreset; if (seasonPreset.HasValue) { Season valueOrDefault = seasonPreset.GetValueOrDefault(); _world.SeasonPreset = valueOrDefault; } } public void SetFog(float multiple) { RecordSceneControl("fog", () => _world.Fog, delegate(float v) { _world.Fog = v; }); _world.Fog = multiple; Fog = multiple; } public void SetExposure(float stops) { RecordSceneControl("exposure", () => _world.Exposure, delegate(float v) { _world.Exposure = v; }); _world.Exposure = stops; Exposure = stops; } private void RecordSceneControl(string name, Func read, Action write) { if (_ledgeredSceneControls.Add(name)) { _ledger.Record(name, read, write); } } public void SetWeather(WeatherPreset? preset) { Weather = preset; ApplyWeather(); } public void SetWeatherStrength(float strength) { WeatherStrength = Math.Clamp(strength, 0f, 1f); if (Weather.HasValue) { ApplyWeather(); } } private void ApplyWeather() { if (!_weatherLedgered) { RecordSnow(); _ledger.Record("wetness", () => _world.Wetness, delegate(float v) { _world.Wetness = v; }); _ledger.Record("weather", () => _world.ForcedWeather, delegate(WeatherOverride? v) { _world.ForcedWeather = v; }); _weatherLedgered = true; } IWorldPort world = _world; WeatherPreset? weather = Weather; WeatherOverride? forcedWeather; if (weather.HasValue) { WeatherPreset valueOrDefault = weather.GetValueOrDefault(); forcedWeather = new WeatherOverride(valueOrDefault, WeatherStrength); } else { forcedWeather = null; } world.ForcedWeather = forcedWeather; } public void SetSeasonPreset(Season? season) { if (!_seasonLedgered) { _ledger.Record("season preset", () => _world.SeasonPreset, delegate(Season? v) { _world.SeasonPreset = v; }); } _seasonLedgered = true; _world.SeasonPreset = season; if (season.HasValue) { Season valueOrDefault = season.GetValueOrDefault(); SetGroundSnow((valueOrDefault == Season.Winter) ? 0.85f : 0f); } else if (_groundSnow.HasValue) { _world.Snow = _entrySnow; _groundSnow = null; } } public void SetGroundSnow(float snow) { RecordSnow(); _groundSnow = Math.Clamp(snow, 0f, 1f); _world.Snow = _groundSnow.Value; } private void RecordSnow() { if (!_snowLedgered) { _ledger.Record("snow", () => _entrySnow, delegate(float v) { _world.Snow = v; }); } _snowLedgered = true; } public void SetFoliageTint(float? tint) { if (!_tintLedgered) { _ledger.Record("foliage tint", () => _world.FoliageTint, delegate(float? v) { _world.FoliageTint = v; }); } _tintLedgered = true; IWorldPort world = _world; float? foliageTint; if (tint.HasValue) { float valueOrDefault = tint.GetValueOrDefault(); foliageTint = Math.Clamp(valueOrDefault, 0f, 1f); } else { foliageTint = null; } world.FoliageTint = foliageTint; } public float EffectValue(LensEffect effect) { return _effects.Get(effect).GetValueOrDefault(); } public void SetEffect(LensEffect effect, float value) { if (_ledgeredEffects.Add(effect)) { _ledger.Record(effect.Label(), () => _effects.Get(effect), delegate(float? v) { _effects.Set(effect, v); }); } _effects.Set(effect, Math.Clamp(value, effect.Min(), effect.Max())); } public LeaveResult Leave() { _ledgeredEffects.Clear(); IsActive = false; FullPause = false; PanelVisible = false; _ledgeredSubjects.Clear(); _weatherLedgered = false; _snowLedgered = false; _groundSnow = null; Weather = null; WeatherStrength = 1f; _seasonLedgered = false; _tintLedgered = false; _ledgeredSceneControls.Clear(); List list = new List(RestoreCaptureQuality()); list.AddRange(_ledger.UndoAll()); return new LeaveResult(list); } public Task Capture(DateTime takenAt) { Frame frame = GrabAtFullQuality(CaptureSize); string text = PhotoName(takenAt); bool flag = AddToSteam && CaptureSize > CaptureSize.X2; CapturedPhoto photo = new CapturedPhoto(text + ".png", text + ".txt", frame.Width, frame.Height, flag); string settings = SettingsText(photo); bool addToSteam = AddToSteam && !flag; Volatile.Write(ref _captureProgress, 0f); return Task.Run(delegate { _output.WritePng(photo.PngFile, PngEncoder.Encode(frame)); _output.WriteSettings(photo.SettingsFile, settings); Exception steamError = null; if (addToSteam) { try { _output.AddToSteam(photo.PngFile, photo.Width, photo.Height); } catch (Exception ex) { steamError = ex; } } Volatile.Write(ref _captureProgress, 1f); return photo with { SteamError = steamError }; }); } public void PrepareCapture() { if (_captureQualityPrepared) { return; } _captureQualityPrepared = true; try { _captureLedger.Change("dynamic resolution", () => _frame.DynamicResolution, delegate(bool v) { _frame.DynamicResolution = v; }, value: false); _captureLedger.Change("upscaler", () => _frame.Upscaler, delegate(Upscaler v) { _frame.Upscaler = v; }, Upscaler.None); } catch { RestoreCaptureQuality(); throw; } } private IReadOnlyList RestoreCaptureQuality() { _captureQualityPrepared = false; return _captureLedger.UndoAll(); } private Frame GrabAtFullQuality(CaptureSize size) { Frame result; IReadOnlyList readOnlyList; try { PrepareCapture(); result = _frame.Grab((int)size); } finally { readOnlyList = RestoreCaptureQuality(); } if (readOnlyList.Count > 0) { throw new InvalidOperationException("The capture could not restore " + string.Join(", ", readOnlyList.Select((RestoreFailure f) => f.Step)), new AggregateException(readOnlyList.Select((RestoreFailure f) => f.Error))); } return result; } private string PhotoName(DateTime takenAt) { string text = takenAt.ToString("yyyy-MM-dd_HH-mm-ss", CultureInfo.InvariantCulture); _photosThisStamp = ((!(text == _lastStamp)) ? 1 : (_photosThisStamp + 1)); _lastStamp = text; if (_photosThisStamp != 1) { return text + "_" + _photosThisStamp.ToString(CultureInfo.InvariantCulture); } return text; } private string SettingsText(CapturedPhoto photo) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("Photo Mod photo ").Append(photo.PngFile).Append("\r\n"); stringBuilder.Append("Capture size: ").Append((int)CaptureSize).Append("x (") .Append(photo.Width) .Append(" x ") .Append(photo.Height) .Append(" pixels)\r\n"); stringBuilder.Append("Game HUD: ").Append(_subjects.HudHidden ? "hidden" : "shown").Append("\r\n"); string text = string.Join(", ", Subjects.All.Where(_subjects.IsHidden)); stringBuilder.Append("Hidden subjects: ").Append((text.Length > 0) ? text : "none").Append("\r\n"); stringBuilder.Append("Focal length: ").Append(Number(Lens.FocalLength, "0.#")).Append(" mm (vertical field of view ") .Append(Number(Lens.FieldOfView, "0.0")) .Append(" degrees on a ") .Append(Number(36f, "0")) .Append(" x ") .Append(Number(24f, "0")) .Append(" mm sensor)\r\n"); stringBuilder.Append("Aperture: ").Append(DepthOfField ? ("f/" + Number(Lens.Aperture, "0.#")) : "off").Append("\r\n"); stringBuilder.Append("Focus distance: ").Append(Number(Lens.FocusDistance, "0.##")).Append(" m\r\n"); stringBuilder.Append("Roll: ").Append(Number(Roll, "0.#")).Append(" degrees\r\n"); CameraPose pose = _flyCamera.Pose; stringBuilder.Append("Camera position (x, y, z in meters): ").Append(Number(pose.Position.X, "0.##;-0.##;0")).Append(", ") .Append(Number(pose.Position.Y, "0.##;-0.##;0")) .Append(", ") .Append(Number(pose.Position.Z, "0.##;-0.##;0")) .Append("\r\n"); stringBuilder.Append("Yaw: ").Append(Number(_flyCamera.YawDegrees, "0.#;-0.#;0")).Append(" degrees\r\n"); stringBuilder.Append("Pitch: ").Append(Number(_flyCamera.PitchDegrees, "0.#;-0.#;0")).Append(" degrees, positive looks down\r\n"); stringBuilder.Append("Time of day: ").Append(ClockTime(TimeOfDay)).Append("\r\n"); stringBuilder.Append("Fog: ").Append(FogText(Fog)).Append("\r\n"); stringBuilder.Append("Exposure: ").Append(Number(Exposure, "+0.#;-0.#;0")).Append(" stops\r\n"); StringBuilder stringBuilder2 = stringBuilder.Append("Weather: "); WeatherPreset? weather = Weather; stringBuilder2.Append((!weather.HasValue) ? "game forecast" : (weather.GetValueOrDefault().ToString() + " at strength " + Number(WeatherStrength, "0.##"))).Append("\r\n"); stringBuilder.Append("Season preset: ").Append(SeasonPreset?.ToString() ?? "off").Append("\r\n"); StringBuilder stringBuilder3 = stringBuilder.Append("Foliage tint: "); float? foliageTint = FoliageTint; object value; if (foliageTint.HasValue) { float valueOrDefault = foliageTint.GetValueOrDefault(); value = Number(valueOrDefault, "0.##"); } else { value = "off"; } stringBuilder3.Append((string?)value).Append("\r\n"); stringBuilder.Append("Ground snow: ").Append(Number(GroundSnow, "0.##")).Append("\r\n"); LensEffect[] all = LensEffects.All; foreach (LensEffect effect in all) { float? num = _effects.Get(effect); StringBuilder stringBuilder4 = stringBuilder.Append(effect.Label()).Append(": "); object value2; if (num.HasValue) { float valueOrDefault2 = num.GetValueOrDefault(); value2 = Number(valueOrDefault2, "0.##"); } else { value2 = "game's own"; } stringBuilder4.Append((string?)value2).Append("\r\n"); } stringBuilder.Append((TiltShiftBlur > 0f) ? TiltShiftText() : "Tilt-shift: off").Append("\r\n"); return stringBuilder.ToString(); } public static string ClockTime(float hours) { int num = Math.Min((int)Math.Round(hours * 60f), 1439); return (num / 60).ToString("00", CultureInfo.InvariantCulture) + ":" + (num % 60).ToString("00", CultureInfo.InvariantCulture); } private static string FogText(float fog) { if (fog != 0f) { if (fog != 1f) { return Number(fog, "0.##") + " times the game's density"; } return "the game's own"; } return "off"; } private static string Number(float value, string format) { return value.ToString(format, CultureInfo.InvariantCulture); } private string TiltShiftText() { float num = TiltShiftLensScale(); return "Tilt-shift: blur " + Number(TiltShiftBlur * 100f, "0.#") + "% of the height, lens scale " + ((num < 1f) ? Number(num, "G3") : Number(MathF.Round(num), "0")) + "x"; } } internal static class PngEncoder { private const int BytesPerPixel = 3; private const byte SubFilter = 1; private static readonly byte[] Signature = new byte[8] { 137, 80, 78, 71, 13, 10, 26, 10 }; private static readonly uint[] CrcTable = BuildCrcTable(); public static byte[] Encode(Frame frame) { MemoryStream memoryStream = new MemoryStream(); memoryStream.Write(Signature); byte[] array = new byte[13]; BinaryPrimitives.WriteInt32BigEndian(array, frame.Width); BinaryPrimitives.WriteInt32BigEndian(array.AsSpan(4), frame.Height); array[8] = 8; array[9] = 2; WriteChunk(memoryStream, "IHDR", array); MemoryStream memoryStream2 = Compress(frame); WriteChunk(memoryStream, "IDAT", memoryStream2.GetBuffer().AsSpan(0, (int)memoryStream2.Length)); WriteChunk(memoryStream, "IEND", Array.Empty()); return memoryStream.ToArray(); } private static MemoryStream Compress(Frame frame) { byte[] array = new byte[frame.Width * 3 + 1]; array[0] = 1; MemoryStream memoryStream = new MemoryStream(); using ZLibStream zLibStream = new ZLibStream(memoryStream, CompressionLevel.Fastest, leaveOpen: true); byte[] rgba = frame.Rgba; for (int i = 0; i < frame.Height; i++) { int num = i * frame.Width * 4; byte b = 0; byte b2 = 0; byte b3 = 0; int num2 = 0; int num3 = 1; while (num2 < frame.Width) { array[num3] = (byte)(rgba[num] - b); array[num3 + 1] = (byte)(rgba[num + 1] - b2); array[num3 + 2] = (byte)(rgba[num + 2] - b3); b = rgba[num]; b2 = rgba[num + 1]; b3 = rgba[num + 2]; num2++; num += 4; num3 += 3; } zLibStream.Write(array); } return memoryStream; } private static void WriteChunk(Stream file, string type, ReadOnlySpan data) { Span span = stackalloc byte[4]; BinaryPrimitives.WriteInt32BigEndian(span, data.Length); file.Write(span); byte[] array = new byte[4]; for (int i = 0; i < 4; i++) { array[i] = (byte)type[i]; } file.Write(array); file.Write(data); uint crc = Crc(uint.MaxValue, array); crc = Crc(crc, data) ^ 0xFFFFFFFFu; BinaryPrimitives.WriteUInt32BigEndian(span, crc); file.Write(span); } private static uint Crc(uint crc, ReadOnlySpan bytes) { ReadOnlySpan readOnlySpan = bytes; for (int i = 0; i < readOnlySpan.Length; i++) { byte b = readOnlySpan[i]; crc = CrcTable[(crc ^ b) & 0xFF] ^ (crc >> 8); } return crc; } private static uint[] BuildCrcTable() { uint[] array = new uint[256]; for (uint num = 0u; num < 256; num++) { uint num2 = num; for (int i = 0; i < 8; i++) { num2 = (((num2 & 1) != 0) ? (0xEDB88320u ^ (num2 >> 1)) : (num2 >> 1)); } array[num] = num2; } return array; } } public interface ICameraPort { bool BrainEnabled { get; set; } CameraPose Pose { get; set; } float FieldOfView { get; } bool PhysicalLens { get; set; } void SetLens(RenderedLens lens); Vector3? SurfaceAt(Vector2 viewportPoint); float? CollisionDistance(Vector3 from, Vector3 to); } public interface ISubjectsPort { bool HudHidden { get; set; } Vector3 CharacterPosition { get; } bool IsHidden(Subject subject); void SetHidden(Subject subject, bool hidden); void HideNew(Subject subject); } public interface IInputPort { bool GameInputBlocked { get; set; } bool CursorFree { get; set; } } public interface IWorldPort { bool ClockFrozen { get; set; } float TimeScale { get; set; } bool SimulationPaused { get; set; } WeatherOverride? ForcedWeather { get; set; } float Snow { get; set; } float Wetness { get; set; } Season? SeasonPreset { get; set; } float? FoliageTint { get; set; } float TimeOfDay { get; set; } float Fog { get; set; } float Exposure { get; set; } bool InstantExposure { get; set; } } public interface ISessionInfoPort { bool IsSinglePlayer { get; } bool PhotoModeActive { get; set; } } public interface ISaveGatePort { bool SaveInProgress { get; } } public interface IFramePort { bool DynamicResolution { get; set; } Upscaler Upscaler { get; set; } AntiAliasing AntiAliasing { get; set; } Frame Grab(int multiplier); } public interface IEffectsPort { float? Get(LensEffect effect); void Set(LensEffect effect, float? value); } public interface IOutputPort { void WritePng(string fileName, byte[] png); void WriteSettings(string fileName, string text); void AddToSteam(string pngFile, int width, int height); } public static class RayMesh { private const float Epsilon = 1E-07f; public static float? Hit(Vector3 origin, Vector3 direction, Vector3 a, Vector3 b, Vector3 c) { Vector3 vector = b - a; Vector3 vector2 = c - a; Vector3 vector3 = Vector3.Cross(direction, vector2); float num = Vector3.Dot(vector, vector3); if (MathF.Abs(num) < 1E-07f) { return null; } float num2 = 1f / num; Vector3 vector4 = origin - a; float num3 = Vector3.Dot(vector4, vector3) * num2; if (num3 < 0f || num3 > 1f) { return null; } Vector3 vector5 = Vector3.Cross(vector4, vector); float num4 = Vector3.Dot(direction, vector5) * num2; if (num4 < 0f || num3 + num4 > 1f) { return null; } float num5 = Vector3.Dot(vector2, vector5) * num2; if (!(num5 > 1E-07f)) { return null; } return num5; } public static float? Nearest(Vector3 origin, Vector3 direction, IReadOnlyList vertices, IReadOnlyList triangles) { float? num = null; for (int i = 0; i + 2 < triangles.Count; i += 3) { float? num2 = Hit(origin, direction, vertices[triangles[i]], vertices[triangles[i + 1]], vertices[triangles[i + 2]]); if (num2 < (num ?? float.PositiveInfinity)) { num = num2; } } return num; } } public readonly record struct RenderedLens(float FocalLength, float Aperture, float FocusDistance, float SensorScale, bool DepthOfField); public enum Upscaler { None, Dlss, Fsr2 } public enum AntiAliasing { None, Fxaa, Taa, Smaa } internal sealed class RestoreLedger { private readonly List<(string Name, Action Undo)> _steps = new List<(string, Action)>(); public void Change(string name, Func read, Action write, T value) { T original = read(); _steps.Add((name, delegate { write(original); })); write(value); } public void Record(string name, Func read, Action write) { T original = read(); _steps.Add((name, delegate { write(original); })); } public IReadOnlyList UndoAll() { List list = new List(); for (int num = _steps.Count - 1; num >= 0; num--) { try { _steps[num].Undo(); } catch (Exception error) { list.Add(new RestoreFailure(_steps[num].Name, error)); } } _steps.Clear(); return list; } } public static class SceneRange { public const float HoursPerDay = 24f; public const float GameFog = 1f; public const float MaxFog = 16f; public const float MinExposure = -5f; public const float MaxExposure = 5f; } public enum Season { Winter, Spring, Summer, Autumn } public readonly record struct GuideRect(float X, float Y, float Width, float Height); public sealed class StoreShape { public static readonly StoreShape Title = new StoreShape("Title", 1920, 1080); public static readonly StoreShape Header = new StoreShape("Header", 1300, 372); public static readonly StoreShape Thumbnail = new StoreShape("Thumbnail", 256, 256); public static StoreShape[] All { get; } = new StoreShape[3] { Title, Header, Thumbnail }; public string Name { get; } public int Width { get; } public int Height { get; } private StoreShape(string name, int width, int height) { Name = name; Width = width; Height = height; } public GuideRect FitInside(int screenWidth, int screenHeight) { float num = Math.Min((float)screenWidth / (float)Width, (float)screenHeight / (float)Height); float num2 = (float)Width * num; float num3 = (float)Height * num; return new GuideRect(((float)screenWidth - num2) / 2f, ((float)screenHeight - num3) / 2f, num2, num3); } } public enum Subject { Player, Villagers, Creatures } public static class Subjects { public static readonly Subject[] All = new Subject[3] { Subject.Player, Subject.Villagers, Subject.Creatures }; } public enum WeatherPreset { Clear, Overcast, SpringClouds, AutumnClouds, Fog, HeavyRain, SkollThunderstorm, Blizzard } public readonly record struct WeatherOverride(WeatherPreset Preset, float Strength) { public float DebugProgress => Strength * 0.5f; private const float PeakProgress = 0.5f; } } namespace AskaShared.Game { public static class LocalPlayerTool { private sealed class Registration { public ManualLogSource Log; public string ObjectName; public Vector3 LocalPosition; public Type[] Components; } private const string WorldScene = "StreamingWorld"; private static readonly List Registrations = new List(); private static readonly HashSet SubscribedManagers = new HashSet(); private static bool _failureLogged; public static Character LocalCharacter { get; private set; } public static void Register(ManualLogSource log, string objectName, Vector3 localPosition, params Type[] components) { //IL_0070: 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) if (log == null) { throw new ArgumentNullException("log"); } if (string.IsNullOrEmpty(objectName)) { throw new ArgumentException("objectName is required and must be unique to this mod.", "objectName"); } if (Registrations.Count == 0) { SceneManager.sceneLoaded += DelegateSupport.ConvertDelegate>((Delegate)new Action(OnSceneLoaded)); } Registrations.Add(new Registration { Log = log, ObjectName = objectName, LocalPosition = localPosition, Components = (components ?? Array.Empty()) }); } private static void OnSceneLoaded(Scene scene, LoadSceneMode mode) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Expected O, but got Unknown try { PlayerManager manager = default(PlayerManager); if (!GameManagers.TryGet(ref manager) || (Object)(object)manager == (Object)null) { if (((Scene)(ref scene)).name == "StreamingWorld") { ManualLogSource log = Registrations[0].Log; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(97, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("No PlayerManager when the world scene '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("StreamingWorld"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' loaded; the player tools "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ObjectNames()); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" will not attach in this world."); } log.LogError(val); } } else if (SubscribedManagers.Add(((Object)manager).GetInstanceID())) { manager.OnPlayerSpawned.AddListener(DelegateSupport.ConvertDelegate((Delegate)(Action)delegate { OnPlayerSpawned(manager); })); } } catch (Exception ex) { LogFailureOnce(Registrations[0].Log, "subscribing to the player spawn event threw - the player tools " + ObjectNames() + " may not attach", ex); } } private static void OnPlayerSpawned(PlayerManager manager) { Character val; try { Player localPlayer = manager.LocalPlayer; val = (Character)(object)((localPlayer != null) ? localPlayer.playerCharacter : null); if ((Object)(object)val == (Object)null) { throw new InvalidOperationException("PlayerManager.OnPlayerSpawned fired with no local player character."); } LocalCharacter = val; } catch (Exception ex) { LogFailureOnce(Registrations[0].Log, "reading the local character threw - the player tools " + ObjectNames() + " did not attach", ex); return; } foreach (Registration registration in Registrations) { try { Attach(val, registration); } catch (Exception ex2) { LogFailureOnce(registration.Log, registration.ObjectName + ": attaching to the local player threw - it will do nothing in this world", ex2); } } } private static void Attach(Character character, Registration registration) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Expected O, but got Unknown Transform transform = ((Component)character).gameObject.transform; if (!((Object)(object)transform.Find(registration.ObjectName) != (Object)null)) { GameObject val = new GameObject(registration.ObjectName); val.transform.SetParent(transform, false); val.transform.localPosition = registration.LocalPosition; Type[] components = registration.Components; foreach (Type type in components) { val.AddComponent(Il2CppType.From(type)); } ManualLogSource log = registration.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(29, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(registration.ObjectName); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" attached to local player '"); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(((Object)((Component)character).gameObject).name); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("'."); } log.LogInfo(val2); } } private static void LogFailureOnce(ManualLogSource log, string message, Exception ex) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown if (!_failureLogged) { _failureLogged = true; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(29, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(message); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("; reported once per session: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex); } log.LogError(val); } } private static string ObjectNames() { string[] array = new string[Registrations.Count]; for (int i = 0; i < array.Length; i++) { array[i] = "'" + Registrations[i].ObjectName + "'"; } return string.Join(", ", array); } } public static class ModStrings { private const string FallbackLanguage = "english"; private static readonly Regex Placeholder = new Regex("\\{\\d+\\}"); private static ManualLogSource _log; private static string _prefix; private static Dictionary> _table; private static bool _loadFailed; private static readonly HashSet _warned = new HashSet(); public static void Init(ManualLogSource log, string logPrefix) { _log = log ?? throw new ArgumentNullException("log"); _prefix = logPrefix ?? throw new ArgumentNullException("logPrefix"); } public static string Get(string key) { return Lookup(key); } public static string Get(string key, params object[] args) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown string text = Lookup(key); if (args == null || args.Length == 0) { return text; } try { return string.Format(text, args); } catch (FormatException ex) { ManualLogSource log = _log; bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(27, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(_prefix); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(key); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' has a bad placeholder: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex.Message); } log.LogWarning(val); return text; } } private static string Lookup(string key) { if (_log == null) { throw new InvalidOperationException("ModStrings.Get was called before ModStrings.Init."); } Dictionary> dictionary = Table(); if (dictionary == null) { return key; } if (!dictionary.TryGetValue(key, out var value) || !value.TryGetValue("english", out var value2) || string.IsNullOrEmpty(value2)) { WarnOnce(key, "'" + key + "' has no english text; showing the key"); return key; } string text = CurrentLanguage(); if (value.TryGetValue(text, out var value3) && !string.IsNullOrEmpty(value3)) { return value3; } WarnOnce(key + "/" + text, $"'{key}' has no {text} text; showing english"); return value2; } private static string CurrentLanguage() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) LocalizationManager instance = LocalizationManager.Instance; if ((Object)(object)instance == (Object)null) { return "english"; } return Name(instance.SystemLanguage); } private unsafe static string Name(Language language) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Invalid comparison between Unknown and I4 if ((int)language != 1) { return ((object)(*(Language*)(&language))/*cast due to .constrained prefix*/).ToString(); } return "english"; } private static void WarnOnce(string id, string message) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown if (_warned.Add(id)) { ManualLogSource log = _log; bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(1, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(_prefix); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(message); } log.LogWarning(val); } } private static Dictionary> Table() { //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Expected O, but got Unknown if (_table != null || _loadFailed) { return _table; } Assembly executingAssembly = Assembly.GetExecutingAssembly(); string text = executingAssembly.GetName().Name + ".Strings.json"; try { using Stream stream = executingAssembly.GetManifestResourceStream(text); if (stream == null) { throw new InvalidOperationException("the embedded resource '" + text + "' is missing"); } using StreamReader streamReader = new StreamReader(stream); _table = JsonSerializer.Deserialize>>(streamReader.ReadToEnd()); } catch (Exception ex) { _loadFailed = true; ManualLogSource log = _log; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(65, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(_prefix); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" the string table could not be read, every string shows its key: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex); } log.LogError(val); } return _table; } } }