using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using TMPro;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("PeakUnlockedCamera")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("PeakUnlockedCamera")]
[assembly: AssemblyTitle("PeakUnlockedCamera")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
[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 PeakUnlockedCamera
{
internal enum CameraMode
{
Default,
FrontThirdPerson,
FreeCamera
}
internal enum RadialMenuKind
{
Pose,
Camera
}
internal readonly struct CameraSnapshot
{
public Vector3 Position { get; }
public Quaternion Rotation { get; }
public float FieldOfView { get; }
public CameraSnapshot(Vector3 position, Quaternion rotation, float fieldOfView)
{
//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_0008: 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)
Position = position;
Rotation = rotation;
FieldOfView = fieldOfView;
}
}
internal readonly struct InputActionState
{
public InputAction Action { get; }
public bool WasEnabled { get; }
public InputActionState(InputAction action, bool wasEnabled)
{
Action = action;
WasEnabled = wasEnabled;
}
}
internal readonly struct GameObjectActiveState
{
public GameObject GameObject { get; }
public bool WasActive { get; }
public GameObjectActiveState(GameObject gameObject, bool wasActive)
{
GameObject = gameObject;
WasActive = wasActive;
}
}
[BepInPlugin("io.pekoe.peak.unlockedcamera", "Unlocked Camera", "1.1.4")]
public sealed class Plugin : BaseUnityPlugin
{
internal const string PluginGuid = "io.pekoe.peak.unlockedcamera";
internal const string PluginName = "Unlocked Camera";
internal const string PluginVersion = "1.1.4";
private static readonly Func<Vector3, Vector3, Vector3> NativeLookToDirection = AccessTools.MethodDelegate<Func<Vector3, Vector3, Vector3>>(AccessTools.Method(typeof(HelperFunctions), "LookToDirection", new Type[2]
{
typeof(Vector3),
typeof(Vector3)
}, (Type[])null), (object)null, true);
private static readonly Func<Vector3, Vector3> NativeDirectionToLook = AccessTools.MethodDelegate<Func<Vector3, Vector3>>(AccessTools.Method(typeof(HelperFunctions), "DirectionToLook", new Type[1] { typeof(Vector3) }, (Type[])null), (object)null, true);
private static readonly Action<Character> RecalculateNativeLookDirections = AccessTools.MethodDelegate<Action<Character>>(AccessTools.Method(typeof(Character), "RecalculateLookDirections", (Type[])null, (Type[])null), (object)null, true);
private readonly List<InputActionState> _disabledInputActions = new List<InputActionState>();
private ConfigEntry<KeyCode> _toggleHudKey;
private ConfigEntry<KeyCode> _holdPoseRadialKey;
private ConfigEntry<KeyCode> _holdCameraRadialKey;
private ConfigEntry<float> _frontDistance;
private ConfigEntry<float> _frontHeight;
private ConfigEntry<float> _frontPositionLerpRate;
private ConfigEntry<float> _frontRotationSpeed;
private ConfigEntry<float> _frontScrollStep;
private ConfigEntry<float> _frontScrollMultiplier;
private ConfigEntry<float> _frontGazeDownOffsetDegrees;
private ConfigEntry<float> _freeMoveSpeed;
private ConfigEntry<float> _freeMouseSensitivity;
private ConfigEntry<float> _freeShiftSpeedMultiplier;
private CameraMode _mode;
private bool _freeCameraRequested;
private CameraSnapshot _freeCameraSnapshot;
private GameObject? _hudRoot;
private readonly List<GameObjectActiveState> _hiddenHudChildren = new List<GameObjectActiveState>();
private bool _hudVisible = true;
private float _frontCurrentDistance;
private bool _frontDistanceInitialized;
private Vector2 _frontOrbitLookValues;
private Vector2 _lastForcedGazeLookValues;
private bool _frontOrbitInitialized;
private string _statusText = string.Empty;
private float _statusHideAt;
private GameObject? _statusOverlayRoot;
private TextMeshProUGUI? _statusOverlayText;
private bool _poseRadialActive;
private int _poseRadialHoveredPose = -1;
private CursorLockMode _poseRadialPreviousCursorLockMode;
private bool _poseRadialPreviousCursorVisible;
private bool _poseRadialPreviousWindowShowingCursor;
private Vector2 _poseRadialPreviousCursorPosition;
private bool _poseRadialHasPreviousCursorPosition;
private GameObject? _poseRadialRoot;
private RectTransform? _poseRadialContainer;
private CanvasGroup? _poseRadialCanvasGroup;
private readonly Image?[] _poseRadialSliceImages = (Image?[])(object)new Image[8];
private readonly Image?[] _poseRadialSliceOutlines = (Image?[])(object)new Image[8];
private readonly TextMeshProUGUI?[] _poseRadialSliceLabels = (TextMeshProUGUI?[])(object)new TextMeshProUGUI[8];
private readonly Sprite?[] _poseRadialFillSprites = (Sprite?[])(object)new Sprite[8];
private readonly Sprite?[] _poseRadialOutlineSprites = (Sprite?[])(object)new Sprite[8];
private readonly Sprite?[] _cameraRadialFillSprites = (Sprite?[])(object)new Sprite[3];
private readonly Sprite?[] _cameraRadialOutlineSprites = (Sprite?[])(object)new Sprite[3];
private bool _poseRadialClosing;
private float _poseRadialAnimationStartedAt;
private int _suppressPoseRadialCameraInputUntilFrame = -1;
private RadialMenuKind _radialMenuKind;
private bool _hasSelectedIdlePose;
private int _selectedIdlePose;
private const int PoseCount = 8;
private const int CameraRadialCount = 3;
private const float PoseRadialOuterRadius = 216f;
private const float PoseRadialInnerRadius = 84f;
private const int PoseRadialTextureSize = 480;
private const float PoseRadialOpenDuration = 0.12f;
private const float PoseRadialCloseDuration = 0.09f;
private const float PoseRadialClosedScale = 0.7f;
private const float PoseRadialHoveredScale = 1.05f;
private const float PoseRadialHoveredOffset = 7f;
private static readonly Vector2 PoseRadialAnchor = new Vector2(0.7f, 0.5f);
internal static Plugin Instance { get; private set; } = null;
private void Awake()
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
Instance = this;
BindConfiguration();
PrewarmRadialSpriteCache();
new Harmony("io.pekoe.peak.unlockedcamera").PatchAll();
((BaseUnityPlugin)this).Logger.LogInfo((object)"Unlocked Camera 1.1.4 loaded.");
}
private void Update()
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_0097: 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)
UpdateStatusOverlay();
if (_poseRadialActive)
{
if (IsInputBlockedByGameUi())
{
ClosePoseRadialImmediately();
}
else if (!Input.GetKey(GetActiveRadialKey()))
{
BeginRadialClose();
}
else
{
UpdateRadial();
}
}
else if (_poseRadialClosing)
{
UpdatePoseRadialAnimation();
}
else if (!IsInputBlockedByGameUi())
{
if (Input.GetKeyDown(_toggleHudKey.Value))
{
_hudVisible = !_hudVisible;
ApplyHudVisibility();
ShowStatus(_hudVisible ? "HUD: ON" : "HUD: OFF");
}
if (Input.GetKeyDown(_holdCameraRadialKey.Value))
{
BeginRadial(RadialMenuKind.Camera);
}
else if (Input.GetKeyDown(_holdPoseRadialKey.Value))
{
BeginRadial(RadialMenuKind.Pose);
}
}
}
private void OnDestroy()
{
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
ClosePoseRadialImmediately();
DestroyRadialSpriteCache(_poseRadialFillSprites);
DestroyRadialSpriteCache(_poseRadialOutlineSprites);
DestroyRadialSpriteCache(_cameraRadialFillSprites);
DestroyRadialSpriteCache(_cameraRadialOutlineSprites);
if ((Object)(object)_poseRadialRoot != (Object)null)
{
Object.Destroy((Object)(object)_poseRadialRoot);
}
RestoreDisabledInputActions();
RestoreHudState();
if ((Object)(object)_statusOverlayRoot != (Object)null)
{
Object.Destroy((Object)(object)_statusOverlayRoot);
}
new Harmony("io.pekoe.peak.unlockedcamera").UnpatchSelf();
}
private void BindConfiguration()
{
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Expected O, but got Unknown
//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
//IL_00dd: Expected O, but got Unknown
//IL_0111: Unknown result type (might be due to invalid IL or missing references)
//IL_011b: Expected O, but got Unknown
//IL_014f: Unknown result type (might be due to invalid IL or missing references)
//IL_0159: Expected O, but got Unknown
//IL_018d: Unknown result type (might be due to invalid IL or missing references)
//IL_0197: Expected O, but got Unknown
//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
//IL_01d5: Expected O, but got Unknown
//IL_0209: Unknown result type (might be due to invalid IL or missing references)
//IL_0213: Expected O, but got Unknown
//IL_0247: Unknown result type (might be due to invalid IL or missing references)
//IL_0251: Expected O, but got Unknown
//IL_0285: Unknown result type (might be due to invalid IL or missing references)
//IL_028f: Expected O, but got Unknown
//IL_02c3: Unknown result type (might be due to invalid IL or missing references)
//IL_02cd: Expected O, but got Unknown
_toggleHudKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Controls", "Toggle HUD", (KeyCode)98, "Toggles the gameplay HUD independently of camera mode.");
_holdPoseRadialKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Controls", "Hold Pose Radial", (KeyCode)110, "Hold to open the pose radial. Hover a slot to apply that idle pose, then release to close it.");
_holdCameraRadialKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Controls", "Hold Camera Radial", (KeyCode)118, "Hold to open the camera radial. Release over Front Chase, Free Camera, or Cancel.");
_frontDistance = ((BaseUnityPlugin)this).Config.Bind<float>("Front Third Person", "Distance", 3f, new ConfigDescription("Distance in front of the local player.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 8f), Array.Empty<object>()));
_frontHeight = ((BaseUnityPlugin)this).Config.Bind<float>("Front Third Person", "Height", 1.5f, new ConfigDescription("Height above the local player's torso.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-1f, 4f), Array.Empty<object>()));
_frontPositionLerpRate = ((BaseUnityPlugin)this).Config.Bind<float>("Front Third Person", "Position Lerp Rate", 5f, new ConfigDescription("Front-view follow smoothing only. Free Camera never uses smoothing.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 30f), Array.Empty<object>()));
_frontRotationSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Front Third Person", "Rotation Speed", 720f, new ConfigDescription("Front-view rotation speed in degrees per second.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 2160f), Array.Empty<object>()));
_frontScrollStep = ((BaseUnityPlugin)this).Config.Bind<float>("Front Third Person", "Scroll Step", 0.5f, new ConfigDescription("Distance adjustment per mouse-wheel notch.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.05f, 2f), Array.Empty<object>()));
_frontScrollMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Front Third Person", "Scroll Multiplier", 3.5f, new ConfigDescription("Base multiplier for mouse-wheel distance adjustment. A 1.3x speed boost is also applied.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 10f), Array.Empty<object>()));
_frontGazeDownOffsetDegrees = ((BaseUnityPlugin)this).Config.Bind<float>("Front Third Person", "Gaze Down Offset Degrees", 20f, new ConfigDescription("Makes the character look below the camera by this many degrees.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-45f, 45f), Array.Empty<object>()));
_freeMoveSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Free Camera", "Move Speed", 6f, new ConfigDescription("Free-camera speed in world units per second.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 100f), Array.Empty<object>()));
_freeMouseSensitivity = ((BaseUnityPlugin)this).Config.Bind<float>("Free Camera", "Mouse Sensitivity", 3f, new ConfigDescription("Free-camera mouse sensitivity.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.05f, 25f), Array.Empty<object>()));
_freeShiftSpeedMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Free Camera", "Shift Speed Multiplier", 2f, new ConfigDescription("Camera movement multiplier while holding either Shift key.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 10f), Array.Empty<object>()));
}
private void CommitCameraRadialSelection(int selection)
{
switch (selection)
{
case 0:
EnterFrontChase();
break;
case 1:
EnterFreeCameraFromRadial();
break;
case 2:
ReturnToDefaultCamera();
break;
}
}
private void ReturnToDefaultCamera()
{
_freeCameraRequested = false;
ExitFreeCamera();
_mode = CameraMode.Default;
((BaseUnityPlugin)this).Logger.LogInfo((object)"Camera mode: Default");
ShowStatus("DEFAULT CAMERA");
}
private void EnterFrontChase()
{
_freeCameraRequested = false;
if (_mode == CameraMode.FreeCamera)
{
ExitFreeCamera();
}
_mode = CameraMode.FrontThirdPerson;
_frontCurrentDistance = _frontDistance.Value;
_frontDistanceInitialized = true;
_frontOrbitInitialized = false;
((BaseUnityPlugin)this).Logger.LogInfo((object)"Camera mode: Front Third Person");
ShowStatus("FRONT CHASE");
}
private void EnterFreeCameraFromRadial()
{
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
if (_mode == CameraMode.FrontThirdPerson)
{
_freeCameraRequested = true;
((BaseUnityPlugin)this).Logger.LogInfo((object)"Free Camera will unlock from the current front-camera frame.");
return;
}
if (_mode == CameraMode.FreeCamera)
{
ShowStatus("FREE CAMERA");
return;
}
MainCamera instance = MainCamera.instance;
Camera val = (((Object)(object)instance == (Object)null) ? null : ((Component)instance).GetComponent<Camera>());
if ((Object)(object)val == (Object)null)
{
((BaseUnityPlugin)this).Logger.LogWarning((object)"Free Camera could not start because the active PEAK camera was not found.");
return;
}
Transform transform = ((Component)val).transform;
_freeCameraSnapshot = new CameraSnapshot(transform.position, transform.rotation, val.fieldOfView);
_mode = CameraMode.FreeCamera;
DisableLocalMovementAndLookActions();
((BaseUnityPlugin)this).Logger.LogInfo((object)"Camera mode: Free Camera");
ShowStatus("FREE CAMERA");
}
private bool IsInputBlockedByGameUi()
{
if ((Object)(object)GUIManager.instance != (Object)null)
{
return GUIManager.instance.windowBlockingInput;
}
return false;
}
internal bool ShouldReplaceGameCharacterCamera()
{
CameraMode mode = _mode;
if ((uint)(mode - 1) <= 1u)
{
return true;
}
return false;
}
internal bool ShouldSuppressLocalCharacterMovement(CharacterMovement movement)
{
if ((_mode == CameraMode.FreeCamera || IsPoseRadialCameraInputSuppressed()) && (Object)(object)Character.localCharacter != (Object)null)
{
return (Object)(object)((Component)movement).GetComponent<Character>() == (Object)(object)Character.localCharacter;
}
return false;
}
internal bool ShouldSuppressLocalMovementInput(CharacterInput input)
{
if (_mode == CameraMode.FreeCamera && (Object)(object)Character.localCharacter != (Object)null)
{
return (Object)(object)Character.localCharacter.input == (Object)(object)input;
}
return false;
}
internal bool ShouldInvertLocalMovementInput(CharacterInput input)
{
if (_mode == CameraMode.FrontThirdPerson && (Object)(object)Character.localCharacter != (Object)null)
{
return (Object)(object)Character.localCharacter.input == (Object)(object)input;
}
return false;
}
internal bool ShouldSuppressLocalCharacterAction(CharacterMovement movement)
{
if (_mode == CameraMode.FreeCamera && (Object)(object)Character.localCharacter != (Object)null)
{
return (Object)(object)((Component)movement).GetComponent<Character>() == (Object)(object)Character.localCharacter;
}
return false;
}
internal bool ShouldSuppressLocalInteractInput(CharacterInput input)
{
if (_mode == CameraMode.FreeCamera && (Object)(object)Character.localCharacter != (Object)null)
{
return (Object)(object)Character.localCharacter.input == (Object)(object)input;
}
return false;
}
private bool IsPoseRadialCameraInputSuppressed()
{
if (!_poseRadialActive)
{
return Time.frameCount <= _suppressPoseRadialCameraInputUntilFrame;
}
return true;
}
internal void OnCameraLateUpdate(MainCameraMovement cameraMovement)
{
switch (_mode)
{
case CameraMode.FrontThirdPerson:
ApplyFrontThirdPerson(cameraMovement);
if (_freeCameraRequested)
{
EnterFreeCamera(cameraMovement);
}
break;
case CameraMode.FreeCamera:
ApplyFreeCamera(cameraMovement);
break;
}
if (_poseRadialActive)
{
MaintainPoseRadialCursor();
}
}
private void ApplyFrontThirdPerson(MainCameraMovement cameraMovement)
{
//IL_0027: 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_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_00e4: Unknown result type (might be due to invalid IL or missing references)
//IL_010c: Unknown result type (might be due to invalid IL or missing references)
//IL_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_012a: 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_013b: Unknown result type (might be due to invalid IL or missing references)
//IL_0140: Unknown result type (might be due to invalid IL or missing references)
//IL_0145: 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_0156: Unknown result type (might be due to invalid IL or missing references)
//IL_0158: Unknown result type (might be due to invalid IL or missing references)
//IL_015a: Unknown result type (might be due to invalid IL or missing references)
//IL_015b: Unknown result type (might be due to invalid IL or missing references)
//IL_0160: Unknown result type (might be due to invalid IL or missing references)
//IL_0164: Unknown result type (might be due to invalid IL or missing references)
//IL_0169: Unknown result type (might be due to invalid IL or missing references)
//IL_016b: Unknown result type (might be due to invalid IL or missing references)
//IL_016d: Unknown result type (might be due to invalid IL or missing references)
//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
//IL_0102: Unknown result type (might be due to invalid IL or missing references)
//IL_0196: Unknown result type (might be due to invalid IL or missing references)
//IL_019c: Unknown result type (might be due to invalid IL or missing references)
//IL_0202: Unknown result type (might be due to invalid IL or missing references)
//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
//IL_01be: 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_0209: 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_0214: Unknown result type (might be due to invalid IL or missing references)
//IL_0219: 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_0225: Unknown result type (might be due to invalid IL or missing references)
//IL_022a: Unknown result type (might be due to invalid IL or missing references)
//IL_022f: Unknown result type (might be due to invalid IL or missing references)
//IL_0234: Unknown result type (might be due to invalid IL or missing references)
//IL_026b: Unknown result type (might be due to invalid IL or missing references)
//IL_024c: Unknown result type (might be due to invalid IL or missing references)
//IL_0251: Unknown result type (might be due to invalid IL or missing references)
//IL_0264: Unknown result type (might be due to invalid IL or missing references)
//IL_0275: Unknown result type (might be due to invalid IL or missing references)
if (!TryGetCamera(cameraMovement, out Camera unityCamera) || (Object)(object)Character.localCharacter == (Object)null)
{
return;
}
if (IsPoseRadialCameraInputSuppressed())
{
ForceLocalCharacterGazeAt(((Component)unityCamera).transform.position);
return;
}
if (IsEmoteWheelHeld())
{
ForceLocalCharacterGazeAt(((Component)unityCamera).transform.position);
return;
}
if (!_frontDistanceInitialized)
{
_frontCurrentDistance = _frontDistance.Value;
_frontDistanceInitialized = true;
}
InitializeFrontCameraOrbit();
UpdateFrontCameraOrbitFromGameInput();
float axisRaw = Input.GetAxisRaw("Mouse ScrollWheel");
if (Mathf.Abs(axisRaw) > 0.0001f)
{
_frontCurrentDistance = Mathf.Clamp(_frontCurrentDistance - axisRaw * _frontScrollStep.Value * _frontScrollMultiplier.Value * 1.3f, 1f, 8f);
}
Vector3 val = NativeLookToDirection(Vector2.op_Implicit(_frontOrbitLookValues), Vector3.forward);
if (((Vector3)(ref val)).sqrMagnitude < 0.0001f)
{
val = ((Component)Character.localCharacter).transform.forward;
}
((Vector3)(ref val)).Normalize();
val.y = 0f - val.y;
((Vector3)(ref val)).Normalize();
Vector3 center = Character.localCharacter.Center;
Vector3 val2 = center + Vector3.up * _frontHeight.Value + val * _frontCurrentDistance;
Vector3 val3 = val2 - center;
Vector3 normalized = ((Vector3)(ref val3)).normalized;
float num = Vector3.Distance(val2, center);
int mask = LayerMask.GetMask(new string[2] { "Terrain", "Map" });
RaycastHit val4 = default(RaycastHit);
if (mask != 0 && Physics.SphereCast(center, 0.06f, normalized, ref val4, num, mask))
{
val2 = ((RaycastHit)(ref val4)).point - normalized * 0.03f;
}
Transform transform = ((Component)unityCamera).transform;
transform.position = ((_frontPositionLerpRate.Value <= 0f) ? val2 : Vector3.Lerp(transform.position, val2, Time.deltaTime * _frontPositionLerpRate.Value));
Quaternion val5 = Quaternion.LookRotation(center + Vector3.up * 0.5f - transform.position, Vector3.up);
transform.rotation = ((_frontRotationSpeed.Value <= 0f) ? val5 : Quaternion.RotateTowards(transform.rotation, val5, _frontRotationSpeed.Value * Time.deltaTime));
ForceLocalCharacterGazeAt(transform.position);
}
private void InitializeFrontCameraOrbit()
{
//IL_0021: 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_0032: Unknown result type (might be due to invalid IL or missing references)
if (!_frontOrbitInitialized && !((Object)(object)Character.localCharacter == (Object)null))
{
_frontOrbitLookValues = Character.localCharacter.data.lookValues;
_lastForcedGazeLookValues = _frontOrbitLookValues;
_frontOrbitInitialized = true;
}
}
private void UpdateFrontCameraOrbitFromGameInput()
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: 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_0036: 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)
if (!((Object)(object)Character.localCharacter == (Object)null))
{
Vector2 val = Character.localCharacter.data.lookValues - _lastForcedGazeLookValues;
_frontOrbitLookValues.x += val.x;
_frontOrbitLookValues.y = Mathf.Clamp(_frontOrbitLookValues.y + val.y, -85f, 85f);
}
}
private void ForceLocalCharacterGazeAt(Vector3 cameraPosition)
{
//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_0033: 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_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_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_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_008d: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: 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_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
Character localCharacter = Character.localCharacter;
if ((Object)(object)localCharacter == (Object)null)
{
return;
}
Vector3 val = cameraPosition - localCharacter.Head;
if (!(((Vector3)(ref val)).sqrMagnitude < 0.0001f))
{
((Vector3)(ref val)).Normalize();
Vector3 val2 = Vector3.Cross(Vector3.up, val);
if (((Vector3)(ref val2)).sqrMagnitude > 0.0001f)
{
val = Quaternion.AngleAxis(_frontGazeDownOffsetDegrees.Value, ((Vector3)(ref val2)).normalized) * val;
}
_lastForcedGazeLookValues = Vector2.op_Implicit(NativeDirectionToLook(val));
localCharacter.data.lookValues = _lastForcedGazeLookValues;
RecalculateNativeLookDirections(localCharacter);
}
}
private void EnterFreeCamera(MainCameraMovement cameraMovement)
{
//IL_001b: 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)
if (!TryGetCamera(cameraMovement, out Camera unityCamera))
{
_freeCameraRequested = false;
return;
}
Transform transform = ((Component)unityCamera).transform;
_freeCameraSnapshot = new CameraSnapshot(transform.position, transform.rotation, unityCamera.fieldOfView);
_freeCameraRequested = false;
_mode = CameraMode.FreeCamera;
DisableLocalMovementAndLookActions();
((BaseUnityPlugin)this).Logger.LogInfo((object)"Camera mode: Free Camera");
ShowStatus("FREE CAMERA");
}
private void ApplyFreeCamera(MainCameraMovement cameraMovement)
{
//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_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)
//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
//IL_016f: Unknown result type (might be due to invalid IL or missing references)
//IL_0175: Unknown result type (might be due to invalid IL or missing references)
//IL_0176: Unknown result type (might be due to invalid IL or missing references)
//IL_0182: Unknown result type (might be due to invalid IL or missing references)
//IL_0187: Unknown result type (might be due to invalid IL or missing references)
//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
if (!TryGetCamera(cameraMovement, out Camera unityCamera))
{
return;
}
Transform transform = ((Component)unityCamera).transform;
unityCamera.fieldOfView = _freeCameraSnapshot.FieldOfView;
if (!IsInputBlockedByGameUi() && !IsPoseRadialCameraInputSuppressed())
{
if (!IsEmoteWheelHeld())
{
Vector2 val = new Vector2(Input.GetAxisRaw("Mouse X"), Input.GetAxisRaw("Mouse Y"));
Quaternion val2 = Quaternion.AngleAxis((0f - val.y) * _freeMouseSensitivity.Value * 0.3f, transform.right);
Quaternion val3 = Quaternion.AngleAxis(val.x * _freeMouseSensitivity.Value * 0.3f, Vector3.up);
transform.rotation = val3 * val2 * transform.rotation;
}
Vector3 zero = Vector3.zero;
if (Input.GetKey((KeyCode)119))
{
zero.z += 1f;
}
if (Input.GetKey((KeyCode)115))
{
zero.z -= 1f;
}
if (Input.GetKey((KeyCode)100))
{
zero.x += 1f;
}
if (Input.GetKey((KeyCode)97))
{
zero.x -= 1f;
}
if (((Vector3)(ref zero)).sqrMagnitude > 1f)
{
((Vector3)(ref zero)).Normalize();
}
float num = _freeMoveSpeed.Value;
if (Input.GetKey((KeyCode)304) || Input.GetKey((KeyCode)303))
{
num *= _freeShiftSpeedMultiplier.Value;
}
transform.position += transform.TransformDirection(zero) * (num * Time.deltaTime);
float num2 = 0f;
if (Input.GetKey((KeyCode)32))
{
num2 += 1f;
}
if (Input.GetKey((KeyCode)306) || Input.GetKey((KeyCode)305))
{
num2 -= 1f;
}
transform.position += Vector3.up * (num2 * num * Time.deltaTime);
}
}
private static bool IsEmoteWheelHeld()
{
return Input.GetKey((KeyCode)114);
}
private KeyCode GetActiveRadialKey()
{
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
if (_radialMenuKind != RadialMenuKind.Camera)
{
return _holdPoseRadialKey.Value;
}
return _holdCameraRadialKey.Value;
}
private int GetRadialOptionCount()
{
if (_radialMenuKind != RadialMenuKind.Camera)
{
return 8;
}
return 3;
}
private string GetRadialLabel(int option)
{
if (_radialMenuKind == RadialMenuKind.Pose)
{
return option.ToString();
}
return option switch
{
0 => "FRONT\nCHASE",
1 => "FREE\nCAMERA",
_ => "CANCEL",
};
}
private void BeginRadial(RadialMenuKind menuKind)
{
//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_008a: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
_poseRadialActive = true;
_poseRadialClosing = false;
_radialMenuKind = menuKind;
_poseRadialHoveredPose = -1;
_poseRadialAnimationStartedAt = Time.unscaledTime;
_poseRadialPreviousCursorLockMode = Cursor.lockState;
_poseRadialPreviousCursorVisible = Cursor.visible;
_poseRadialPreviousWindowShowingCursor = (Object)(object)GUIManager.instance != (Object)null && GUIManager.instance.windowShowingCursor;
_poseRadialHasPreviousCursorPosition = Mouse.current != null;
_poseRadialPreviousCursorPosition = (_poseRadialHasPreviousCursorPosition ? ((InputControl<Vector2>)(object)((Pointer)Mouse.current).position).ReadValue() : Vector2.op_Implicit(Input.mousePosition));
_suppressPoseRadialCameraInputUntilFrame = Time.frameCount + 1;
EnsurePoseRadialUi();
ConfigureRadialUi();
ApplyPoseRadialAnchor();
SetPoseRadialUiVisible(visible: true);
MaintainPoseRadialCursor();
Mouse current = Mouse.current;
if (current != null)
{
current.WarpCursorPosition(GetPoseRadialCenter());
}
UpdatePoseRadialVisuals();
UpdatePoseRadialAnimation();
((BaseUnityPlugin)this).Logger.LogInfo((object)$"{_radialMenuKind} radial opened.");
}
private void UpdateRadial()
{
MaintainPoseRadialCursor();
UpdatePoseRadialAnimation();
int radialSlotAtMouse = GetRadialSlotAtMouse();
if (radialSlotAtMouse != _poseRadialHoveredPose)
{
_poseRadialHoveredPose = radialSlotAtMouse;
if (_radialMenuKind == RadialMenuKind.Pose && radialSlotAtMouse >= 0)
{
SelectIdlePose(radialSlotAtMouse);
}
}
UpdatePoseRadialVisuals();
}
private void BeginRadialClose()
{
if (_poseRadialActive)
{
if (_radialMenuKind == RadialMenuKind.Camera && _poseRadialHoveredPose >= 0)
{
CommitCameraRadialSelection(_poseRadialHoveredPose);
}
_poseRadialActive = false;
_poseRadialHoveredPose = -1;
_poseRadialClosing = true;
_poseRadialAnimationStartedAt = Time.unscaledTime;
RestorePoseRadialCursor();
((BaseUnityPlugin)this).Logger.LogInfo((object)$"{_radialMenuKind} radial closed.");
}
}
private void ClosePoseRadialImmediately()
{
if (_poseRadialActive || _poseRadialClosing)
{
_poseRadialActive = false;
_poseRadialClosing = false;
_poseRadialHoveredPose = -1;
SetPoseRadialUiVisible(visible: false);
RestorePoseRadialCursor();
}
}
private void UpdatePoseRadialAnimation()
{
//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)_poseRadialContainer == (Object)null || (Object)(object)_poseRadialCanvasGroup == (Object)null)
{
return;
}
if (_poseRadialClosing)
{
float num = Mathf.Clamp01((Time.unscaledTime - _poseRadialAnimationStartedAt) / 0.09f);
float num2 = Mathf.SmoothStep(0f, 1f, num);
((Transform)_poseRadialContainer).localScale = Vector3.one * Mathf.Lerp(1f, 0.7f, num2);
_poseRadialCanvasGroup.alpha = 1f - num2;
UpdatePoseRadialVisuals();
if (num >= 1f)
{
_poseRadialClosing = false;
SetPoseRadialUiVisible(visible: false);
}
}
else
{
float num3 = Mathf.Clamp01((Time.unscaledTime - _poseRadialAnimationStartedAt) / 0.12f);
float num4 = 1f - Mathf.Pow(1f - num3, 3f);
((Transform)_poseRadialContainer).localScale = Vector3.one * Mathf.Lerp(0.7f, 1f, num4);
_poseRadialCanvasGroup.alpha = num3;
}
}
private int GetRadialSlotAtMouse()
{
//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_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//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_0032: 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)
Vector2 poseRadialCenter = GetPoseRadialCenter();
Vector2 val = Vector2.op_Implicit(Input.mousePosition) - poseRadialCenter;
float magnitude = ((Vector2)(ref val)).magnitude;
if (magnitude < 84f || magnitude > 216f)
{
return -1;
}
float num = Mathf.Repeat(Mathf.Atan2(val.x, val.y) * 57.29578f + 360f, 360f);
int radialOptionCount = GetRadialOptionCount();
return Mathf.FloorToInt((Mathf.Repeat(num - GetRadialStartAngle() + 360f, 360f) + 180f / (float)radialOptionCount) / (360f / (float)radialOptionCount)) % radialOptionCount;
}
private Vector2 GetPoseRadialCenter()
{
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
return new Vector2((float)Screen.width * PoseRadialAnchor.x, (float)Screen.height * PoseRadialAnchor.y);
}
private void RestorePoseRadialCursor()
{
//IL_0043: 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)
Cursor.lockState = (CursorLockMode)0;
Cursor.visible = true;
if (_poseRadialHasPreviousCursorPosition)
{
Mouse current = Mouse.current;
if (current != null)
{
current.WarpCursorPosition(_poseRadialPreviousCursorPosition);
}
}
if ((Object)(object)GUIManager.instance != (Object)null)
{
SetGameWindowShowingCursor(_poseRadialPreviousWindowShowingCursor);
}
Cursor.lockState = _poseRadialPreviousCursorLockMode;
Cursor.visible = _poseRadialPreviousCursorVisible;
_suppressPoseRadialCameraInputUntilFrame = Time.frameCount + 2;
}
private void MaintainPoseRadialCursor()
{
if ((Object)(object)GUIManager.instance != (Object)null)
{
SetGameWindowShowingCursor(showing: true);
}
Cursor.lockState = (CursorLockMode)0;
Cursor.visible = true;
}
private static void SetGameWindowShowingCursor(bool showing)
{
if ((Object)(object)GUIManager.instance != (Object)null)
{
Traverse.Create((object)GUIManager.instance).Property<bool>("windowShowingCursor", (object[])null).Value = showing;
}
}
private void EnsurePoseRadialUi()
{
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Expected O, but got Unknown
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00ad: Expected O, but got Unknown
//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
//IL_0144: Unknown result type (might be due to invalid IL or missing references)
//IL_0149: Unknown result type (might be due to invalid IL or missing references)
//IL_0179: Unknown result type (might be due to invalid IL or missing references)
//IL_018e: Unknown result type (might be due to invalid IL or missing references)
//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
//IL_01ae: 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_0212: Unknown result type (might be due to invalid IL or missing references)
//IL_0217: Unknown result type (might be due to invalid IL or missing references)
//IL_0247: Unknown result type (might be due to invalid IL or missing references)
//IL_025c: Unknown result type (might be due to invalid IL or missing references)
//IL_0271: Unknown result type (might be due to invalid IL or missing references)
//IL_027c: 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_02c8: Unknown result type (might be due to invalid IL or missing references)
//IL_02cd: Unknown result type (might be due to invalid IL or missing references)
//IL_032b: 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_0355: Unknown result type (might be due to invalid IL or missing references)
//IL_035f: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)_poseRadialRoot != (Object)null)
{
return;
}
_poseRadialRoot = new GameObject("PeakUnlockedCamera_PoseRadial", new Type[2]
{
typeof(Canvas),
typeof(CanvasGroup)
});
Canvas component = _poseRadialRoot.GetComponent<Canvas>();
component.renderMode = (RenderMode)0;
component.sortingOrder = 4900;
_poseRadialCanvasGroup = _poseRadialRoot.GetComponent<CanvasGroup>();
_poseRadialCanvasGroup.blocksRaycasts = false;
_poseRadialCanvasGroup.interactable = false;
Object.DontDestroyOnLoad((Object)(object)_poseRadialRoot);
GameObject val = new GameObject("RadialContainer", new Type[1] { typeof(RectTransform) });
val.transform.SetParent(_poseRadialRoot.transform, false);
_poseRadialContainer = val.GetComponent<RectTransform>();
_poseRadialContainer.pivot = new Vector2(0.5f, 0.5f);
_poseRadialContainer.sizeDelta = Vector2.zero;
ApplyPoseRadialAnchor();
for (int i = 0; i < 8; i++)
{
GameObject val2 = new GameObject($"PoseSlice_{i}", new Type[3]
{
typeof(RectTransform),
typeof(CanvasRenderer),
typeof(Image)
});
val2.transform.SetParent((Transform)(object)_poseRadialContainer, false);
Image component2 = val2.GetComponent<Image>();
((Graphic)component2).raycastTarget = false;
RectTransform rectTransform = ((Graphic)component2).rectTransform;
rectTransform.anchorMin = new Vector2(0.5f, 0.5f);
rectTransform.anchorMax = new Vector2(0.5f, 0.5f);
rectTransform.pivot = new Vector2(0.5f, 0.5f);
rectTransform.anchoredPosition = Vector2.zero;
rectTransform.sizeDelta = new Vector2(480f, 480f);
_poseRadialSliceImages[i] = component2;
GameObject val3 = new GameObject($"PoseSliceOutline_{i}", new Type[3]
{
typeof(RectTransform),
typeof(CanvasRenderer),
typeof(Image)
});
val3.transform.SetParent((Transform)(object)_poseRadialContainer, false);
Image component3 = val3.GetComponent<Image>();
((Graphic)component3).raycastTarget = false;
RectTransform rectTransform2 = ((Graphic)component3).rectTransform;
rectTransform2.anchorMin = new Vector2(0.5f, 0.5f);
rectTransform2.anchorMax = new Vector2(0.5f, 0.5f);
rectTransform2.pivot = new Vector2(0.5f, 0.5f);
rectTransform2.anchoredPosition = Vector2.zero;
rectTransform2.sizeDelta = new Vector2(480f, 480f);
_poseRadialSliceOutlines[i] = component3;
GameObject val4 = new GameObject("Label", new Type[2]
{
typeof(RectTransform),
typeof(TextMeshProUGUI)
});
val4.transform.SetParent((Transform)(object)_poseRadialContainer, false);
TextMeshProUGUI component4 = val4.GetComponent<TextMeshProUGUI>();
TextMeshProUGUI peakFontSource = GetPeakFontSource();
if ((Object)(object)peakFontSource != (Object)null)
{
((TMP_Text)component4).font = ((TMP_Text)peakFontSource).font;
}
((TMP_Text)component4).alignment = (TextAlignmentOptions)514;
((Graphic)component4).raycastTarget = false;
RectTransform rectTransform3 = ((TMP_Text)component4).rectTransform;
rectTransform3.anchorMin = new Vector2(0.5f, 0.5f);
rectTransform3.anchorMax = new Vector2(0.5f, 0.5f);
rectTransform3.pivot = new Vector2(0.5f, 0.5f);
rectTransform3.anchoredPosition = Vector2.zero;
_poseRadialSliceLabels[i] = component4;
}
}
private void ConfigureRadialUi()
{
//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
int radialOptionCount = GetRadialOptionCount();
for (int i = 0; i < 8; i++)
{
bool flag = i < radialOptionCount;
Image val = _poseRadialSliceImages[i];
Image val2 = _poseRadialSliceOutlines[i];
TextMeshProUGUI val3 = _poseRadialSliceLabels[i];
if (!((Object)(object)val == (Object)null) && !((Object)(object)val2 == (Object)null) && !((Object)(object)val3 == (Object)null))
{
((Component)val).gameObject.SetActive(flag);
((Component)val2).gameObject.SetActive(flag);
((Component)val3).gameObject.SetActive(flag);
if (flag)
{
val.sprite = GetCachedRadialSprite(i, outlineOnly: false);
val2.sprite = GetCachedRadialSprite(i, outlineOnly: true);
((TMP_Text)val3).text = GetRadialLabel(i);
((TMP_Text)val3).fontSize = ((_radialMenuKind == RadialMenuKind.Camera) ? 22f : 28f);
((TMP_Text)val3).rectTransform.sizeDelta = ((_radialMenuKind == RadialMenuKind.Camera) ? new Vector2(128f, 64f) : new Vector2(52f, 52f));
}
}
}
}
private Sprite GetCachedRadialSprite(int option, bool outlineOnly)
{
Sprite[] array = ((_radialMenuKind != RadialMenuKind.Camera) ? (outlineOnly ? _poseRadialOutlineSprites : _poseRadialFillSprites) : (outlineOnly ? _cameraRadialOutlineSprites : _cameraRadialFillSprites));
if ((Object)(object)array[option] == (Object)null)
{
array[option] = CreateRadialSliceSprite(option, GetRadialOptionCount(), outlineOnly);
}
return array[option];
}
private void PrewarmRadialSpriteCache()
{
RadialMenuKind radialMenuKind = _radialMenuKind;
_radialMenuKind = RadialMenuKind.Pose;
for (int i = 0; i < 8; i++)
{
GetCachedRadialSprite(i, outlineOnly: false);
GetCachedRadialSprite(i, outlineOnly: true);
}
_radialMenuKind = RadialMenuKind.Camera;
for (int j = 0; j < 3; j++)
{
GetCachedRadialSprite(j, outlineOnly: false);
GetCachedRadialSprite(j, outlineOnly: true);
}
_radialMenuKind = radialMenuKind;
}
private static void DestroyRadialSpriteCache(Sprite?[] sprites)
{
foreach (Sprite val in sprites)
{
if (!((Object)(object)val == (Object)null))
{
Object.Destroy((Object)(object)val.texture);
Object.Destroy((Object)(object)val);
}
}
}
private Sprite CreateRadialSliceSprite(int slice, int optionCount, bool outlineOnly)
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Expected O, but got Unknown
//IL_017c: Unknown result type (might be due to invalid IL or missing references)
//IL_018b: Unknown result type (might be due to invalid IL or missing references)
//IL_0088: 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_012a: Unknown result type (might be due to invalid IL or missing references)
//IL_012f: Unknown result type (might be due to invalid IL or missing references)
Texture2D val = new Texture2D(480, 480, (TextureFormat)4, false);
((Texture)val).filterMode = (FilterMode)1;
((Texture)val).wrapMode = (TextureWrapMode)1;
Color32[] array = (Color32[])(object)new Color32[230400];
float num = 239.5f;
float num2 = 360f / (float)optionCount * 0.5f - 1.1f;
Vector2 val2 = default(Vector2);
for (int i = 0; i < 480; i++)
{
for (int j = 0; j < 480; j++)
{
((Vector2)(ref val2))..ctor((float)j - num, (float)i - num);
float magnitude = ((Vector2)(ref val2)).magnitude;
if (magnitude < 84f || magnitude > 216f)
{
continue;
}
float num3 = Mathf.Repeat(Mathf.Atan2(val2.x, val2.y) * 57.29578f + 360f, 360f);
float radialOptionAngle = GetRadialOptionAngle(slice, optionCount);
if (!(Mathf.Abs(Mathf.DeltaAngle(num3, radialOptionAngle)) > num2))
{
bool flag = magnitude < 85.2f || magnitude > 214.8f || Mathf.Abs(Mathf.Abs(Mathf.DeltaAngle(num3, radialOptionAngle)) - num2) < 0.8f;
if (!outlineOnly || flag)
{
array[i * 480 + j] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue);
}
}
}
}
val.SetPixels32(array);
val.Apply(false, true);
return Sprite.Create(val, new Rect(0f, 0f, 480f, 480f), new Vector2(0.5f, 0.5f));
}
private void SetPoseRadialUiVisible(bool visible)
{
if ((Object)(object)_poseRadialRoot != (Object)null)
{
_poseRadialRoot.SetActive(visible);
}
}
private void ApplyPoseRadialAnchor()
{
//IL_0015: 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)
if (!((Object)(object)_poseRadialContainer == (Object)null))
{
_poseRadialContainer.anchorMin = PoseRadialAnchor;
_poseRadialContainer.anchorMax = PoseRadialAnchor;
_poseRadialContainer.anchoredPosition = Vector2.zero;
}
}
private void UpdatePoseRadialVisuals()
{
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
//IL_0105: Unknown result type (might be due to invalid IL or missing references)
//IL_010a: Unknown result type (might be due to invalid IL or missing references)
//IL_010d: Unknown result type (might be due to invalid IL or missing references)
//IL_0125: Unknown result type (might be due to invalid IL or missing references)
//IL_012a: 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_0137: 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_0172: Unknown result type (might be due to invalid IL or missing references)
//IL_0177: Unknown result type (might be due to invalid IL or missing references)
//IL_017a: Unknown result type (might be due to invalid IL or missing references)
//IL_0192: Unknown result type (might be due to invalid IL or missing references)
//IL_0197: Unknown result type (might be due to invalid IL or missing references)
//IL_019e: Unknown result type (might be due to invalid IL or missing references)
//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
//IL_0209: Unknown result type (might be due to invalid IL or missing references)
//IL_0210: Unknown result type (might be due to invalid IL or missing references)
//IL_0215: Unknown result type (might be due to invalid IL or missing references)
//IL_0217: Unknown result type (might be due to invalid IL or missing references)
//IL_021c: Unknown result type (might be due to invalid IL or missing references)
//IL_022c: Unknown result type (might be due to invalid IL or missing references)
//IL_0231: Unknown result type (might be due to invalid IL or missing references)
//IL_0234: Unknown result type (might be due to invalid IL or missing references)
//IL_024c: Unknown result type (might be due to invalid IL or missing references)
//IL_0251: Unknown result type (might be due to invalid IL or missing references)
//IL_0258: Unknown result type (might be due to invalid IL or missing references)
//IL_025e: Unknown result type (might be due to invalid IL or missing references)
float num = 1f - Mathf.Exp(-20f * Time.unscaledDeltaTime);
int radialOptionCount = GetRadialOptionCount();
for (int i = 0; i < radialOptionCount; i++)
{
bool flag = i == _poseRadialHoveredPose;
Color color = (flag ? new Color(0.62f, 0.34f, 0.1f, 0.9f) : new Color(0.025f, 0.04f, 0.09f, 0.82f));
Color color2 = (flag ? new Color(1f, 0.55f, 0.1f, 1f) : new Color(0f, 0f, 0f, 0.12f));
float num2 = (flag ? 1.05f : 1f);
Vector2 radialOutwardDirection = GetRadialOutwardDirection(i, radialOptionCount);
Vector2 val = radialOutwardDirection * (flag ? 7f : 0f);
if ((Object)(object)_poseRadialSliceImages[i] != (Object)null)
{
Image val2 = _poseRadialSliceImages[i];
((Graphic)val2).color = color;
((Graphic)val2).rectTransform.anchoredPosition = Vector2.Lerp(((Graphic)val2).rectTransform.anchoredPosition, val, num);
((Transform)((Graphic)val2).rectTransform).localScale = Vector3.Lerp(((Transform)((Graphic)val2).rectTransform).localScale, Vector3.one * num2, num);
}
if ((Object)(object)_poseRadialSliceOutlines[i] != (Object)null)
{
Image val3 = _poseRadialSliceOutlines[i];
((Graphic)val3).color = color2;
((Graphic)val3).rectTransform.anchoredPosition = Vector2.Lerp(((Graphic)val3).rectTransform.anchoredPosition, val, num);
((Transform)((Graphic)val3).rectTransform).localScale = Vector3.Lerp(((Transform)((Graphic)val3).rectTransform).localScale, Vector3.one * num2, num);
}
if ((Object)(object)_poseRadialSliceLabels[i] != (Object)null)
{
TextMeshProUGUI val4 = _poseRadialSliceLabels[i];
((Graphic)val4).color = (flag ? new Color(1f, 0.88f, 0.66f, 1f) : new Color(1f, 0.78f, 0.42f, 0.92f));
Vector2 val5 = radialOutwardDirection * 150f + val;
((TMP_Text)val4).rectTransform.anchoredPosition = Vector2.Lerp(((TMP_Text)val4).rectTransform.anchoredPosition, val5, num);
((Transform)((TMP_Text)val4).rectTransform).localScale = Vector3.Lerp(((Transform)((TMP_Text)val4).rectTransform).localScale, Vector3.one * num2, num);
}
}
}
private float GetRadialStartAngle()
{
if (_radialMenuKind != RadialMenuKind.Camera)
{
return 0f;
}
return -60f;
}
private float GetRadialOptionAngle(int option, int optionCount)
{
return GetRadialStartAngle() + (float)option * (360f / (float)optionCount);
}
private Vector2 GetRadialOutwardDirection(int option, int optionCount)
{
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
float num = GetRadialOptionAngle(option, optionCount) * (MathF.PI / 180f);
return new Vector2(Mathf.Sin(num), Mathf.Cos(num));
}
private void SelectIdlePose(int pose)
{
_selectedIdlePose = Mathf.Clamp(pose, 0, 7);
_hasSelectedIdlePose = true;
if (!TryGetLocalCustomization(out CharacterCustomization customization) || !TryApplyIdlePose(customization))
{
((BaseUnityPlugin)this).Logger.LogWarning((object)$"Pose {_selectedIdlePose} was selected, but the local character is not ready yet.");
}
ShowStatus($"POSE: {_selectedIdlePose}");
}
internal bool TryForceSelectedIdlePose(CharacterCustomization customization)
{
if (!_hasSelectedIdlePose || !IsLocalCustomization(customization))
{
return true;
}
TryApplyIdlePose(customization);
return false;
}
private bool TryGetLocalCustomization(out CharacterCustomization customization)
{
customization = null;
if ((Object)(object)Character.localCharacter == (Object)null)
{
return false;
}
customization = ((Component)Character.localCharacter).GetComponent<CharacterCustomization>();
if ((Object)(object)customization == (Object)null)
{
customization = ((Component)Character.localCharacter).GetComponentInChildren<CharacterCustomization>(true);
}
return (Object)(object)customization != (Object)null;
}
private bool TryApplyIdlePose(CharacterCustomization customization)
{
PhotonView component = ((Component)customization).GetComponent<PhotonView>();
if ((Object)(object)component == (Object)null || !component.IsMine)
{
return false;
}
component.RPC("SetCharacterIdle_RPC", (RpcTarget)0, new object[1] { _selectedIdlePose });
((BaseUnityPlugin)this).Logger.LogInfo((object)$"Applied idle pose {_selectedIdlePose}.");
return true;
}
private static bool IsLocalCustomization(CharacterCustomization customization)
{
PhotonView component = ((Component)customization).GetComponent<PhotonView>();
if ((Object)(object)component != (Object)null)
{
return component.IsMine;
}
return false;
}
private void ShowStatus(string status)
{
_statusText = status;
_statusHideAt = Time.unscaledTime + 2f;
}
private void UpdateStatusOverlay()
{
if (Time.unscaledTime >= _statusHideAt || string.IsNullOrEmpty(_statusText))
{
if ((Object)(object)_statusOverlayText != (Object)null)
{
((Behaviour)_statusOverlayText).enabled = false;
}
return;
}
EnsureStatusOverlay();
if (!((Object)(object)_statusOverlayText == (Object)null))
{
((TMP_Text)_statusOverlayText).text = _statusText;
((Behaviour)_statusOverlayText).enabled = true;
}
}
private void EnsureStatusOverlay()
{
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Expected O, but got Unknown
//IL_009c: Unknown result type (might be due to invalid IL or missing references)
//IL_00a2: Expected O, but got Unknown
//IL_0110: Unknown result type (might be due to invalid IL or missing references)
//IL_013e: Unknown result type (might be due to invalid IL or missing references)
//IL_0149: Unknown result type (might be due to invalid IL or missing references)
//IL_0154: Unknown result type (might be due to invalid IL or missing references)
//IL_0169: Unknown result type (might be due to invalid IL or missing references)
//IL_017d: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)_statusOverlayText != (Object)null))
{
TextMeshProUGUI peakFontSource = GetPeakFontSource();
if (!((Object)(object)peakFontSource == (Object)null) && !((Object)(object)((TMP_Text)peakFontSource).font == (Object)null))
{
_statusOverlayRoot = new GameObject("PeakUnlockedCamera_StatusOverlay", new Type[1] { typeof(Canvas) });
Canvas component = _statusOverlayRoot.GetComponent<Canvas>();
component.renderMode = (RenderMode)0;
component.sortingOrder = 5000;
Object.DontDestroyOnLoad((Object)(object)_statusOverlayRoot);
GameObject val = new GameObject("StatusText", new Type[2]
{
typeof(RectTransform),
typeof(TextMeshProUGUI)
});
val.transform.SetParent(_statusOverlayRoot.transform, false);
_statusOverlayText = val.GetComponent<TextMeshProUGUI>();
((TMP_Text)_statusOverlayText).font = ((TMP_Text)peakFontSource).font;
((TMP_Text)_statusOverlayText).fontSize = 35f;
((TMP_Text)_statusOverlayText).alignment = (TextAlignmentOptions)260;
((Graphic)_statusOverlayText).color = new Color(1f, 0.55f, 0.1f, 1f);
((TMP_Text)_statusOverlayText).textWrappingMode = (TextWrappingModes)0;
((Graphic)_statusOverlayText).raycastTarget = false;
RectTransform rectTransform = ((TMP_Text)_statusOverlayText).rectTransform;
rectTransform.anchorMin = Vector2.one;
rectTransform.anchorMax = Vector2.one;
rectTransform.pivot = Vector2.one;
rectTransform.anchoredPosition = new Vector2(-20f, -20f);
rectTransform.sizeDelta = new Vector2(420f, 100f);
}
}
}
private static TextMeshProUGUI? GetPeakFontSource()
{
if ((Object)(object)GUIManager.instance == (Object)null)
{
return null;
}
string[] array = new string[3] { "interactPromptText", "interactNameText", "text" };
foreach (string text in array)
{
TextMeshProUGUI value = Traverse.Create((object)GUIManager.instance).Field<TextMeshProUGUI>(text).Value;
if ((Object)(object)value != (Object)null && (Object)(object)((TMP_Text)value).font != (Object)null)
{
return value;
}
}
return null;
}
private static bool TryGetCamera(MainCameraMovement cameraMovement, out Camera unityCamera)
{
unityCamera = null;
MainCamera instance = MainCamera.instance;
if ((Object)(object)instance == (Object)null)
{
return false;
}
unityCamera = ((Component)instance).GetComponent<Camera>();
return (Object)(object)unityCamera != (Object)null;
}
private void DisableLocalMovementAndLookActions()
{
RestoreDisabledInputActions();
if (!((Object)(object)Character.localCharacter == (Object)null))
{
TrackAndDisable(CharacterInput.action_move);
TrackAndDisable(CharacterInput.action_moveForward);
TrackAndDisable(CharacterInput.action_moveBackward);
TrackAndDisable(CharacterInput.action_moveLeft);
TrackAndDisable(CharacterInput.action_moveRight);
TrackAndDisable(CharacterInput.action_look);
TrackAndDisable(CharacterInput.action_jump);
TrackAndDisable(CharacterInput.action_crouch);
TrackAndDisable(CharacterInput.action_crouchToggle);
TrackAndDisable(CharacterInput.action_sprint);
TrackAndDisable(CharacterInput.action_sprintToggle);
}
}
private void TrackAndDisable(InputAction? action)
{
if (action != null && !_disabledInputActions.Exists((InputActionState state) => state.Action == action))
{
_disabledInputActions.Add(new InputActionState(action, action.enabled));
action.Disable();
}
}
private void RestoreDisabledInputActions()
{
foreach (InputActionState disabledInputAction in _disabledInputActions)
{
if (disabledInputAction.WasEnabled && disabledInputAction.Action != null)
{
disabledInputAction.Action.Enable();
}
}
_disabledInputActions.Clear();
}
private void ExitFreeCamera()
{
_freeCameraRequested = false;
_frontDistanceInitialized = false;
_frontOrbitInitialized = false;
RestoreDisabledInputActions();
}
private void ApplyHudVisibility()
{
if ((Object)(object)_hudRoot == (Object)null)
{
_hudRoot = GameObject.Find("Canvas_HUD");
}
if ((Object)(object)_hudRoot == (Object)null)
{
((BaseUnityPlugin)this).Logger.LogWarning((object)"HUD root Canvas_HUD was not found; HUD toggle will retry after a scene change.");
}
else if (_hudVisible)
{
RestoreHudChildren();
}
else
{
HideHudChildrenExceptEmoteWheel();
}
}
private void RestoreHudState()
{
RestoreHudChildren();
}
private void HideHudChildrenExceptEmoteWheel()
{
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: Expected O, but got Unknown
if ((Object)(object)_hudRoot == (Object)null || _hiddenHudChildren.Count > 0)
{
return;
}
GameObject val = (((Object)(object)GUIManager.instance == (Object)null) ? null : Traverse.Create((object)GUIManager.instance).Field<GameObject>("emoteWheel").Value);
Transform val2 = (((Object)(object)val == (Object)null) ? null : val.transform);
foreach (Transform item in _hudRoot.transform)
{
Transform val3 = item;
if (!((Object)(object)val2 != (Object)null) || (!((Object)(object)val3 == (Object)(object)val2) && !val2.IsChildOf(val3)))
{
_hiddenHudChildren.Add(new GameObjectActiveState(((Component)val3).gameObject, ((Component)val3).gameObject.activeSelf));
((Component)val3).gameObject.SetActive(false);
}
}
}
private void RestoreHudChildren()
{
foreach (GameObjectActiveState hiddenHudChild in _hiddenHudChildren)
{
if ((Object)(object)hiddenHudChild.GameObject != (Object)null)
{
hiddenHudChild.GameObject.SetActive(hiddenHudChild.WasActive);
}
}
_hiddenHudChildren.Clear();
}
}
[HarmonyPatch]
internal static class GamePatches
{
[HarmonyPostfix]
[HarmonyPatch(typeof(CharacterInput), "Sample")]
private static void CharacterInputSamplePostfix(CharacterInput __instance)
{
if (Plugin.Instance.ShouldSuppressLocalInteractInput(__instance))
{
__instance.interactIsPressed = false;
__instance.interactWasPressed = false;
__instance.interactWasReleased = false;
}
}
[HarmonyPrefix]
[HarmonyPatch(typeof(MainCameraMovement), "CharacterCam")]
private static bool MainCameraMovementCharacterCamPrefix()
{
return !Plugin.Instance.ShouldReplaceGameCharacterCamera();
}
[HarmonyPostfix]
[HarmonyPatch(typeof(MainCameraMovement), "LateUpdate")]
private static void MainCameraMovementLateUpdatePostfix(MainCameraMovement __instance)
{
Plugin.Instance.OnCameraLateUpdate(__instance);
}
[HarmonyPrefix]
[HarmonyPatch(typeof(CharacterMovement), "CameraLook")]
private static bool CharacterMovementCameraLookPrefix(CharacterMovement __instance)
{
return !Plugin.Instance.ShouldSuppressLocalCharacterMovement(__instance);
}
[HarmonyPostfix]
[HarmonyPatch(typeof(CharacterInput), "GetMovementInput")]
private static void CharacterInputGetMovementInputPostfix(CharacterInput __instance, ref Vector2 __result)
{
//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_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_0032: Unknown result type (might be due to invalid IL or missing references)
if (Plugin.Instance.ShouldSuppressLocalMovementInput(__instance))
{
__result = Vector2.zero;
}
else if (Plugin.Instance.ShouldInvertLocalMovementInput(__instance))
{
__result = -__result;
}
}
[HarmonyPrefix]
[HarmonyPatch(typeof(CharacterMovement), "TryToJump")]
private static bool CharacterMovementTryToJumpPrefix(CharacterMovement __instance)
{
return !Plugin.Instance.ShouldSuppressLocalCharacterAction(__instance);
}
[HarmonyPrefix]
[HarmonyPatch(typeof(CharacterMovement), "SetCrouch")]
private static bool CharacterMovementSetCrouchPrefix(CharacterMovement __instance)
{
return !Plugin.Instance.ShouldSuppressLocalCharacterAction(__instance);
}
[HarmonyPrefix]
[HarmonyPatch(typeof(CharacterCustomization), "SetRandomIdle")]
private static bool CharacterCustomizationSetRandomIdlePrefix(CharacterCustomization __instance)
{
return Plugin.Instance.TryForceSelectedIdlePose(__instance);
}
}
}