Decompiled source of FreeCameraAndWaterCollision v1.4.0
BepInEx/plugins/FreeCameraAndCollision/FreeCameraAndCollision.dll
Decompiled 2 days ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using Crest; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.Events; using UnityEngine.PostProcessing; using cakeslice; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")] [assembly: AssemblyCompany("FreeCameraAndCollision")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.4.0.0")] [assembly: AssemblyInformationalVersion("1.4.0")] [assembly: AssemblyProduct("FreeCameraAndCollision")] [assembly: AssemblyTitle("FreeCameraAndCollision")] [assembly: AssemblyVersion("1.4.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace FreeCameraAndCollision { [HarmonyPatch(typeof(BoatCamera), "Start")] internal static class BoatCameraStartPatch { [HarmonyPostfix] private static void Postfix(BoatCamera __instance) { FreeCameraAndCollisionPlugin.Instance?.AttachController(__instance); } } [HarmonyPatch(typeof(BoatCamera), "SwitchOff")] internal static class BoatCameraSwitchOffPatch { [HarmonyPrefix] private static void Prefix(BoatCamera __instance) { FreeCameraController.ExitIfOwnedBy(__instance); } } internal sealed class CameraConstraintResolver { private readonly FreeCameraAndCollisionPlugin plugin; private readonly Object queryContext; private readonly SampleHeightHelper waterHeightSampler = new SampleHeightHelper(); internal CameraConstraintResolver(FreeCameraAndCollisionPlugin ownerPlugin, Object owner) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown plugin = ownerPlugin; queryContext = owner; } internal Vector3 ConstrainFreeCameraPosition(Vector3 position, Vector3 focus, float maximumDistance) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0004: 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_000c: 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_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_002c: 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_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_0094: 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_00a0: Unknown result type (might be due to invalid IL or missing references) position = ClampToMaximumDistance(position, focus, maximumDistance); position = ApplyWaterCollision(position); Vector3 val = position - focus; float num = maximumDistance * maximumDistance; if (((Vector3)(ref val)).sqrMagnitude <= num) { return position; } float num2 = position.y - focus.y; if (Mathf.Abs(num2) >= maximumDistance) { return focus + Vector3.up * Mathf.Sign(num2) * maximumDistance; } Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(val.x, 0f, val.z); float num3 = Mathf.Sqrt(num - num2 * num2); if (((Vector3)(ref val2)).sqrMagnitude > num3 * num3) { val2 = ((Vector3)(ref val2)).normalized * num3; } return focus + val2 + Vector3.up * num2; } private Vector3 ClampToMaximumDistance(Vector3 position, Vector3 focus, float maximumDistance) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: 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_0014: Unknown result type (might be due to invalid IL or missing references) Vector3 val = position - focus; if (((Vector3)(ref val)).sqrMagnitude <= maximumDistance * maximumDistance) { return position; } return focus + ((Vector3)(ref val)).normalized * maximumDistance; } internal Vector3 ApplyWaterCollision(Vector3 position) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) if (!plugin.WaterCollision.Value || (Object)(object)OceanRenderer.Instance == (Object)null) { return position; } waterHeightSampler.Init(position, plugin.SphereRadius.Value * 2f, true, queryContext); float num = default(float); if (!waterHeightSampler.Sample(ref num)) { return position; } float num2 = num + plugin.SphereRadius.Value + plugin.SurfacePadding.Value; if (position.y < num2) { position.y = num2; } return position; } } internal static class CameraDistanceLimits { internal const float FreeCameraMaximumDistanceFromBoat = 320f; } internal sealed class DroneVelocityState { private const float VelocityTransitionTime = 2f; private const float SpeedMultiplierTransitionTime = 1f; private const float OppositeInputDecelerationTime = 1f; private const float MovementInputEpsilonSquared = 0.0001f; private const float CollisionCorrectionEpsilonSquared = 1E-06f; private float currentSpeedMultiplier = 1f; private float speedMultiplierTransitionStart = 1f; private float speedMultiplierTransitionTarget = 1f; private float speedMultiplierTransitionElapsed; private bool movementInputWasActive; private float stoppingVelocityChangeRate; internal Vector3 LocalVelocity { get; private set; } internal void Reset(float initialSpeedMultiplier) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) LocalVelocity = Vector3.zero; currentSpeedMultiplier = initialSpeedMultiplier; speedMultiplierTransitionStart = initialSpeedMultiplier; speedMultiplierTransitionTarget = initialSpeedMultiplier; speedMultiplierTransitionElapsed = 1f; movementInputWasActive = false; stoppingVelocityChangeRate = 0f; } internal Vector3 Update(Vector3 localInput, float baseSpeed, float requestedSpeedMultiplier, float deltaTime) { //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_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_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: 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_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) bool flag = UpdateSpeedMultiplier(requestedSpeedMultiplier, deltaTime); if (((Vector3)(ref localInput)).sqrMagnitude > 1f) { ((Vector3)(ref localInput)).Normalize(); } bool flag2 = ((Vector3)(ref localInput)).sqrMagnitude >= 0.0001f; if (!flag2) { localInput = Vector3.zero; if (movementInputWasActive) { Vector3 localVelocity = LocalVelocity; stoppingVelocityChangeRate = ((Vector3)(ref localVelocity)).magnitude / 2f; } } Vector3 val = localInput * baseSpeed * currentSpeedMultiplier; if (flag2) { float num = Mathf.Max(currentSpeedMultiplier, requestedSpeedMultiplier); if (Vector3.Dot(LocalVelocity, val) < 0f) { float num2 = baseSpeed * num / 1f; LocalVelocity = Vector3.MoveTowards(LocalVelocity, Vector3.zero, num2 * deltaTime); } else { float num3 = baseSpeed * num / 2f; if (flag) { float num4 = baseSpeed * Mathf.Abs(speedMultiplierTransitionTarget - speedMultiplierTransitionStart) / 1f; num3 = Mathf.Max(num3, num4); } LocalVelocity = Vector3.MoveTowards(LocalVelocity, val, num3 * deltaTime); } } else { LocalVelocity = Vector3.MoveTowards(LocalVelocity, val, stoppingVelocityChangeRate * deltaTime); } movementInputWasActive = flag2; return LocalVelocity; } internal void RemoveBlockedComponent(Quaternion cameraRotation, Vector3 constraintCorrection) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: 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_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0044: 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_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) if (!(((Vector3)(ref constraintCorrection)).sqrMagnitude < 1E-06f)) { Vector3 normalized = ((Vector3)(ref constraintCorrection)).normalized; Vector3 val = cameraRotation * LocalVelocity; float num = Vector3.Dot(val, normalized); if (!(num >= 0f)) { val -= normalized * num; LocalVelocity = Quaternion.Inverse(cameraRotation) * val; } } } private bool UpdateSpeedMultiplier(float requestedSpeedMultiplier, float deltaTime) { if (!Mathf.Approximately(requestedSpeedMultiplier, speedMultiplierTransitionTarget)) { speedMultiplierTransitionStart = currentSpeedMultiplier; speedMultiplierTransitionTarget = requestedSpeedMultiplier; speedMultiplierTransitionElapsed = 0f; } if (speedMultiplierTransitionElapsed >= 1f) { currentSpeedMultiplier = speedMultiplierTransitionTarget; return false; } speedMultiplierTransitionElapsed = Mathf.Min(speedMultiplierTransitionElapsed + deltaTime, 1f); currentSpeedMultiplier = Mathf.Lerp(speedMultiplierTransitionStart, speedMultiplierTransitionTarget, speedMultiplierTransitionElapsed / 1f); return true; } } [DefaultExecutionOrder(10000)] internal sealed class FreeCameraController : MonoBehaviour { private const KeyCode DefaultToggleKey = (KeyCode)98; private const KeyCode AlternativeToggleKey = (KeyCode)112; private const KeyCode FollowShipToggleKey = (KeyCode)104; private const KeyCode ControllerToggleKey = (KeyCode)338; private const KeyCode ControllerDescendKey = (KeyCode)334; private const KeyCode ControllerRiseKey = (KeyCode)335; private const float SpeedBoostMultiplier = 2f; private const float PrecisionSpeedMultiplier = 0.5f; private const float MinimumZoom = 20f; private const float MouseZoomSpeed = 30f; private const float ControllerZoomSpeed = 35f; private const float ZoomResponseSpeed = 100f; private const float WorldShiftDistanceThreshold = 20f; private const string PrimaryHorizontalAxis = "Oculus_CrossPlatform_PrimaryThumbstickHorizontal"; private const string PrimaryVerticalAxis = "Oculus_CrossPlatform_PrimaryThumbstickVertical"; private const string SecondaryHorizontalAxis = "Oculus_CrossPlatform_SecondaryThumbstickHorizontal"; private const string SecondaryVerticalAxis = "Oculus_CrossPlatform_SecondaryThumbstickVertical"; private const string PrimaryTriggerAxis = "Oculus_CrossPlatform_PrimaryIndexTrigger"; private const string SecondaryTriggerAxis = "Oculus_CrossPlatform_SecondaryIndexTrigger"; private const string MouseHorizontalAxis = "Mouse X"; private const string MouseVerticalAxis = "Mouse Y"; private const string MouseScrollAxis = "Mouse ScrollWheel"; private static readonly FieldInfo CenterEyeField = AccessTools.Field(typeof(BoatCamera), "centerEye"); private static readonly FieldInfo PlayerLooksField = AccessTools.Field(typeof(BoatCamera), "playerLooks"); private static readonly FieldInfo BoatLooksField = AccessTools.Field(typeof(BoatCamera), "boatLooks"); private BoatCamera boatCamera; private FreeCameraAndCollisionPlugin plugin; private CameraConstraintResolver constraintResolver; private Transform centerEye; private Camera unityCamera; private MouseLook[] playerLooks; private MouseLook[] boatLooks; private bool[] savedBoatLookStates; private readonly FreeCameraRotationState rotationState = new FreeCameraRotationState(); private readonly DroneVelocityState droneVelocityState = new DroneVelocityState(); private bool initialized; private bool freeCameraActive; private Transform followedBoat; private Transform anchor; private bool followShipTranslation; private Vector3 lastAnchorPosition; private Vector3 freeCameraPosition; private float lookSensitivityX = 2f; private float lookSensitivityY = 2f; private float minimumLookY = -80f; private float maximumLookY = 80f; private Vector3 savedCenterEyeLocalPosition; private Quaternion savedCenterEyeLocalRotation; private float savedFieldOfView; private float targetFieldOfView; private OVRPlayerController playerController; private bool savedPlayerControllerEnabled; internal static FreeCameraController ActiveController { get; private set; } internal static bool IsFreeCameraOn { get { if ((Object)(object)ActiveController != (Object)null) { return ActiveController.freeCameraActive; } return false; } } internal static bool IsInputCaptured { get { if (!PhotoMode.IsOpen) { if ((Object)(object)ActiveController != (Object)null) { return ActiveController.freeCameraActive; } return false; } return true; } } internal Transform CenterEye => centerEye; internal Camera UnityCamera => unityCamera; internal float MaximumZoom => savedFieldOfView; internal void SetZoom(float fieldOfView) { targetFieldOfView = Mathf.Clamp(fieldOfView, 20f, savedFieldOfView); } internal void Initialize(BoatCamera owner, FreeCameraAndCollisionPlugin ownerPlugin) { if (initialized && (Object)(object)boatCamera == (Object)(object)owner && (Object)(object)plugin == (Object)(object)ownerPlugin) { return; } boatCamera = owner; plugin = ownerPlugin; ref Transform reference = ref centerEye; object? obj = CenterEyeField?.GetValue(owner); reference = (Transform)((obj is Transform) ? obj : null); playerLooks = PlayerLooksField?.GetValue(owner) as MouseLook[]; boatLooks = BoatLooksField?.GetValue(owner) as MouseLook[]; if ((Object)(object)centerEye == (Object)null) { ownerPlugin.LogInitializationError("Free camera could not initialize: BoatCamera.centerEye was not found."); ((Behaviour)this).enabled = false; return; } unityCamera = ((Component)centerEye).GetComponent<Camera>(); if ((Object)(object)unityCamera == (Object)null) { unityCamera = ((Component)centerEye).GetComponentInChildren<Camera>(); } if ((Object)(object)unityCamera == (Object)null) { unityCamera = Camera.main; } constraintResolver = new CameraConstraintResolver(ownerPlugin, (Object)(object)this); CacheVanillaFirstPersonLookSettings(); initialized = true; } internal static void ExitActiveCamera() { ActiveController?.ExitFreeCamera(); } internal static void ExitIfOwnedBy(BoatCamera owner) { if ((Object)(object)ActiveController != (Object)null && (Object)(object)ActiveController.boatCamera == (Object)(object)owner) { ActiveController.ExitFreeCamera(); } } private void Update() { if (!initialized) { return; } bool flag = Input.GetKeyDown((KeyCode)(plugin.SwapBToP.Value ? 112 : 98)) || (GameInput.controllerEnabled && Input.GetKeyDown((KeyCode)338)); if (!freeCameraActive) { if (flag && CanEnterFreeCamera()) { EnterFreeCamera(); } } else if (flag || !CanRemainActive()) { ExitFreeCamera(); } else { UpdateFreeCameraInput(); } } private void LateUpdate() { //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) if (initialized) { if (freeCameraActive) { centerEye.SetPositionAndRotation(freeCameraPosition, rotationState.Rotation); } else if (BoatCamera.on && (Object)(object)GameState.currentBoat != (Object)null) { ApplyThirdPersonWaterConstraint(); } } } private void HoldPoseBeforeRender() { //IL_0006: 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) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) if (centerEye.position != freeCameraPosition || centerEye.rotation != rotationState.Rotation) { centerEye.SetPositionAndRotation(freeCameraPosition, rotationState.Rotation); } } private void OnDisable() { if (freeCameraActive) { ExitFreeCamera(); } } private void OnDestroy() { if (freeCameraActive) { ExitFreeCamera(); } } private bool CanEnterFreeCamera() { if (PhotoMode.IsOpen || IsFreeCameraContextAvailable()) { return (Object)(object)CurrentAnchor() != (Object)null; } return false; } private bool CanRemainActive() { if ((PhotoMode.IsOpen || IsFreeCameraContextAvailable()) && (Object)(object)anchor != (Object)null) { return (Object)(object)GameState.currentBoat == (Object)(object)followedBoat; } return false; } private static bool IsFreeCameraContextAvailable() { if (BoatCamera.on && GameState.playing && !GameState.currentlyLoading && (Object)(object)GameState.currentShipyard == (Object)null && !GameState.inCursorMenu) { return !GameState.VREnabled; } return false; } private static Transform CurrentAnchor() { if ((Object)(object)GameState.currentBoat != (Object)null) { return GameState.currentBoat; } if (!((Object)(object)Refs.observerMirror != (Object)null)) { return null; } return ((Component)Refs.observerMirror).transform; } private void EnterFreeCamera() { //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0059: 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_006f: 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_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Expected O, but got Unknown //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Expected O, but got Unknown if ((Object)(object)ActiveController != (Object)null && (Object)(object)ActiveController != (Object)(object)this) { ActiveController.ExitFreeCamera(); } followedBoat = GameState.currentBoat; anchor = CurrentAnchor(); followShipTranslation = true; lastAnchorPosition = anchor.position; freeCameraPosition = centerEye.position; rotationState.Initialize(centerEye.rotation, plugin.MovementMode.Value, minimumLookY, maximumLookY); droneVelocityState.Reset(GetMovementSpeedMultiplier()); savedCenterEyeLocalPosition = centerEye.localPosition; savedCenterEyeLocalRotation = centerEye.localRotation; if ((Object)(object)unityCamera != (Object)null) { savedFieldOfView = unityCamera.fieldOfView; targetFieldOfView = savedFieldOfView; } SaveAndDisableBoatLook(); SaveAndDisablePlayerMovement(); ActiveController = this; freeCameraActive = true; Application.onBeforeRender -= new UnityAction(HoldPoseBeforeRender); Application.onBeforeRender += new UnityAction(HoldPoseBeforeRender); } private void ExitFreeCamera() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown //IL_0036: 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) if (freeCameraActive) { freeCameraActive = false; Application.onBeforeRender -= new UnityAction(HoldPoseBeforeRender); if ((Object)(object)centerEye != (Object)null) { centerEye.localPosition = savedCenterEyeLocalPosition; centerEye.localRotation = savedCenterEyeLocalRotation; } if ((Object)(object)unityCamera != (Object)null) { unityCamera.fieldOfView = savedFieldOfView; } RestoreBoatLook(); RestorePlayerMovement(); followedBoat = null; anchor = null; droneVelocityState.Reset(1f); if ((Object)(object)ActiveController == (Object)(object)this) { ActiveController = null; } } } private void UpdateFreeCameraInput() { float deltaTime = Mathf.Min(Time.unscaledDeltaTime, 0.05f); if (Input.GetKeyDown((KeyCode)104)) { followShipTranslation = !followShipTranslation; } if (rotationState.SetMode(plugin.MovementMode.Value)) { droneVelocityState.Reset(GetMovementSpeedMultiplier()); } UpdateFreeCameraLook(deltaTime); UpdateFreeCameraMovement(deltaTime); UpdateFreeCameraZoom(deltaTime); } private void UpdateFreeCameraLook(float deltaTime) { float num = 0f; float num2 = 0f; if (GameInput.controllerEnabled) { num = Input.GetAxis("Oculus_CrossPlatform_SecondaryThumbstickHorizontal"); num2 = Input.GetAxis("Oculus_CrossPlatform_SecondaryThumbstickVertical"); } float num3 = 0f; float num4 = 0f; if (!PhotoMode.IsPanelShown || Input.GetMouseButton(1)) { num3 = Input.GetAxis("Mouse X"); num4 = Input.GetAxis("Mouse Y"); } if (num != 0f || num2 != 0f) { GameState.lookingWithController = true; } if (num3 != 0f || num4 != 0f) { GameState.lookingWithController = false; } float num5 = (float)Settings.mouseSens / 5f + 0.1f; float yawDelta = (num + num3) * lookSensitivityX * num5; float keyboardAxis = GetKeyboardAxis((KeyCode)113, (KeyCode)101); rotationState.UpdateLook(yawDelta, num4 * lookSensitivityY * num5, num2 * lookSensitivityY * num5, plugin.InvertDroneMousePitch.Value, keyboardAxis, plugin.CameraRollingSpeed.Value, Input.GetKeyDown((KeyCode)114), deltaTime); } private void UpdateFreeCameraMovement(float deltaTime) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: 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) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_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_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0148: 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) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0184: 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_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: 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_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Unknown result type (might be due to invalid IL or missing references) Vector3 position = anchor.position; Vector3 val = position - lastAnchorPosition; lastAnchorPosition = position; if (((Vector3)(ref val)).sqrMagnitude > 400f) { freeCameraPosition += val; val = Vector3.zero; } else if (!followShipTranslation) { val = Vector3.zero; } float num = GetKeyboardAxis((KeyCode)119, (KeyCode)115); float num2 = GetKeyboardAxis((KeyCode)100, (KeyCode)97); float num3 = GetKeyboardAxis((KeyCode)32, (KeyCode)306); if (Input.GetKey((KeyCode)305)) { num3 -= 1f; } if (GameInput.controllerEnabled) { num += Input.GetAxis("Oculus_CrossPlatform_PrimaryThumbstickVertical"); num2 += Input.GetAxis("Oculus_CrossPlatform_PrimaryThumbstickHorizontal"); if (Input.GetKey((KeyCode)335)) { num3 += 1f; } if (Input.GetKey((KeyCode)334)) { num3 -= 1f; } } float movementSpeedMultiplier = GetMovementSpeedMultiplier(); Vector3 val3; if (rotationState.Mode == FreeCameraMovementMode.Drone) { Vector3 localInput = default(Vector3); ((Vector3)(ref localInput))..ctor(num2, num3, num); Vector3 val2 = droneVelocityState.Update(localInput, plugin.CameraSpeed.Value, movementSpeedMultiplier, deltaTime); val3 = rotationState.Rotation * val2 * deltaTime; } else { Quaternion movementRotation = rotationState.MovementRotation; Vector3 val4 = movementRotation * Vector3.forward * num + movementRotation * Vector3.right * num2 + Vector3.up * num3; if (((Vector3)(ref val4)).sqrMagnitude > 1f) { ((Vector3)(ref val4)).Normalize(); } val3 = val4 * (float)plugin.CameraSpeed.Value * movementSpeedMultiplier * deltaTime; } Vector3 focus = position; Vector3 val5 = freeCameraPosition + val + val3; Vector3 val6 = constraintResolver.ConstrainFreeCameraPosition(val5, focus, 320f); if (rotationState.Mode == FreeCameraMovementMode.Drone) { droneVelocityState.RemoveBlockedComponent(rotationState.Rotation, val6 - val5); } freeCameraPosition = val6; } private static float GetMovementSpeedMultiplier() { float num = 1f; if (Input.GetKey((KeyCode)304) || Input.GetKey((KeyCode)303)) { num *= 2f; } if (Input.GetKey((KeyCode)308) || Input.GetKey((KeyCode)307)) { num *= 0.5f; } return num; } private void UpdateFreeCameraZoom(float deltaTime) { if (!((Object)(object)unityCamera == (Object)null)) { float num = (PhotoMode.IsMouseOverPanel ? 0f : Input.GetAxis("Mouse ScrollWheel")); float num2 = 0f; if (GameInput.controllerEnabled) { num2 = Input.GetAxis("Oculus_CrossPlatform_SecondaryIndexTrigger") - Input.GetAxis("Oculus_CrossPlatform_PrimaryIndexTrigger"); } targetFieldOfView -= num * 30f; targetFieldOfView -= num2 * 35f * deltaTime; targetFieldOfView = Mathf.Clamp(targetFieldOfView, 20f, savedFieldOfView); float fieldOfView = unityCamera.fieldOfView; if (fieldOfView != targetFieldOfView) { unityCamera.fieldOfView = Mathf.MoveTowards(fieldOfView, targetFieldOfView, 100f * deltaTime); } } } private void ApplyThirdPersonWaterConstraint() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: 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_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: 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) Vector3 position = centerEye.position; Vector3 val = constraintResolver.ApplyWaterCollision(position); if (val.y != position.y) { centerEye.position = val; } } private void CacheVanillaFirstPersonLookSettings() { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Invalid comparison between Unknown and I4 //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Invalid comparison between Unknown and I4 //IL_0046: Unknown result type (might be due to invalid IL or missing references) if (playerLooks == null) { return; } for (int i = 0; i < playerLooks.Length; i++) { MouseLook val = playerLooks[i]; if (!((Object)(object)val == (Object)null)) { if ((int)val.axes == 1 || (int)val.axes == 0) { lookSensitivityX = val.sensitivityX; } if ((int)val.axes == 2 || (int)val.axes == 0) { lookSensitivityY = val.sensitivityY; minimumLookY = val.minimumY; maximumLookY = val.maximumY; } } } } private void SaveAndDisableBoatLook() { if (boatLooks == null) { savedBoatLookStates = null; return; } savedBoatLookStates = new bool[boatLooks.Length]; for (int i = 0; i < boatLooks.Length; i++) { MouseLook val = boatLooks[i]; if (!((Object)(object)val == (Object)null)) { savedBoatLookStates[i] = ((Behaviour)val).enabled; ((Behaviour)val).enabled = false; } } } private void RestoreBoatLook() { if (boatLooks == null || savedBoatLookStates == null) { return; } int num = Mathf.Min(boatLooks.Length, savedBoatLookStates.Length); for (int i = 0; i < num; i++) { if ((Object)(object)boatLooks[i] != (Object)null) { ((Behaviour)boatLooks[i]).enabled = savedBoatLookStates[i]; } } savedBoatLookStates = null; } private void SaveAndDisablePlayerMovement() { playerController = Refs.ovrController; if (!((Object)(object)playerController == (Object)null)) { savedPlayerControllerEnabled = ((Behaviour)playerController).enabled; playerController.Stop(); ((Behaviour)playerController).enabled = false; } } private void RestorePlayerMovement() { if ((Object)(object)playerController != (Object)null) { ((Behaviour)playerController).enabled = savedPlayerControllerEnabled; } playerController = null; } private static float GetKeyboardAxis(KeyCode positive, KeyCode negative) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) float num = 0f; if (Input.GetKey(positive)) { num += 1f; } if (Input.GetKey(negative)) { num -= 1f; } return num; } } internal enum FreeCameraMovementMode { World, Drone } internal sealed class FreeCameraRotationState { private const float RollReferenceEpsilonSquared = 0.0001f; private const float RollResetSpeedDegreesPerSecond = 120f; private float minimumPitch; private float maximumPitch; private float worldYaw; private float worldPitch; private float worldRoll; private bool rollResetActive; internal Quaternion Rotation { get; private set; } internal FreeCameraMovementMode Mode { get; private set; } internal Quaternion MovementRotation { get { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) if (Mode != FreeCameraMovementMode.Drone) { return Quaternion.Euler(0f - worldPitch, worldYaw, 0f); } return Rotation; } } internal void Initialize(Quaternion initialRotation, FreeCameraMovementMode mode, float minimumWorldPitch, float maximumWorldPitch) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) Rotation = initialRotation; Mode = mode; minimumPitch = minimumWorldPitch; maximumPitch = maximumWorldPitch; rollResetActive = false; UpdateWorldAnglesFromRotation(); } internal bool SetMode(FreeCameraMovementMode mode) { if (mode == Mode) { return false; } Mode = mode; if (Mode == FreeCameraMovementMode.World) { UpdateWorldAnglesFromRotation(); } return true; } internal void UpdateLook(float yawDelta, float mousePitchDelta, float controllerPitchDelta, bool invertDroneMousePitch, float rollInput, float rollingSpeed, bool resetRollPressed, float deltaTime) { float num = ((Mode == FreeCameraMovementMode.Drone && invertDroneMousePitch) ? (-1f) : 1f); float pitchDelta = controllerPitchDelta + mousePitchDelta * num; float rollDelta = rollInput * rollingSpeed * deltaTime; if (rollInput != 0f) { rollResetActive = false; } else if (resetRollPressed) { rollResetActive = true; } if (Mode == FreeCameraMovementMode.Drone) { UpdateDroneRotation(yawDelta, pitchDelta, rollDelta, deltaTime); } else { UpdateWorldRotation(yawDelta, pitchDelta, rollDelta, deltaTime); } } private void UpdateWorldRotation(float yawDelta, float pitchDelta, float rollDelta, float deltaTime) { //IL_0095: Unknown result type (might be due to invalid IL or missing references) worldYaw = NormalizeAngle(worldYaw + yawDelta); worldPitch = Mathf.Clamp(worldPitch + pitchDelta, minimumPitch, maximumPitch); if (rollResetActive) { worldRoll = Mathf.MoveTowardsAngle(worldRoll, 0f, 120f * deltaTime); if (worldRoll == 0f) { rollResetActive = false; } } else { worldRoll = NormalizeAngle(worldRoll + rollDelta); } Rotation = Quaternion.Euler(0f - worldPitch, worldYaw, worldRoll); } private void UpdateDroneRotation(float yawDelta, float pitchDelta, float rollDelta, float deltaTime) { //IL_0004: 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_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_001a: Unknown result type (might be due to invalid IL or missing references) Quaternion val = Quaternion.Euler(0f - pitchDelta, yawDelta, rollDelta); Quaternion val2 = Rotation * val; Rotation = ((Quaternion)(ref val2)).normalized; if (rollResetActive) { UpdateDroneRollReset(deltaTime); } } private void UpdateWorldAnglesFromRotation() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: 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_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) Quaternion rotation = Rotation; Vector3 eulerAngles = ((Quaternion)(ref rotation)).eulerAngles; worldYaw = NormalizeAngle(eulerAngles.y); worldPitch = Mathf.Clamp(0f - NormalizeAngle(eulerAngles.x), minimumPitch, maximumPitch); worldRoll = NormalizeAngle(eulerAngles.z); } private void UpdateDroneRollReset(float deltaTime) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0028: 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_003c: 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) //IL_0042: 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_005e: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: 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_009d: Unknown result type (might be due to invalid IL or missing references) Vector3 val = Rotation * Vector3.forward; Vector3 val2 = Rotation * Vector3.up; Vector3 val3 = Vector3.ProjectOnPlane(Vector3.up, val); if (((Vector3)(ref val3)).sqrMagnitude < 0.0001f) { val3 = Vector3.ProjectOnPlane(Vector3.forward, val); } if (!(((Vector3)(ref val3)).sqrMagnitude < 0.0001f)) { ((Vector3)(ref val3)).Normalize(); float num = Vector3.SignedAngle(val3, val2, val); float num2 = Mathf.MoveTowardsAngle(num, 0f, 120f * deltaTime); float num3 = Mathf.DeltaAngle(num, num2); Quaternion val4 = Rotation * Quaternion.AngleAxis(num3, Vector3.forward); Rotation = ((Quaternion)(ref val4)).normalized; if (num2 == 0f) { rollResetActive = false; } } } private static float NormalizeAngle(float angle) { while (angle > 180f) { angle -= 360f; } while (angle < -180f) { angle += 360f; } return angle; } } internal static class GameInputSuppression { internal static bool AllowOriginalOrNeutralize(ref bool result) { if (!FreeCameraController.IsInputCaptured) { return true; } result = false; return false; } internal static bool AllowOriginalOrNeutralize(ref float result) { if (!FreeCameraController.IsInputCaptured) { return true; } result = 0f; return false; } } [HarmonyPatch(typeof(GameInput), "GetKey")] internal static class GameInputGetKeyPatch { [HarmonyPrefix] [HarmonyPriority(0)] private static bool Prefix(ref bool __result) { return GameInputSuppression.AllowOriginalOrNeutralize(ref __result); } } [HarmonyPatch(typeof(GameInput), "GetKeyDown")] internal static class GameInputGetKeyDownPatch { [HarmonyPrefix] [HarmonyPriority(0)] private static bool Prefix(ref bool __result) { return GameInputSuppression.AllowOriginalOrNeutralize(ref __result); } } [HarmonyPatch(typeof(GameInput), "GetKeyUp")] internal static class GameInputGetKeyUpPatch { [HarmonyPrefix] [HarmonyPriority(0)] private static bool Prefix(ref bool __result) { return GameInputSuppression.AllowOriginalOrNeutralize(ref __result); } } [HarmonyPatch(typeof(GameInput), "GetScrollAxis")] internal static class GameInputGetScrollAxisPatch { [HarmonyPrefix] [HarmonyPriority(0)] private static bool Prefix(ref float __result) { return GameInputSuppression.AllowOriginalOrNeutralize(ref __result); } } [HarmonyPatch(typeof(GameInput), "GetPrimaryHorizontal")] internal static class GameInputGetPrimaryHorizontalPatch { [HarmonyPrefix] [HarmonyPriority(0)] private static bool Prefix(ref float __result) { return GameInputSuppression.AllowOriginalOrNeutralize(ref __result); } } [HarmonyPatch(typeof(GameInput), "GetPrimaryVertical")] internal static class GameInputGetPrimaryVerticalPatch { [HarmonyPrefix] [HarmonyPriority(0)] private static bool Prefix(ref float __result) { return GameInputSuppression.AllowOriginalOrNeutralize(ref __result); } } [HarmonyPatch(typeof(GameInput), "GetSecondaryHorizontal")] internal static class GameInputGetSecondaryHorizontalPatch { [HarmonyPrefix] [HarmonyPriority(0)] private static bool Prefix(ref float __result) { return GameInputSuppression.AllowOriginalOrNeutralize(ref __result); } } [HarmonyPatch(typeof(GameInput), "GetSecondaryVertical")] internal static class GameInputGetSecondaryVerticalPatch { [HarmonyPrefix] [HarmonyPriority(0)] private static bool Prefix(ref float __result) { return GameInputSuppression.AllowOriginalOrNeutralize(ref __result); } } [DefaultExecutionOrder(10001)] internal sealed class PhotoMode : MonoBehaviour { private struct Setting { public bool Set; public float Value; } private enum SliderId { Time, FieldOfView, FocusDistance, Aperture, Exposure, Contrast, Saturation, Temperature, Tint, BloomIntensity, BloomThreshold, Vignette, VignetteSoftness, FilmGrain, GrainSize, ChromaticAberration, Fog, VolumetricFog } private enum Part { HideUi, Leave, Weather, DepthOfField, HideBody, Grid, ResetAll, Slider, Reset } private struct Hit { public Rect Area; public Part Part; public int Index; public Outline Outline; } private sealed class SliderRow { public SliderId Id; public TextMesh Label; public TextMesh Bars; public TextMesh Value; public Renderer ResetPlate; public TextMesh ResetArrow; public float BarsLeft; public float BarsWidth; public float ShownValue; public float ShownFraction; public int State; } private sealed class PanelParts { public Transform Page; public Transform Paper; public Transform Plate; public Transform PlateText; public Transform Mark; public Transform Label; public Transform Heading; public Transform Value; public Transform Strip; public Transform Bars; public Transform Arrow; public float MarkOffset; public float BarsInset; } private const string PlayerModelGuid = "com.diamondminer99.playermodel"; private const string PlayerModelEntryId = "freecam_photomode"; private const string GameMenuButtonName = "freecam photo mode button"; private static readonly FieldInfo SettingsUiField = AccessTools.Field(typeof(StartMenu), "settingsUI"); private static readonly FieldInfo LogoField = AccessTools.Field(typeof(StartMenu), "logo"); private static readonly MethodInfo EnableSettingsMenuMethod = AccessTools.Method(typeof(StartMenu), "EnableSettingsMenu", (Type[])null, (Type[])null); private static readonly MethodInfo DisableSettingsMenuMethod = AccessTools.Method(typeof(StartMenu), "DisableSettingsMenu", (Type[])null, (Type[])null); private static readonly FieldInfo WeatherLerpField = AccessTools.Field(typeof(Weather), "lerp"); private static readonly FieldInfo[] WeatherParticleFields = new FieldInfo[5] { AccessTools.Field(typeof(Weather), "upperClouds"), AccessTools.Field(typeof(Weather), "lowerClouds"), AccessTools.Field(typeof(Weather), "rain"), AccessTools.Field(typeof(Weather), "outerRain"), AccessTools.Field(typeof(Weather), "rainSplash") }; private static MethodInfo playerModelMenuHide; private static MethodInfo playerModelMenuReopen; private static MethodInfo playerModelForceVisible; private static PropertyInfo playerModelBody; private static PhotoMode instance; private static int closedFrame = -1; private FreeCameraController controller; private FreeCameraAndCollisionPlugin plugin; private StartMenu menu; private GameObject settingsUi; private GameObject logo; private MouseButtonPointer menuPointer; private bool settingsUiWasShown; private bool logoWasShown; private bool menuPointerWasEnabled; private Sun sun; private Light sunLight; private SunlightNightIntensity sunlightIntensity; private float savedGlobalTime; private float savedSunIntensity; private float localTimeOffset; private Weather weather; private WeatherSet savedWeatherTarget; private float savedWeatherLerp; private readonly float[] savedFog = new float[8]; private float savedDayFogMult; private float savedNightFogMult; private ParticleSystem[] weatherParticles; private bool[] savedParticleUnscaled; private bool weatherFogDirty; private PostProcessingBehaviour postProcessing; private PostProcessingProfile originalProfile; private PostProcessingProfile photoProfile; private float savedFieldOfView; private Camera uiCamera; private int savedUiCullingMask; private Renderer[] hudRenderers; private bool[] savedHudRendererStates; private bool hudHidden; private bool uiHidden; private GameObject playerBody; private bool bodyHidden; private bool bodyForcedVisible; private const float MinimumFieldOfView = 20f; private const float MinimumFocusDistance = 0.1f; private const float MaximumFocusDistance = 300f; private const string Hint = "B: free camera, look with the right mouse button held\nHide UI: ESC shows the panel again. ESC: leave"; private static readonly string[] WeatherNames = new string[4] { "Clear", "Cloudy", "Rain", "Storm" }; private static readonly Vector3 GameMenuButtonPosition = new Vector3(2.3f, -1.03f, -0.13f); private const float PanelWidth = 2.84f; private const float Padding = 0.14f; private const float RowHeight = 0.16f; private const float HeadingHeight = 0.2f; private const float ButtonRowHeight = 0.22f; private const float ButtonHeight = 0.15f; private const float Gap = 0.05f; private const float StripHeight = 0.13f; private const float BoxWidth = 0.15f; private const float BoxHeight = 0.13f; private const float LabelRight = 1.3f; private const float StripLeft = 1.38f; private const float StripWidth = 0.74f; private const float ValueRight = 2.5f; private const float ResetCentre = 2.625f; private const float HintHeight = 0.26f; private const float PaperMargin = 0.08f; private const float PaperDepth = 0.16f; private const float TextDepth = -0.01f; private const float SmallText = 0.85f; private const int BarCount = 20; private const float PanelDistance = 3f; private const float PanelScale = 0.72f; private const float ScreenMargin = 0.04f; private static readonly Color PaperEmission = new Color(0.85f, 0.85f, 0.85f, 1f); private const float DimAlpha = 0.35f; private Setting time; private Setting fieldOfView; private Setting exposure; private Setting contrast; private Setting saturation; private Setting temperature; private Setting tint; private Setting bloomIntensity; private Setting bloomThreshold; private Setting vignetteIntensity; private Setting vignetteSmoothness; private Setting grainIntensity; private Setting grainSize; private Setting chromaticAberration; private Setting fogDensity; private Setting volumetricFog; private int weatherPreset; private bool depthOfField; private float focusDistance; private float aperture; private bool showGrid; private bool mouseOverPanel; private Transform panelRoot; private float panelHeight; private Rect paperArea; private readonly List<Hit> hits = new List<Hit>(); private SliderRow[] sliderRows; private Renderer[] weatherPlates; private TextMesh depthOfFieldMark; private TextMesh hideBodyMark; private TextMesh gridMark; private TextMesh hideBodyLabel; private Renderer hideBodyPlate; private Material plateOn; private Material plateOff; private Color ink; private Color barColour; private Color plateInk; private readonly string[] barTexts = new string[21]; private int hovered = -1; private SliderRow dragged; private int shownPreset; private int shownChecks; private int layoutWidth; private int layoutHeight; internal static bool IsOpen { get; private set; } internal static bool ClaimsPauseKey { get { if (!IsOpen) { return closedFrame == Time.frameCount; } return true; } } internal static bool IsPanelShown { get { if (IsOpen && (Object)(object)instance != (Object)null) { return !instance.uiHidden; } return false; } } internal static bool IsMouseOverPanel { get { if (IsPanelShown) { return instance.mouseOverPanel; } return false; } } internal static bool UsesPlayerModelMenu => playerModelMenuHide != null; private float FieldOfViewMaximum { get { if (!FreeCameraController.IsFreeCameraOn) { return savedFieldOfView; } return controller.MaximumZoom; } } internal void Initialize(FreeCameraController owner, FreeCameraAndCollisionPlugin ownerPlugin) { controller = owner; plugin = ownerPlugin; instance = this; if (!IsOpen) { ((Behaviour)this).enabled = false; } } internal static void ConnectPlayerModel(FreeCameraAndCollisionPlugin ownerPlugin) { if (!Chainloader.PluginInfos.ContainsKey("com.diamondminer99.playermodel")) { return; } try { Type type = AccessTools.TypeByName("SailwindPlayerModel.ModPauseMenu"); Type type2 = type?.GetNestedType("Entry"); FieldInfo fieldInfo = AccessTools.Field(AccessTools.TypeByName("SailwindPlayerModel.PauseMenuPatches"), "ExtraPauseKeyClaim"); MethodInfo methodInfo = ((type != null) ? AccessTools.Method(type, "Register", (Type[])null, (Type[])null) : null); MethodInfo methodInfo2 = ((type != null) ? AccessTools.Method(type, "Hide", (Type[])null, (Type[])null) : null); MethodInfo methodInfo3 = ((type != null) ? AccessTools.Method(type, "Reopen", (Type[])null, (Type[])null) : null); if (type2 == null || fieldInfo == null || methodInfo == null || methodInfo2 == null || methodInfo3 == null) { ownerPlugin.LogInitializationError("Photo mode: Player Model's pause menu was not found; the Photo Mode button is not added."); return; } object obj = Activator.CreateInstance(type2); type2.GetField("Id").SetValue(obj, "freecam_photomode"); type2.GetField("Order").SetValue(obj, 200); type2.GetField("Label").SetValue(obj, (Func<string>)(() => "Photo Mode")); type2.GetField("OnClick").SetValue(obj, new Action(OpenFromMenu)); Func<bool> previousClaim = fieldInfo.GetValue(null) as Func<bool>; fieldInfo.SetValue(null, (Func<bool>)(() => ClaimsPauseKey || (previousClaim != null && previousClaim()))); methodInfo.Invoke(null, new object[1] { obj }); playerModelMenuHide = methodInfo2; playerModelMenuReopen = methodInfo3; Type type3 = AccessTools.TypeByName("SailwindPlayerModel.PlayerModel"); playerModelForceVisible = ((type3 != null) ? AccessTools.Method(type3, "ForceVisible", (Type[])null, (Type[])null) : null); playerModelBody = ((type3 != null) ? AccessTools.Property(type3, "Body") : null); } catch (Exception ex) { playerModelMenuHide = null; ownerPlugin.LogInitializationError("Photo mode: could not connect to Player Model's pause menu: " + ex.GetBaseException().Message); } } internal static void EnsureGameMenuButton(StartMenu startMenu) { //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) object? obj = SettingsUiField?.GetValue(startMenu); GameObject val = (GameObject)((obj is GameObject) ? obj : null); Transform val2 = (((Object)(object)val != (Object)null) ? val.transform.Find("button recover") : null); if (!((Object)(object)val2 == (Object)null) && !((Object)(object)val2.parent.Find("freecam photo mode button") != (Object)null)) { Transform transform = Object.Instantiate<GameObject>(((Component)val2).gameObject, val2.parent).transform; ((Object)transform).name = "freecam photo mode button"; transform.localPosition = GameMenuButtonPosition; transform.localRotation = val2.localRotation; transform.localScale = val2.localScale; ((Component)transform).gameObject.SetActive(true); TextMesh[] componentsInChildren = ((Component)transform).GetComponentsInChildren<TextMesh>(true); for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].text = "Photo Mode"; } } } internal static bool IsGameMenuButton(StartMenuButton button) { Transform parent = ((Component)button).transform.parent; if ((Object)(object)parent != (Object)null) { return ((Object)parent).name == "freecam photo mode button"; } return false; } internal static void OpenFromMenu() { if ((Object)(object)instance != (Object)null && !IsOpen) { instance.Open(); } } private void Open() { //IL_0397: Unknown result type (might be due to invalid IL or missing references) //IL_039c: Unknown result type (might be due to invalid IL or missing references) Camera unityCamera = controller.UnityCamera; menu = (((Object)(object)menu != (Object)null) ? menu : Object.FindObjectOfType<StartMenu>()); if (!GameState.playing || GameState.currentlyLoading || !GameState.inCursorMenu || (Object)(object)GameState.currentShipyard != (Object)null || (Object)(object)menu == (Object)null || (Object)(object)unityCamera == (Object)null || (Object)(object)Sun.sun == (Object)null || (Object)(object)Weather.instance == (Object)null) { return; } ref GameObject reference = ref settingsUi; object? value = SettingsUiField.GetValue(menu); reference = (GameObject)((value is GameObject) ? value : null); Transform centerEye = controller.CenterEye; Transform val = (((Object)(object)centerEye != (Object)null) ? centerEye.Find("UI camera") : null); uiCamera = (((Object)(object)val != (Object)null) ? ((Component)val).GetComponent<Camera>() : null); if (!EnsurePanel()) { return; } ref GameObject reference2 = ref logo; object? value2 = LogoField.GetValue(menu); reference2 = (GameObject)((value2 is GameObject) ? value2 : null); playerModelMenuHide?.Invoke(null, null); settingsUiWasShown = (Object)(object)settingsUi != (Object)null && settingsUi.activeSelf; if (settingsUiWasShown) { DisableSettingsMenuMethod.Invoke(menu, null); } logoWasShown = (Object)(object)logo != (Object)null && logo.activeSelf; if (logoWasShown) { logo.SetActive(false); } menuPointer = ((Component)menu).GetComponent<MouseButtonPointer>(); menuPointerWasEnabled = (Object)(object)menuPointer != (Object)null && ((Behaviour)menuPointer).enabled; if ((Object)(object)menuPointer != (Object)null) { ((Behaviour)menuPointer).enabled = false; } sun = Sun.sun; sunLight = ((Component)sun).GetComponent<Light>(); sunlightIntensity = ((Component)sun).GetComponent<SunlightNightIntensity>(); savedGlobalTime = sun.globalTime; savedSunIntensity = (((Object)(object)sunLight != (Object)null) ? sunLight.intensity : 0f); localTimeOffset = Mathf.DeltaAngle(0f, (sun.localTime - sun.globalTime) * 15f) / 15f; weather = Weather.instance; savedWeatherTarget = weather.targetWeatherSet; savedWeatherLerp = (float)WeatherLerpField.GetValue(weather); VolufogManager val2 = VolufogManager.instance; if ((Object)(object)val2 != (Object)null) { savedFog[0] = val2.sunColorMult; savedFog[1] = val2.dayDensity; savedFog[2] = val2.daySaturaion; savedFog[3] = val2.dayMie; savedFog[4] = val2.moonColorMult; savedFog[5] = val2.nightDensity; savedFog[6] = val2.nightSaturation; savedFog[7] = val2.nightMie; savedDayFogMult = val2.dayDensityMult; savedNightFogMult = val2.nightDensityMult; } weatherParticles = (ParticleSystem[])(object)new ParticleSystem[WeatherParticleFields.Length]; savedParticleUnscaled = new bool[WeatherParticleFields.Length]; for (int i = 0; i < WeatherParticleFields.Length; i++) { object? obj = WeatherParticleFields[i]?.GetValue(weather); ParticleSystem val3 = (ParticleSystem)((obj is ParticleSystem) ? obj : null); weatherParticles[i] = val3; if ((Object)(object)val3 != (Object)null) { MainModule main = val3.main; savedParticleUnscaled[i] = ((MainModule)(ref main)).useUnscaledTime; ((MainModule)(ref main)).useUnscaledTime = true; } } postProcessing = ((Component)unityCamera).GetComponent<PostProcessingBehaviour>(); originalProfile = (((Object)(object)postProcessing != (Object)null) ? postProcessing.profile : null); if ((Object)(object)originalProfile != (Object)null) { photoProfile = Object.Instantiate<PostProcessingProfile>(originalProfile); postProcessing.profile = photoProfile; } savedFieldOfView = unityCamera.fieldOfView; playerBody = FindPlayerBody(); ResetControls(); uiHidden = false; IsOpen = true; ((Behaviour)this).enabled = true; ShowPanel(); } private void Close(bool showMenu) { //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) if (!IsOpen) { return; } FreeCameraController.ExitActiveCamera(); IsOpen = false; closedFrame = Time.frameCount; HidePanel(); uiHidden = false; SetHudHidden(hidden: false); Cursor.lockState = (CursorLockMode)0; Cursor.visible = true; SetBodyForcedVisible(visible: false); if (bodyHidden && (Object)(object)playerBody != (Object)null) { playerBody.SetActive(true); } bodyHidden = false; if ((Object)(object)postProcessing != (Object)null && (Object)(object)originalProfile != (Object)null) { postProcessing.profile = originalProfile; } if ((Object)(object)photoProfile != (Object)null) { Object.Destroy((Object)(object)photoProfile); photoProfile = null; } if ((Object)(object)controller.UnityCamera != (Object)null) { controller.UnityCamera.fieldOfView = savedFieldOfView; } sun.globalTime = savedGlobalTime; if ((Object)(object)sunLight != (Object)null) { sunLight.intensity = savedSunIntensity; } RestoreWeather(); for (int i = 0; i < weatherParticles.Length; i++) { if ((Object)(object)weatherParticles[i] != (Object)null) { MainModule main = weatherParticles[i].main; ((MainModule)(ref main)).useUnscaledTime = savedParticleUnscaled[i]; } } VolufogManager val = VolufogManager.instance; if ((Object)(object)val != (Object)null) { val.dayDensityMult = savedDayFogMult; val.nightDensityMult = savedNightFogMult; } if ((Object)(object)menuPointer != (Object)null) { ((Behaviour)menuPointer).enabled = menuPointerWasEnabled; } if (showMenu) { if (logoWasShown && (Object)(object)logo != (Object)null) { logo.SetActive(true); } if (playerModelMenuReopen != null) { playerModelMenuReopen.Invoke(null, null); } else if (settingsUiWasShown) { EnableSettingsMenuMethod.Invoke(menu, null); } } ((Behaviour)this).enabled = false; } private void Update() { if (!IsOpen) { return; } if (!GameState.playing || !GameState.inCursorMenu) { Close(showMenu: false); } else if (Input.GetKeyDown((KeyCode)27) || Input.GetKeyDown((KeyCode)291) || Input.GetKeyDown((KeyCode)336)) { if (uiHidden) { SetUiHidden(hidden: false); } else { Close(showMenu: true); } } else if (!uiHidden) { UpdatePanel(); } } private void LateUpdate() { //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) if (IsOpen) { if (time.Set && (Object)(object)sunLight != (Object)null && (Object)(object)sunlightIntensity != (Object)null) { sunLight.intensity = ((sun.dummySun.position.y < sun.nightLightOffHeight) ? 0f : (sunlightIntensity.dayIntensity * Mathf.InverseLerp(-25f, -1f, controller.CenterEye.position.y))); } if (weatherFogDirty) { weatherFogDirty = false; ApplyWeatherFog(); } ApplyPicture(); if (fogDensity.Set) { RenderSettings.fogDensity *= fogDensity.Value; } SetBodyForcedVisible(FreeCameraController.IsFreeCameraOn && !BoatCamera.on); } } private void OnApplicationQuit() { Close(showMenu: false); } private void SetLocalTime(float localTime) { sun.globalTime = Mathf.Repeat(localTime - localTimeOffset, 24f); weatherFogDirty = true; } private void ResetTime() { sun.globalTime = savedGlobalTime; if ((Object)(object)sunLight != (Object)null) { sunLight.intensity = savedSunIntensity; } weatherFogDirty = true; } private void SetWeatherPreset(int preset) { weatherPreset = preset; if (preset == 0) { RestoreWeather(); } else { weather.targetWeatherSet = PresetSet(preset); WeatherLerpField.SetValue(weather, 1f); } weatherFogDirty = true; } private WeatherSet PresetSet(int preset) { Region currentRegion = weather.currentRegion; return (WeatherSet)(preset switch { 1 => currentRegion.clearWeather, 2 => currentRegion.cloudyWeather, 3 => currentRegion.rainWeather, _ => currentRegion.stormWeather, }); } private VolufogSet PresetFog(int preset) { Region currentRegion = weather.currentRegion; return (VolufogSet)(preset switch { 1 => currentRegion.clearVolufog, 2 => currentRegion.cloudyVolufog, 3 => currentRegion.rainVolufog, _ => currentRegion.stormVolufog, }); } private void ApplyWeatherFog() { VolufogManager val = VolufogManager.instance; if (!((Object)(object)val == (Object)null)) { if (weatherPreset != 0) { val.ApplySet(PresetFog(weatherPreset)); } else if (time.Set && (Object)(object)WeatherStorms.instance != (Object)null) { WeatherStorms.instance.ApplyStorm(); } else { RestoreFogValues(val); } } } private void RestoreWeather() { weather.targetWeatherSet = savedWeatherTarget; WeatherLerpField.SetValue(weather, savedWeatherLerp); if ((Object)(object)VolufogManager.instance != (Object)null) { RestoreFogValues(VolufogManager.instance); } } private void RestoreFogValues(VolufogManager fog) { fog.sunColorMult = savedFog[0]; fog.dayDensity = savedFog[1]; fog.daySaturaion = savedFog[2]; fog.dayMie = savedFog[3]; fog.moonColorMult = savedFog[4]; fog.nightDensity = savedFog[5]; fog.nightSaturation = savedFog[6]; fog.nightMie = savedFog[7]; } private void ApplyPicture() { //IL_0028: 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_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_02a0: Unknown result type (might be due to invalid IL or missing references) //IL_02b1: Unknown result type (might be due to invalid IL or missing references) //IL_02b6: Unknown result type (might be due to invalid IL or missing references) //IL_02c6: Unknown result type (might be due to invalid IL or missing references) //IL_02ed: Unknown result type (might be due to invalid IL or missing references) //IL_0340: Unknown result type (might be due to invalid IL or missing references) //IL_0351: Unknown result type (might be due to invalid IL or missing references) //IL_0356: Unknown result type (might be due to invalid IL or missing references) //IL_0385: Unknown result type (might be due to invalid IL or missing references) //IL_03c0: Unknown result type (might be due to invalid IL or missing references) //IL_03d2: Unknown result type (might be due to invalid IL or missing references) //IL_03d7: Unknown result type (might be due to invalid IL or missing references) //IL_03e8: Unknown result type (might be due to invalid IL or missing references) //IL_043c: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)photoProfile == (Object)null) && !((Object)(object)originalProfile == (Object)null)) { Settings settings = originalProfile.colorGrading.settings; settings.basic.postExposure += (exposure.Set ? exposure.Value : 0f); settings.basic.contrast = (contrast.Set ? contrast.Value : settings.basic.contrast); settings.basic.saturation = (saturation.Set ? saturation.Value : settings.basic.saturation); settings.basic.temperature = (temperature.Set ? temperature.Value : settings.basic.temperature); settings.basic.tint = (tint.Set ? tint.Value : settings.basic.tint); ((PostProcessingModel)photoProfile.colorGrading).enabled = ((PostProcessingModel)originalProfile.colorGrading).enabled; photoProfile.colorGrading.settings = settings; Settings settings2 = originalProfile.bloom.settings; settings2.bloom.intensity = (bloomIntensity.Set ? bloomIntensity.Value : settings2.bloom.intensity); settings2.bloom.threshold = (bloomThreshold.Set ? bloomThreshold.Value : settings2.bloom.threshold); ((PostProcessingModel)photoProfile.bloom).enabled = ((PostProcessingModel)originalProfile.bloom).enabled || bloomIntensity.Set; photoProfile.bloom.settings = settings2; Settings settings3 = originalProfile.vignette.settings; settings3.intensity = (vignetteIntensity.Set ? vignetteIntensity.Value : settings3.intensity); settings3.smoothness = (vignetteSmoothness.Set ? vignetteSmoothness.Value : settings3.smoothness); ((PostProcessingModel)photoProfile.vignette).enabled = ((PostProcessingModel)originalProfile.vignette).enabled || vignetteIntensity.Set; photoProfile.vignette.settings = settings3; Settings settings4 = originalProfile.grain.settings; settings4.intensity = (grainIntensity.Set ? grainIntensity.Value : settings4.intensity); settings4.size = (grainSize.Set ? grainSize.Value : settings4.size); ((PostProcessingModel)photoProfile.grain).enabled = ((PostProcessingModel)originalProfile.grain).enabled || grainIntensity.Set; photoProfile.grain.settings = settings4; Settings settings5 = originalProfile.depthOfField.settings; if (depthOfField) { settings5.focusDistance = focusDistance; settings5.aperture = aperture; settings5.useCameraFov = true; settings5.kernelSize = (KernelSize)2; } ((PostProcessingModel)photoProfile.depthOfField).enabled = ((PostProcessingModel)originalProfile.depthOfField).enabled || depthOfField; photoProfile.depthOfField.settings = settings5; Settings settings6 = originalProfile.chromaticAberration.settings; settings6.intensity = (chromaticAberration.Set ? chromaticAberration.Value : settings6.intensity); ((PostProcessingModel)photoProfile.chromaticAberration).enabled = ((PostProcessingModel)originalProfile.chromaticAberration).enabled || chromaticAberration.Set; photoProfile.chromaticAberration.settings = settings6; } } private void SetVolumetricFog(float factor) { VolufogManager val = VolufogManager.instance; if ((Object)(object)val != (Object)null) { val.dayDensityMult = savedDayFogMult * factor; val.nightDensityMult = savedNightFogMult * factor; } } private void SetFieldOfView(float fieldOfView) { if (FreeCameraController.IsFreeCameraOn) { controller.SetZoom(fieldOfView); } else if ((Object)(object)controller.UnityCamera != (Object)null) { controller.UnityCamera.fieldOfView = fieldOfView; } } private void SetUiHidden(bool hidden) { uiHidden = hidden; SetHudHidden(hidden); Cursor.lockState = (CursorLockMode)(hidden ? 1 : 0); Cursor.visible = !hidden; } private void SetHudHidden(bool hidden) { if (hidden == hudHidden) { return; } hudHidden = hidden; if (hidden) { if ((Object)(object)uiCamera != (Object)null) { savedUiCullingMask = uiCamera.cullingMask; uiCamera.cullingMask = 0; } hudRenderers = CollectHudRenderers(); savedHudRendererStates = new bool[hudRenderers.Length]; for (int i = 0; i < hudRenderers.Length; i++) { savedHudRendererStates[i] = hudRenderers[i].enabled; hudRenderers[i].enabled = false; } return; } if ((Object)(object)uiCamera != (Object)null) { uiCamera.cullingMask = savedUiCullingMask; } for (int j = 0; j < hudRenderers.Length; j++) { if ((Object)(object)hudRenderers[j] != (Object)null) { hudRenderers[j].enabled = savedHudRendererStates[j]; } } hudRenderers = null; savedHudRendererStates = null; } private static Renderer[] CollectHudRenderers() { GameObject[] array = (GameObject[])(object)new GameObject[4] { Refs.mouseCrosshair, GameObject.Find("look UI"), ((Object)(object)MoneyNotification.instance != (Object)null) ? ((Component)MoneyNotification.instance).gameObject : null, ((Object)(object)BuyItemUI.instance != (Object)null) ? ((Component)BuyItemUI.instance).gameObject : null }; List<Renderer> list = new List<Renderer>(); for (int i = 0; i < array.Length; i++) { if ((Object)(object)array[i] != (Object)null) { list.AddRange(array[i].GetComponentsInChildren<Renderer>(true)); } } return list.ToArray(); } private static GameObject FindPlayerBody() { object obj = playerModelBody?.GetValue(null, null); PropertyInfo propertyInfo = ((obj != null) ? AccessTools.Property(obj.GetType(), "Instance") : null); if (!(propertyInfo != null)) { return null; } object? value = propertyInfo.GetValue(obj, null); return (GameObject)((value is GameObject) ? value : null); } private void SetBodyHidden(bool hidden) { bodyHidden = hidden; if ((Object)(object)playerBody != (Object)null) { playerBody.SetActive(!hidden); } } private void SetBodyForcedVisible(bool visible) { if (visible != bodyForcedVisible && !(playerModelForceVisible == null)) { bodyForcedVisible = visible; playerModelForceVisible.Invoke(null, new object[1] { visible }); } } private void ResetControls() { time = (fieldOfView = (exposure = (contrast = (saturation = (temperature = (tint = default(Setting))))))); bloomIntensity = (bloomThreshold = (vignetteIntensity = (vignetteSmoothness = default(Setting)))); grainIntensity = (grainSize = (chromaticAberration = (fogDensity = (volumetricFog = default(Setting))))); weatherPreset = 0; depthOfField = false; focusDistance = 10f; aperture = 5.6f; showGrid = false; } private void ResetAll() { if (time.Set) { ResetTime(); } if (weatherPreset != 0) { SetWeatherPreset(0); } SetVolumetricFog(1f); SetFieldOfView(FieldOfViewMaximum); if (bodyHidden) { SetBodyHidden(hidden: false); } ResetControls(); } private bool EnsurePanel() { //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_0237: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_0290: Unknown result type (might be due to invalid IL or missing references) //IL_0295: Unknown result type (might be due to invalid IL or missing references) //IL_02a6: Unknown result type (might be due to invalid IL or missing references) //IL_02ab: Unknown result type (might be due to invalid IL or missing references) //IL_02bc: Unknown result type (might be due to invalid IL or missing references) //IL_02c1: Unknown result type (might be due to invalid IL or missing references) //IL_031c: Unknown result type (might be due to invalid IL or missing references) //IL_0323: Expected O, but got Unknown if ((Object)(object)panelRoot != (Object)null) { return true; } if ((Object)(object)uiCamera == (Object)null || (Object)(object)settingsUi == (Object)null || (Object)(object)AutosaveUI.instance == (Object)null) { return false; } Transform transform = settingsUi.transform; PanelParts panelParts = new PanelParts { Page = transform, Paper = transform.Find("bg"), Plate = transform.Find("switch"), PlateText = transform.Find("switch/text (1)"), Mark = transform.Find("chekbox (5)/text"), Label = transform.Find("text (3)"), Heading = transform.Find("text (2)"), Value = transform.Find("text fov"), Strip = transform.Find("slider fov"), Bars = transform.Find("slider fov/text volume"), Arrow = transform.Find("button back/text (1)") }; GPButtonSliderVolume val = (((Object)(object)panelParts.Strip != (Object)null) ? ((Component)panelParts.Strip).GetComponent<GPButtonSliderVolume>() : null); if ((Object)(object)panelParts.Paper == (Object)null || (Object)(object)panelParts.Plate == (Object)null || (Object)(object)panelParts.PlateText == (Object)null || (Object)(object)panelParts.Mark == (Object)null || (Object)(object)panelParts.Label == (Object)null || (Object)(object)panelParts.Heading == (Object)null || (Object)(object)panelParts.Value == (Object)null || (Object)(object)val == (Object)null || (Object)(object)panelParts.Bars == (Object)null || (Object)(object)panelParts.Arrow == (Object)null || (Object)(object)AutosaveUI.instance.onMaterial == (Object)null || (Object)(object)AutosaveUI.instance.offMaterial == (Object)null) { plugin.LogInitializationError("Photo mode: a part of the game's settings page it copies is missing."); return false; } panelParts.MarkOffset = transform.InverseTransformPoint(panelParts.Mark.position).y - transform.InverseTransformPoint(panelParts.Mark.parent.position).y; panelParts.BarsInset = transform.InverseTransformPoint(panelParts.Bars.position).x - (transform.InverseTransformPoint(panelParts.Strip.position).x - PageScale(panelParts, panelParts.Strip).x * 0.5f); plateOn = AutosaveUI.instance.onMaterial; plateOff = AutosaveUI.instance.offMaterial; ink = ((Component)panelParts.Label).GetComponent<TextMesh>().color; barColour = ((Component)panelParts.Bars).GetComponent<TextMesh>().color; plateInk = ((Component)panelParts.PlateText).GetComponent<TextMesh>().color; string text = (string.IsNullOrEmpty(val.bar) ? "▋" : val.bar); for (int i = 0; i <= 20; i++) { barTexts[i] = ((i == 0) ? string.Empty : (barTexts[i - 1] + text)); } GameObject val2 = new GameObject("freecam photo panel"); val2.SetActive(false); val2.layer = ((Component)transform).gameObject.layer; panelRoot = val2.transform; panelRoot.SetParent(((Component)uiCamera).transform, false); hits.Clear(); float num = -0.25f; float num2 = 1.255f; AddButton(panelParts, Part.HideUi, "Hide UI", 0.14f + num2 * 0.5f, num, num2); AddButton(panelParts, Part.Leave, "Leave", 2.6999998f - num2 * 0.5f, num, num2); num -= 0.11f; List<SliderRow> list = new List<SliderRow>(); AddHeading(panelParts, "SCENE", ref num); list.Add(AddSlider(panelParts, SliderId.Time, "time of day", list.Count, ref num)); num -= 0.11f; int num3 = WeatherNames.Length; float num4 = (2.56f - (float)(num3 - 1) * 0.05f) / (float)num3; weatherPlates = (Renderer[])(object)new Renderer[num3]; for (int j = 0; j < num3; j++) { weatherPlates[j] = AddButton(panelParts, Part.Weather, WeatherNames[j], 0.14f + num4 * 0.5f + (float)j * (num4 + 0.05f), num, num4, j + 1); } num -= 0.11f; AddHeading(panelParts, "CAMERA", ref num); list.Add(AddSlider(panelParts, SliderId.FieldOfView, "field of view", list.Count, ref num)); depthOfFieldMark = AddCheckbox(panelParts, Part.DepthOfField, "depth of field", ref num, out var labelText, out var box); list.Add(AddSlider(panelParts, SliderId.FocusDistance, "focus distance", list.Count, ref num)); list.Add(AddSlider(panelParts, SliderId.Aperture, "aperture", list.Count, ref num)); AddHeading(panelParts, "PICTURE", ref num); list.Add(AddSlider(panelParts, SliderId.Exposure, "exposure", list.Count, ref num)); list.Add(AddSlider(panelParts, SliderId.Contrast, "contrast", list.Count, ref num)); list.Add(AddSlider(panelParts, SliderId.Saturation, "saturation", list.Count, ref num)); list.Add(AddSlider(panelParts, SliderId.Temperature, "temperature", list.Count, ref num)); list.Add(AddSlider(panelParts, SliderId.Tint, "tint", list.Count, ref num)); list.Add(AddSlider(panelParts, SliderId.BloomIntensity, "bloom", list.Count, ref num)); list.Add(AddSlider(panelParts, SliderId.BloomThreshold, "bloom threshold", list.Count, ref num)); list.Add(AddSlider(panelParts, SliderId.Vignette, "vignette", list.Count, ref num)); list.Add(AddSlider(panelParts, SliderId.VignetteSoftness, "vignette softness", list.Count, ref num)); list.Add(AddSlider(panelParts, SliderId.FilmGrain, "film grain", list.Count, ref num)); list.Add(AddSlider(panelParts, SliderId.GrainSize, "grain size", list.Count, ref num)); list.Add(AddSlider(panelParts, SliderId.ChromaticAberration, "chromatic aberration", list.Count, ref num)); list.Add(AddSlider(panelParts, SliderId.Fog, "fog", list.Count, ref num)); list.Add(AddSlider(panelParts, SliderId.VolumetricFog, "volumetric fog", list.Count, ref num)); sliderRows = list.ToArray(); AddHeading(panelParts, "EXTRAS", ref num); hideBodyMark = AddCheckbox(panelParts, Part.HideBody, "hide the player's body", ref num, out hideBodyLabel, out hideBodyPlate); gridMark = AddCheckbox(panelParts, Part.Grid, "framing grid", ref num, out labelText, out box); num -= 0.11f; AddButton(panelParts, Part.ResetAll, "Reset All", 1.42f, num, num2); num -= 0.16f; AddText(panelParts, panelParts.Label, "hint", "B: free camera, look with the right mouse button held\nHide UI: ESC shows the panel again. ESC: leave", 1.42f, num, (TextAnchor)1, 0.85f).alignment = (TextAlignment)1; num -= 0.39999998f; panelHeight = 0f - num; AddPaper(panelParts); return true; } private static Vector3 PageScale(PanelParts parts, Transform part) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: 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_0019: 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_0026: 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_0033: 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) Vector3 lossyScale = parts.Page.lossyScale; Vector3 lossyScale2 = part.lossyScale; return new Vector3(lossyScale2.x / lossyScale.x, lossyScale2.y / lossyScale.y, lossyScale2.z / lossyScale.z); } private GameObject Copy(PanelParts parts, Transform source, string name, float x, float y, float z) { //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_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) GameObject val = Object.Instantiate<GameObject>(((Component)source).gameObject, panelRoot); ((Object)val).name = name; Transform transform = val.transform; for (int num = transform.childCount - 1; num >= 0; num--) { Object.DestroyImmediate((Object)(object)((Component)transform.GetChild(num)).gameObject); } GoPointerButton[] components = val.GetComponents<GoPointerButton>(); for (int i = 0; i < components.Length; i++) { Object.DestroyImmediate((Object)(object)components[i]); } Collider[] components2 = val.GetComponents<Collider>(); for (int i = 0; i < components2.Length; i++) { Object.DestroyImmediate((Object)(object)components2[i]); } Outline component = val.GetComponent<Outline>(); if ((Object)(object)component != (Object)null) { ((Behaviour)component).enabled = false; } transform.localRotation = Quaternion.Inverse(parts.Page.rotation) * source.rotation; transform.localScale = PageScale(parts, source); transform.localPosition = new Vector3(x, y, z); val.SetActive(true); return val; } private TextMesh AddText(PanelParts parts, Transform source, string name, string text, float x, float y, TextAnchor anchor, float size = 1f) { //IL_0018: 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_0035: Unknown result type (might be due to invalid IL or missing references) TextMesh component = Copy(parts, source, name, x, y, -0.01f).GetComponent<TextMesh>(); component.anchor = anchor; component.text = text; Transform transform = ((Component)component).transform; transform.localScale *= size; return component; } private Renderer AddPlate(PanelParts parts, Transform source, string name, float x, float y, float width, float height) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0028: 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) GameObject obj = Copy(parts, source, name, x, y, 0f); Vector3 localScale = obj.transform.localScale; obj.transform.localScale = new Vector3(width, height, localScale.z); return obj.GetComponent<Renderer>(); } private void AddHit(Part part, int index, float x, float y, float width, float height, Renderer plate) { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) Outline val = ((Component)plate).GetComponent<Outline>(); if ((Object)(object)val == (Object)null) { val = ((Component)plate).gameObject.AddComponent<Outline>(); ((Behaviour)val).enabled = false; } hits.Add(new Hit { Area = new Rect(x - width * 0.5f, y - height * 0.5f, width, height), Part = part, Index = index, Outline = val }); } private Renderer AddButton(PanelParts parts, Part part, string text, float x, float y, float width, int index = 0) { Renderer val = AddPlate(parts, parts.Plate, ((part == Part.Weather) ? "weather " : "button ") + text, x, y, width, 0.15f); val.sharedMaterial = plateOn; AddText(parts, parts.PlateText, "text " + text, text, x, y, (TextAnchor)4); AddHit(part, index, x, y, width, 0.15f, val); return val; } private void AddHeading(PanelParts parts, string text, ref float y) { y -= 0.1f; AddText(parts, parts.Heading, "heading " + text, text, 1.42f, y, (TextAnchor)4); y -= 0.1f; } private TextMesh AddCheckbox(PanelParts parts, Part part, string label, ref float y, out TextMesh labelText, out Renderer box) { y -= 0.08f; labelText = AddText(parts, parts.Label, "label " + label, label, 1.3f, y, (TextAnchor)5); float x = 1.455f; box = AddPlate(parts, parts.Plate, "checkbox " + label, x, y, 0.15f, 0.13f); box.sharedMaterial = plateOn; TextMesh result = AddText(parts, parts.Mark, "mark " + label, string.Empty, x, y + parts.MarkOffset, (TextAnchor)4); AddHit(part, 0, x, y, 0.15f, 0.13f, box); y -= 0.08f; return result; } private SliderRow AddSlider(PanelParts parts, SliderId id, string label, int index, ref float y) { //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) y -= 0.08f; SliderRow sliderRow = new SliderRow { Id = id }; sliderRow.Label = AddText(parts, parts.Label, "label " + label, label, 1.3f, y, (TextAnchor)5); float x = 1.75f; Renderer plate = AddPlate(parts, parts.Strip, "slider " + label, x, y, 0.74f, 0.13f); float num = 0.74f / PageScale(parts, parts.Strip).x; sliderRow.BarsLeft = 1.38f + parts.BarsInset * num; sliderRow.BarsWidth = 0.74f - 2f * parts.BarsInset * num; sliderRow.Bars = AddText(parts, parts.Bars, "bars " + label, string.Empty, sliderRow.BarsLeft, y, (TextAnchor)3); Vector3 localScale = ((Component)sliderRow.Bars).transform.localScale; ((Component)sliderRow.Bars).transform.localScale = new Vector3(localScale.x * num, localScale.y, localScale.z); sliderRow.Value = AddText(parts, parts.Value, "value " + label, string.Empty, 2.5f, y, (TextAnchor)5); AddHit(Part.Slider, index, x, y, 0.74f, 0.16f, plate); if (id != SliderId.FocusDistance && id != SliderId.Aperture) { sliderRow.ResetPlate = AddPlate(parts, parts.Plate, "reset " + label, 2.625f, y, 0.15f, 0.13f); sliderRow.ResetArrow = AddText(parts, parts.Arrow, "arrow " + label, "↩", 2.625f, y, (TextAnchor)4, 0.8f); AddHit(Part.Reset, index, 2.625f, y, 0.15f, 0.13f, sliderRow.ResetPlate); } y -= 0.08f; return sliderRow; } private void AddPaper(PanelParts parts) { //IL_0028: 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_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0097: 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_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Expected O, but got Unknown //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) float num = 3f; float num2 = panelHeight + 0.16f; paperArea = new Rect(-0.08f, 0f - panelHeight - 0.08f, num, num2); GameObject obj = Copy(parts, parts.Paper, "paper", 0f, 0f, 0f); Bounds bounds = obj.GetComponent<MeshFilter>().sharedMesh.bounds; Transform transform = obj.transform; Vector3 localScale = transform.localScale; transform.localScale = new Vector3(num / ((Bounds)(ref bounds)).size.x, num2 / ((Bounds)(ref bounds)).size.y, localScale.z); Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(1.42f, (0f - panelHeight) * 0.5f, 0.16f); transform.localPosition = val - transform.localRotation * Vector3.Scale(((Bounds)(ref bounds)).center, transform.localScale); Renderer component = obj.GetComponent<Renderer>(); Material val2 = new Material(component.sharedMaterial) { name = "freecam photo panel paper" }; val2.SetTexture("_EmissionMap", val2.mainTexture); val2.SetColor("_EmissionColor", PaperEmission); val2.EnableKeyword("_EMISSION"); val2.color = Color.black; component.sharedMaterial = val2; } private void ShowPanel() { ((Component)panelRoot).gameObject.SetActive(true); PlacePanel(); for (int i = 0; i < sliderRows.Length; i++) { sliderRows[i].ShownValue = float.NaN; sliderRows[i].ShownFraction = float.NaN; sliderRows[i].State = -1; } shownPreset = -1; shownChecks = -1; RefreshPanel(); } private void HidePanel() { SetHovered(-1); dragged = null; mouseOverPanel = false; if ((Object)(object)panelRoot != (Object)null) { ((Component)panelRoot).gameObject.SetActive(false); } } private void PlacePanel() { //IL_005a: Un