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 UnityEngine; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; [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("RepoThirdPerson")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("RepoThirdPerson")] [assembly: AssemblyTitle("RepoThirdPerson")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.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 RepoThirdPerson { [BepInPlugin("com.reponativemods.thirdperson", "REPO Native Third Person", "1.1.1")] public sealed class Plugin : BaseUnityPlugin { private struct ClipPlaneState { public float Near; public float Far; } private static class RepoUpdatePatches { [HarmonyPostfix] [HarmonyPatch(typeof(PlayerController), "Update")] private static void PlayerControllerUpdatePostfix() { Instance?.TickInput(); Instance?.TickCamera(); } [HarmonyPostfix] [HarmonyPatch(typeof(CameraPosition), "Update")] private static void CameraPositionUpdatePostfix() { Instance?.TickCamera(); } [HarmonyPostfix] [HarmonyPatch(typeof(PlayerLocalCamera), "GetOverrideTransform")] private static void PlayerLocalCameraGetOverrideTransformPostfix(PlayerLocalCamera __instance, ref Transform __result) { Instance?.TryGetSelectionOverride(__instance, ref __result); } } public const string PluginGuid = "com.reponativemods.thirdperson"; public const string PluginName = "REPO Native Third Person"; public const string PluginVersion = "1.1.1"; private const string SelectionTransformName = "REPO Native Third Person Selection Transform"; private const string ToggleActionName = "REPO Native Third Person Toggle"; private const string ZoomInActionName = "REPO Native Third Person Zoom In"; private const string ZoomOutActionName = "REPO Native Third Person Zoom Out"; private const string DefaultLayerName = "Default"; private const string GroundLayerName = "Ground"; private const string WallLayerName = "Wall"; private const string PlayerLayerName = "Player"; private const float InputDeadZone = 0.001f; private const float MinimumCameraCastDistance = 0.001f; private const float MinimumSelectionDirectionSqrMagnitude = 0.0001f; private const float MinimumConfiguredDistance = 0.1f; private const float CameraPositionOverrideDuration = 0.1f; private const float ShowSelfOverrideDuration = 0.15f; private ConfigEntry _toggleKey; private ConfigEntry _zoomInKey; private ConfigEntry _zoomOutKey; private ConfigEntry _resetOffsetsKey; private ConfigEntry _scrollSensitivity; private ConfigEntry _keyZoomSpeed; private ConfigEntry _offsetAdjustSpeed; private ConfigEntry _offsetX; private ConfigEntry _offsetY; private ConfigEntry _defaultDistance; private ConfigEntry _minDistance; private ConfigEntry _maxDistance; private ConfigEntry _collisionRadius; private ConfigEntry _collisionPadding; private ConfigEntry _minimumFarClipPlane; private ConfigEntry _nearClipPlane; private ConfigEntry _cameraCenteredSelection; private ConfigEntry _selectionMaxDistance; private readonly Dictionary _originalClipPlanes = new Dictionary(); private readonly List _cameraBuffer = new List(16); private bool _thirdPersonActive; private float _currentDistance; private int _collisionMask; private InputAction _toggleAction; private InputAction _zoomInAction; private InputAction _zoomOutAction; private Harmony _harmony; private Transform _selectionTransform; private int _lastInputTickFrame = -1; private int _lastCameraTickFrame = -1; private bool _temporarilyFirstPerson; private float _startingOffsetX; private float _startingOffsetY; private float _runtimeOffsetX; private float _runtimeOffsetY; internal static Plugin Instance { get; private set; } private void Awake() { //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Expected O, but got Unknown //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Expected O, but got Unknown //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Expected O, but got Unknown //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Expected O, but got Unknown //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Expected O, but got Unknown //IL_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Expected O, but got Unknown //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Expected O, but got Unknown //IL_027f: Unknown result type (might be due to invalid IL or missing references) //IL_0289: Expected O, but got Unknown //IL_032c: Unknown result type (might be due to invalid IL or missing references) //IL_0336: Expected O, but got Unknown //IL_036a: Unknown result type (might be due to invalid IL or missing references) //IL_0374: Expected O, but got Unknown //IL_03a8: Unknown result type (might be due to invalid IL or missing references) //IL_03b2: Expected O, but got Unknown //IL_044d: Unknown result type (might be due to invalid IL or missing references) //IL_0457: Expected O, but got Unknown //IL_047d: Unknown result type (might be due to invalid IL or missing references) //IL_048d: Unknown result type (might be due to invalid IL or missing references) //IL_049d: Unknown result type (might be due to invalid IL or missing references) Instance = this; KeepAliveOutsideScene(((Component)this).gameObject); _toggleKey = ((BaseUnityPlugin)this).Config.Bind("General", "ToggleKey", (KeyCode)120, "Key to toggle third-person mode."); _offsetX = ((BaseUnityPlugin)this).Config.Bind("Camera", "OffsetX", 0.5f, "Horizontal shoulder offset."); _offsetY = ((BaseUnityPlugin)this).Config.Bind("Camera", "OffsetY", 1.6f, "Vertical offset from the local player origin."); _defaultDistance = ((BaseUnityPlugin)this).Config.Bind("Camera", "DefaultDistance", 3f, new ConfigDescription("Default distance behind the player.", (AcceptableValueBase)(object)new AcceptableValueRange(0.25f, 25f), Array.Empty())); _minDistance = ((BaseUnityPlugin)this).Config.Bind("Camera", "MinDistance", 1f, new ConfigDescription("Minimum zoom distance.", (AcceptableValueBase)(object)new AcceptableValueRange(0.1f, 25f), Array.Empty())); _maxDistance = ((BaseUnityPlugin)this).Config.Bind("Camera", "MaxDistance", 10f, new ConfigDescription("Maximum zoom distance.", (AcceptableValueBase)(object)new AcceptableValueRange(0.25f, 50f), Array.Empty())); _collisionRadius = ((BaseUnityPlugin)this).Config.Bind("Camera", "CollisionRadius", 0.25f, new ConfigDescription("Spherecast radius used to keep the camera out of walls.", (AcceptableValueBase)(object)new AcceptableValueRange(0.01f, 2f), Array.Empty())); _collisionPadding = ((BaseUnityPlugin)this).Config.Bind("Camera", "CollisionPadding", 0.15f, new ConfigDescription("Distance kept between the camera and collision surfaces.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 2f), Array.Empty())); _nearClipPlane = ((BaseUnityPlugin)this).Config.Bind("Camera", "NearClipPlane", 0.03f, new ConfigDescription("Near clip plane while third-person is active. Lower values reduce close zoom clipping.", (AcceptableValueBase)(object)new AcceptableValueRange(0.01f, 1f), Array.Empty())); _minimumFarClipPlane = ((BaseUnityPlugin)this).Config.Bind("Camera", "MinimumFarClipPlane", 1000f, new ConfigDescription("Minimum far clip plane while third-person is active. The mod also preserves any larger original far clip value.", (AcceptableValueBase)(object)new AcceptableValueRange(100f, 100000f), Array.Empty())); _cameraCenteredSelection = ((BaseUnityPlugin)this).Config.Bind("Interaction", "CameraCenteredSelection", true, "Aim selection/grabbing at the object centered by the third-person camera while keeping the origin at the player vision transform."); _selectionMaxDistance = ((BaseUnityPlugin)this).Config.Bind("Interaction", "SelectionMaxDistance", 100f, new ConfigDescription("Maximum distance used when converting the third-person camera center ray into a player-origin selection ray.", (AcceptableValueBase)(object)new AcceptableValueRange(10f, 500f), Array.Empty())); _zoomInKey = ((BaseUnityPlugin)this).Config.Bind("Controls", "ZoomInKey", (KeyCode)270, "Key to zoom in."); _zoomOutKey = ((BaseUnityPlugin)this).Config.Bind("Controls", "ZoomOutKey", (KeyCode)269, "Key to zoom out."); _resetOffsetsKey = ((BaseUnityPlugin)this).Config.Bind("Controls", "ResetOffsetsKey", (KeyCode)278, "Key to reset runtime camera offsets to the loaded config values."); _scrollSensitivity = ((BaseUnityPlugin)this).Config.Bind("Controls", "ScrollSensitivity", 1f, new ConfigDescription("Mouse wheel zoom sensitivity.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 10f), Array.Empty())); _keyZoomSpeed = ((BaseUnityPlugin)this).Config.Bind("Controls", "KeyZoomSpeed", 5f, new ConfigDescription("Zoom speed when using zoom keys.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 50f), Array.Empty())); _offsetAdjustSpeed = ((BaseUnityPlugin)this).Config.Bind("Controls", "OffsetAdjustSpeed", 1f, new ConfigDescription("Offset adjustment speed when holding arrow keys, in world units per second.", (AcceptableValueBase)(object)new AcceptableValueRange(0.05f, 10f), Array.Empty())); _currentDistance = ClampDistance(_defaultDistance.Value); _startingOffsetX = _offsetX.Value; _startingOffsetY = _offsetY.Value; _runtimeOffsetX = _startingOffsetX; _runtimeOffsetY = _startingOffsetY; _collisionMask = LayerMask.GetMask(new string[3] { "Default", "Ground", "Wall" }); _selectionTransform = CreatePersistentTransform("REPO Native Third Person Selection Transform"); CreateInputActions(); _harmony = new Harmony("com.reponativemods.thirdperson"); _harmony.PatchAll(typeof(RepoUpdatePatches)); ((BaseUnityPlugin)this).Logger.LogInfo((object)$"Loaded. ToggleKey={_toggleKey.Value}, ZoomInKey={_zoomInKey.Value}, ZoomOutKey={_zoomOutKey.Value}"); } private static Transform CreatePersistentTransform(string objectName) { //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_000c: Expected O, but got Unknown GameObject val = new GameObject(objectName); KeepAliveOutsideScene(val); return val.transform; } private static void KeepAliveOutsideScene(GameObject owner) { if (Object.op_Implicit((Object)(object)owner)) { owner.transform.SetParent((Transform)null, true); ((Object)owner).hideFlags = (HideFlags)61; Object.DontDestroyOnLoad((Object)(object)owner); } } private void Update() { TickInput(); } internal void TickInput() { //IL_002c: Unknown result type (might be due to invalid IL or missing references) if (_lastInputTickFrame != Time.frameCount) { _lastInputTickFrame = Time.frameCount; if (IsActionPressedThisFrame(_toggleAction) || IsKeyPressedThisFrame(_toggleKey.Value)) { SetThirdPersonActive(!_thirdPersonActive); } if (_thirdPersonActive) { HandleZoomInput(); HandleOffsetInput(); } } } private void LateUpdate() { TickCamera(); } internal void TickCamera() { //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_0072: 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_007e: 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_0087: 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) if (_lastCameraTickFrame == Time.frameCount) { return; } _lastCameraTickFrame = Time.frameCount; if (!_thirdPersonActive) { return; } PlayerAvatar instance = PlayerAvatar.instance; CameraAim instance2 = CameraAim.Instance; CameraPosition instance3 = CameraPosition.instance; if (!Object.op_Implicit((Object)(object)instance) || !Object.op_Implicit((Object)(object)instance2) || !Object.op_Implicit((Object)(object)instance3)) { return; } if (ShouldTemporarilyUseFirstPerson()) { EnterTemporaryFirstPerson(instance3, instance); return; } _temporarilyFirstPerson = false; Vector3 val = CalculateCameraPosition(instance, ((Component)instance2).transform); Ray thirdPersonCenterRay = GetThirdPersonCenterRay(val, ((Component)instance2).transform.rotation); UpdateSelectionTransform(instance, thirdPersonCenterRay); instance3.OverridePosition(val, 0.1f); if (Object.op_Implicit((Object)(object)instance.playerAvatarVisuals)) { instance.playerAvatarVisuals.ShowSelfOverride(0.15f); } ApplyClipPlanes(); } private void OnDisable() { SetThirdPersonActive(active: false); } private void OnDestroy() { SetThirdPersonActive(active: false); Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } _harmony = null; DisposeInputActions(); if (Object.op_Implicit((Object)(object)_selectionTransform)) { Object.Destroy((Object)(object)((Component)_selectionTransform).gameObject); _selectionTransform = null; } if ((Object)(object)Instance == (Object)(object)this) { Instance = null; } } private void SetThirdPersonActive(bool active) { //IL_005e: Unknown result type (might be due to invalid IL or missing references) if (_thirdPersonActive == active) { return; } _thirdPersonActive = active; if (active) { _currentDistance = ClampDistance(_defaultDistance.Value); ApplyClipPlanes(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Third-person camera enabled."); return; } CameraPosition instance = CameraPosition.instance; if (Object.op_Implicit((Object)(object)instance) && Object.op_Implicit((Object)(object)instance.playerTransform)) { instance.OverridePosition(Vector3.zero, 0f); } PlayerAvatar instance2 = PlayerAvatar.instance; if (Object.op_Implicit((Object)(object)instance2) && Object.op_Implicit((Object)(object)instance2.playerAvatarVisuals)) { instance2.playerAvatarVisuals.ShowSelfOverride(0f); } RestoreClipPlanes(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Third-person camera disabled."); } private static bool ShouldTemporarilyUseFirstPerson() { if (Object.op_Implicit((Object)(object)Map.Instance)) { return Map.Instance.Active; } return false; } private void EnterTemporaryFirstPerson(CameraPosition cameraPosition, PlayerAvatar avatar) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) if (!_temporarilyFirstPerson) { _temporarilyFirstPerson = true; ((BaseUnityPlugin)this).Logger.LogInfo((object)"Map/tablet active; temporarily using first-person camera."); } if (Object.op_Implicit((Object)(object)cameraPosition) && Object.op_Implicit((Object)(object)cameraPosition.playerTransform)) { cameraPosition.OverridePosition(Vector3.zero, 0f); } if (Object.op_Implicit((Object)(object)avatar) && Object.op_Implicit((Object)(object)avatar.playerAvatarVisuals)) { avatar.playerAvatarVisuals.ShowSelfOverride(0f); } } private void HandleZoomInput() { //IL_0048: 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) if (CanAcceptZoomInput()) { float num = ReadScrollWheel(); if (Mathf.Abs(num) > 0.001f) { _currentDistance -= num * _scrollSensitivity.Value; } if (IsActionHeld(_zoomInAction) || IsKeyHeld(_zoomInKey.Value)) { _currentDistance -= _keyZoomSpeed.Value * Time.deltaTime; } if (IsActionHeld(_zoomOutAction) || IsKeyHeld(_zoomOutKey.Value)) { _currentDistance += _keyZoomSpeed.Value * Time.deltaTime; } _currentDistance = ClampDistance(_currentDistance); } } private void HandleOffsetInput() { //IL_000e: Unknown result type (might be due to invalid IL or missing references) if (!CanAcceptOffsetInput()) { return; } if (IsKeyPressedThisFrame(_resetOffsetsKey.Value)) { _runtimeOffsetX = _startingOffsetX; _runtimeOffsetY = _startingOffsetY; ((BaseUnityPlugin)this).Logger.LogInfo((object)$"Camera offsets reset to X={_runtimeOffsetX:0.###}, Y={_runtimeOffsetY:0.###}."); return; } float num = _offsetAdjustSpeed.Value * Time.deltaTime; if (!(num <= 0f)) { if (IsKeyHeld((KeyCode)276)) { _runtimeOffsetX -= num; } if (IsKeyHeld((KeyCode)275)) { _runtimeOffsetX += num; } if (IsKeyHeld((KeyCode)273)) { _runtimeOffsetY += num; } if (IsKeyHeld((KeyCode)274)) { _runtimeOffsetY -= num; } } } private static bool CanAcceptZoomInput() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Invalid comparison between Unknown and I4 if (!Object.op_Implicit((Object)(object)GameDirector.instance) || (int)GameDirector.instance.currentState != 2) { return false; } if (SemiFunc.MenuLevel() || !SemiFunc.NoTextInputsActive()) { return false; } if (Object.op_Implicit((Object)(object)Map.Instance) && Map.Instance.Active) { return false; } if (Object.op_Implicit((Object)(object)PhysGrabber.instance) && PhysGrabber.instance.grabbed) { return false; } if (Object.op_Implicit((Object)(object)PlayerController.instance) && PlayerController.instance.physGrabActive) { return false; } return true; } private static bool CanAcceptOffsetInput() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Invalid comparison between Unknown and I4 if (!Object.op_Implicit((Object)(object)GameDirector.instance) || (int)GameDirector.instance.currentState != 2) { return false; } if (SemiFunc.MenuLevel() || !SemiFunc.NoTextInputsActive()) { return false; } if (Object.op_Implicit((Object)(object)Map.Instance)) { return !Map.Instance.Active; } return true; } private Vector3 CalculateCameraPosition(PlayerAvatar avatar, Transform aimTransform) { //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_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_0021: 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_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0037: 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_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: 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_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_008d: 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_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: 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_00cf: Unknown result type (might be due to invalid IL or missing references) Vector3 val = ((Component)avatar).transform.position + Vector3.up * _runtimeOffsetY + aimTransform.right * _runtimeOffsetX; Vector3 val2 = val - aimTransform.forward * _currentDistance; Vector3 val3 = val2 - val; float magnitude = ((Vector3)(ref val3)).magnitude; if (magnitude <= 0.001f) { return val; } val3 /= magnitude; int num = ((_collisionMask != 0) ? _collisionMask : LayerMask.op_Implicit(SemiFunc.LayerMaskGetVisionObstruct())); RaycastHit val4 = default(RaycastHit); if (Physics.SphereCast(val, _collisionRadius.Value, val3, ref val4, magnitude, num, (QueryTriggerInteraction)1)) { float num2 = Mathf.Max(0f, ((RaycastHit)(ref val4)).distance - _collisionPadding.Value); return val + val3 * num2; } return val2; } private static Ray GetThirdPersonCenterRay(Vector3 origin, Quaternion fallbackRotation) { //IL_0037: 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_0043: 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_0029: 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_0031: Unknown result type (might be due to invalid IL or missing references) Camera main = Camera.main; if (Object.op_Implicit((Object)(object)main)) { Ray val = main.ViewportPointToRay(new Vector3(0.5f, 0.5f, 0f)); return new Ray(origin, ((Ray)(ref val)).direction); } return new Ray(origin, fallbackRotation * Vector3.forward); } private void UpdateSelectionTransform(PlayerAvatar avatar, Ray cameraCenterRay) { //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0037: 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_004c: 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_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006d: 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_007e: 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_0088: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: 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_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: 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_00f4: 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_0107: 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_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)_selectionTransform) && Object.op_Implicit((Object)(object)avatar)) { Transform val = avatar.PlayerVisionTarget?.VisionTransform; Vector3 val2 = (Object.op_Implicit((Object)(object)val) ? val.position : (((Component)avatar).transform.position + Vector3.up * _runtimeOffsetY)); Vector3 direction = ((Ray)(ref cameraCenterRay)).direction; Vector3 normalized = ((Vector3)(ref direction)).normalized; Vector3 val3 = ((Ray)(ref cameraCenterRay)).origin + normalized * _selectionMaxDistance.Value; int mask = LayerMask.GetMask(new string[1] { "Player" }); int num = LayerMask.op_Implicit(SemiFunc.LayerMaskGetVisionObstruct()) - mask; RaycastHit val4 = default(RaycastHit); if (Physics.Raycast(((Ray)(ref cameraCenterRay)).origin, normalized, ref val4, _selectionMaxDistance.Value, num, (QueryTriggerInteraction)1)) { val3 = ((RaycastHit)(ref val4)).point; } Vector3 val5 = val3 - val2; if (((Vector3)(ref val5)).sqrMagnitude < 0.0001f) { val5 = normalized; } _selectionTransform.position = val2; _selectionTransform.rotation = Quaternion.LookRotation(((Vector3)(ref val5)).normalized, Vector3.up); } } internal bool TryGetSelectionOverride(PlayerLocalCamera localCamera, ref Transform result) { if (!CanOverrideSelection(localCamera)) { return false; } result = _selectionTransform; return true; } private bool CanOverrideSelection(PlayerLocalCamera localCamera) { if (!_thirdPersonActive || !_cameraCenteredSelection.Value || _temporarilyFirstPerson) { return false; } if (!Object.op_Implicit((Object)(object)_selectionTransform) || !Object.op_Implicit((Object)(object)localCamera)) { return false; } return (Object)(object)localCamera.playerAvatar == (Object)(object)PlayerAvatar.instance; } private float ClampDistance(float distance) { float num = Mathf.Max(0.1f, _minDistance?.Value ?? 1f); float num2 = Mathf.Max(num, _maxDistance?.Value ?? 10f); return Mathf.Clamp(distance, num, num2); } private void ApplyClipPlanes() { CollectCameras(); foreach (Camera item in _cameraBuffer) { if (Object.op_Implicit((Object)(object)item)) { if (!_originalClipPlanes.ContainsKey(item)) { _originalClipPlanes.Add(item, new ClipPlaneState { Near = item.nearClipPlane, Far = item.farClipPlane }); } ClipPlaneState clipPlaneState = _originalClipPlanes[item]; item.nearClipPlane = Mathf.Min(clipPlaneState.Near, _nearClipPlane.Value); item.farClipPlane = Mathf.Max(clipPlaneState.Far, _minimumFarClipPlane.Value); } } } private void RestoreClipPlanes() { foreach (KeyValuePair originalClipPlane in _originalClipPlanes) { Camera key = originalClipPlane.Key; if (Object.op_Implicit((Object)(object)key)) { key.nearClipPlane = originalClipPlane.Value.Near; key.farClipPlane = originalClipPlane.Value.Far; } } _originalClipPlanes.Clear(); _cameraBuffer.Clear(); } private void CollectCameras() { _cameraBuffer.Clear(); AddCamera(Camera.main); Camera[] allCameras = Camera.allCameras; for (int i = 0; i < allCameras.Length; i++) { AddCamera(allCameras[i]); } CameraZoom instance = CameraZoom.Instance; if (instance?.cams == null) { return; } foreach (Camera cam in instance.cams) { AddCamera(cam); } } private void AddCamera(Camera cam) { if (Object.op_Implicit((Object)(object)cam) && !cam.orthographic && !_cameraBuffer.Contains(cam)) { _cameraBuffer.Add(cam); } } private void CreateInputActions() { //IL_0012: 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_0048: Unknown result type (might be due to invalid IL or missing references) DisposeInputActions(); _toggleAction = CreateKeyboardAction("REPO Native Third Person Toggle", _toggleKey.Value); _zoomInAction = CreateKeyboardAction("REPO Native Third Person Zoom In", _zoomInKey.Value); _zoomOutAction = CreateKeyboardAction("REPO Native Third Person Zoom Out", _zoomOutKey.Value); } private static InputAction CreateKeyboardAction(string name, KeyCode keyCode) { //IL_0000: 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_0023: Expected O, but got Unknown string text = KeyCodeToKeyboardPath(keyCode); if (string.IsNullOrEmpty(text)) { return null; } InputAction val = new InputAction(name, (InputActionType)1, text, (string)null, (string)null, (string)null); val.Enable(); return val; } private void DisposeInputActions() { DisposeInputAction(ref _toggleAction); DisposeInputAction(ref _zoomInAction); DisposeInputAction(ref _zoomOutAction); } private static void DisposeInputAction(ref InputAction action) { if (action != null) { action.Disable(); action.Dispose(); action = null; } } private static bool IsActionPressedThisFrame(InputAction action) { if (action != null && action.enabled) { return action.WasPressedThisFrame(); } return false; } private static bool IsActionHeld(InputAction action) { if (action != null && action.enabled) { return action.IsPressed(); } return false; } private static bool IsKeyPressedThisFrame(KeyCode key) { //IL_0000: 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_0016: Unknown result type (might be due to invalid IL or missing references) if (TryGetKeyboardKey(key, out var key2) && Keyboard.current != null && ((ButtonControl)Keyboard.current[key2]).wasPressedThisFrame) { return true; } try { return Input.GetKeyDown(key); } catch { return false; } } private static bool IsKeyHeld(KeyCode key) { //IL_0000: 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_0016: Unknown result type (might be due to invalid IL or missing references) if (TryGetKeyboardKey(key, out var key2) && Keyboard.current != null && ((ButtonControl)Keyboard.current[key2]).isPressed) { return true; } try { return Input.GetKey(key); } catch { return false; } } private static float ReadScrollWheel() { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)InputManager.instance)) { float scrollY = InputManager.instance.GetScrollY(); if (Mathf.Abs(scrollY) > 0.001f) { return Mathf.Sign(scrollY); } } if (Mouse.current != null) { float y = ((InputControl)(object)Mouse.current.scroll).ReadValue().y; if (Mathf.Abs(y) > 0.001f) { return Mathf.Sign(y); } } try { return Input.mouseScrollDelta.y; } catch { return 0f; } } private static bool TryGetKeyboardKey(KeyCode keyCode, out Key key) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Invalid comparison between Unknown and I4 //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Invalid comparison between Unknown and I4 //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Invalid comparison between Unknown and I4 //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Invalid comparison between Unknown and I4 //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Invalid comparison between Unknown and I4 //IL_0010: 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_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected I4, but got Unknown //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Invalid comparison between Unknown and I4 //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Invalid comparison between Unknown and I4 //IL_0025: 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_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected I4, but got Unknown //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Invalid comparison between Unknown and I4 //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Invalid comparison between Unknown and I4 //IL_0040: 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_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Expected I4, but got Unknown //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Invalid comparison between Unknown and I4 //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Invalid comparison between Unknown and I4 //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Invalid comparison between Unknown and I4 //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Invalid comparison between Unknown and I4 //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Invalid comparison between Unknown and I4 //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Invalid comparison between Unknown and I4 //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Invalid comparison between Unknown and I4 //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Invalid comparison between Unknown and I4 //IL_00b0: 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_0168: Expected I4, but got Unknown //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Invalid comparison between Unknown and I4 //IL_021b: 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_0222: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Expected I4, but got Unknown key = (Key)0; if ((int)keyCode >= 97 && (int)keyCode <= 122) { key = (Key)(15 + (keyCode - 97)); return true; } if ((int)keyCode >= 48 && (int)keyCode <= 57) { key = (Key)(50 + (keyCode - 48)); return true; } if ((int)keyCode >= 256 && (int)keyCode <= 265) { key = (Key)(84 + (keyCode - 256)); return true; } if ((int)keyCode <= 32) { if ((int)keyCode <= 9) { if ((int)keyCode == 8) { key = (Key)65; return true; } if ((int)keyCode == 9) { key = (Key)3; return true; } } else { if ((int)keyCode == 13) { key = (Key)2; return true; } if ((int)keyCode == 27) { key = (Key)60; return true; } if ((int)keyCode == 32) { key = (Key)1; return true; } } } else if ((int)keyCode <= 45) { if ((int)keyCode == 43) { goto IL_0212; } if ((int)keyCode == 45) { key = (Key)13; return true; } } else { if ((int)keyCode == 61) { goto IL_0212; } if ((int)keyCode == 127) { key = (Key)71; return true; } switch (keyCode - 266) { case 11: key = (Key)70; return true; case 12: key = (Key)68; return true; case 13: key = (Key)69; return true; case 14: key = (Key)67; return true; case 15: key = (Key)66; return true; case 38: key = (Key)51; return true; case 37: key = (Key)52; return true; case 40: key = (Key)55; return true; case 39: key = (Key)56; return true; case 42: key = (Key)53; return true; case 41: key = (Key)54; return true; case 7: key = (Key)63; return true; case 8: key = (Key)64; return true; case 10: key = (Key)61; return true; case 9: key = (Key)62; return true; case 4: key = (Key)80; return true; case 3: key = (Key)81; return true; case 5: key = (Key)77; return true; case 0: key = (Key)82; return true; case 1: key = (Key)78; return true; case 2: key = (Key)79; return true; case 16: case 17: case 18: case 19: case 20: case 21: case 22: case 23: case 24: case 25: case 26: case 27: key = (Key)(94 + (keyCode - 282)); return true; } } return false; IL_0212: key = (Key)14; return true; } private static string KeyCodeToKeyboardPath(KeyCode keyCode) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Invalid comparison between Unknown and I4 //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Invalid comparison between Unknown and I4 //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Invalid comparison between Unknown and I4 //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Invalid comparison between Unknown and I4 //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Invalid comparison between Unknown and I4 //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_0010: 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_0070: Invalid comparison between Unknown and I4 //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Invalid comparison between Unknown and I4 //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected I4, but got Unknown //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Invalid comparison between Unknown and I4 //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Invalid comparison between Unknown and I4 //IL_0054: 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_005c: Expected I4, but got Unknown //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Invalid comparison between Unknown and I4 //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Invalid comparison between Unknown and I4 //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Invalid comparison between Unknown and I4 //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Invalid comparison between Unknown and I4 //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Invalid comparison between Unknown and I4 //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Invalid comparison between Unknown and I4 //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Invalid comparison between Unknown and I4 //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Invalid comparison between Unknown and I4 //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Expected I4, but got Unknown //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Invalid comparison between Unknown and I4 //IL_0243: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Expected I4, but got Unknown if ((int)keyCode >= 97 && (int)keyCode <= 122) { char c = (char)(97 + keyCode - 97); return $"/{c}"; } if ((int)keyCode >= 48 && (int)keyCode <= 57) { int num = keyCode - 48; return $"/{num}"; } if ((int)keyCode >= 256 && (int)keyCode <= 265) { int num2 = keyCode - 256; return $"/numpad{num2}"; } if ((int)keyCode <= 32) { if ((int)keyCode <= 9) { if ((int)keyCode == 8) { return "/backspace"; } if ((int)keyCode == 9) { return "/tab"; } } else { if ((int)keyCode == 13) { return "/enter"; } if ((int)keyCode == 27) { return "/escape"; } if ((int)keyCode == 32) { return "/space"; } } } else if ((int)keyCode <= 45) { if ((int)keyCode == 43) { goto IL_0237; } if ((int)keyCode == 45) { return "/minus"; } } else { if ((int)keyCode == 61) { goto IL_0237; } if ((int)keyCode == 127) { return "/delete"; } switch (keyCode - 266) { case 11: return "/insert"; case 12: return "/home"; case 13: return "/end"; case 14: return "/pageUp"; case 15: return "/pageDown"; case 38: return "/leftShift"; case 37: return "/rightShift"; case 40: return "/leftCtrl"; case 39: return "/rightCtrl"; case 42: return "/leftAlt"; case 41: return "/rightAlt"; case 7: return "/upArrow"; case 8: return "/downArrow"; case 10: return "/leftArrow"; case 9: return "/rightArrow"; case 4: return "/numpadPlus"; case 3: return "/numpadMinus"; case 5: return "/numpadEnter"; case 0: return "/numpadPeriod"; case 1: return "/numpadDivide"; case 2: return "/numpadMultiply"; case 16: case 17: case 18: case 19: case 20: case 21: case 22: case 23: case 24: case 25: case 26: case 27: return $"/f{1 + keyCode - 282}"; } } return null; IL_0237: return "/equals"; } } }