using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using On;
using UnityEngine;
using Zorro.ControllerSupport;
using Zorro.Settings;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyCompany("ThirdPersonToggle")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+528587b792585303fdd3652189cfb8b460ab5782")]
[assembly: AssemblyProduct("ThirdPersonToggle")]
[assembly: AssemblyTitle("ThirdPersonToggle")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace Evaisa.ThirdPersonToggle
{
[BepInPlugin("evaisa.ThirdPersonToggle", "ThirdPersonToggle", "1.0.10")]
public class ThirdPersonToggle : BaseUnityPlugin
{
public const string GUID = "evaisa.ThirdPersonToggle";
public const string ModName = "ThirdPersonToggle";
public const string Version = "1.0.10";
private ConfigEntry<KeyCode> toggleKey;
private bool thirdPersonEnabled;
private MouseSensitivitySetting mouseSensSetting;
private ControllerSensitivitySetting controllerSensSetting;
private bool settingsInitialized;
private readonly float height = 1.5f;
private readonly float defaultDistance = 3f;
private float currentDistance;
private readonly float minDistance = 2f;
private readonly float maxDistance = 4f;
private readonly float zoomSpeed = 1f;
private readonly float lerpRate = 5f;
private readonly float turnSpeed = 720f;
private readonly float clipRadius = 0.06f;
private readonly float clipBuffer = 0.03f;
private readonly LayerMask clipMask = LayerMask.op_Implicit(LayerMask.GetMask(new string[2] { "Terrain", "Map" }));
private void Awake()
{
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Expected O, but got Unknown
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Expected O, but got Unknown
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Expected O, but got Unknown
toggleKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Camera", "ToggleKey", (KeyCode)118, "Key to toggle third-person camera");
currentDistance = defaultDistance;
MainCameraMovement.LateUpdate += new hook_LateUpdate(MainCameraMovement_LateUpdate);
MainCameraMovement.CharacterCam += new hook_CharacterCam(MainCameraMovement_CharacterCam);
CharacterClimbing.TryToStartWallClimb += new hook_TryToStartWallClimb(CharacterClimbing_TryToStartWallClimb);
}
private void EnsureSettings()
{
if (!settingsInitialized && (Object)(object)GameHandler.Instance != (Object)null && GameHandler.Instance.SettingsHandler != null)
{
mouseSensSetting = GameHandler.Instance.SettingsHandler.GetSetting<MouseSensitivitySetting>();
controllerSensSetting = GameHandler.Instance.SettingsHandler.GetSetting<ControllerSensitivitySetting>();
settingsInitialized = true;
}
}
private void MainCameraMovement_LateUpdate(orig_LateUpdate orig, MainCameraMovement self)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
if (Input.GetKeyDown(toggleKey.Value))
{
thirdPersonEnabled = !thirdPersonEnabled;
}
if (thirdPersonEnabled)
{
float y = Input.mouseScrollDelta.y;
if (Mathf.Abs(y) > 0.01f)
{
currentDistance = Mathf.Clamp(currentDistance - y * zoomSpeed, minDistance, maxDistance);
}
}
orig.Invoke(self);
}
private void MainCameraMovement_CharacterCam(orig_CharacterCam orig, MainCameraMovement self)
{
//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_0060: 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_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_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_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_00b9: Unknown result type (might be due to invalid IL or missing references)
//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
//IL_00c4: 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_00d4: 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_00e6: 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_0122: Unknown result type (might be due to invalid IL or missing references)
//IL_0127: Unknown result type (might be due to invalid IL or missing references)
//IL_0135: Unknown result type (might be due to invalid IL or missing references)
//IL_0141: 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_015b: 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_010a: Unknown result type (might be due to invalid IL or missing references)
//IL_010f: Unknown result type (might be due to invalid IL or missing references)
//IL_0114: Unknown result type (might be due to invalid IL or missing references)
//IL_016c: Unknown result type (might be due to invalid IL or missing references)
//IL_0172: Invalid comparison between Unknown and I4
//IL_019a: Unknown result type (might be due to invalid IL or missing references)
//IL_019f: Unknown result type (might be due to invalid IL or missing references)
//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
if (thirdPersonEnabled && (Object)(object)Character.localCharacter != (Object)null)
{
EnsureSettings();
MainCamera component = ((Component)self).GetComponent<MainCamera>();
component.cam.fieldOfView = self.GetFov();
Transform transform = ((Component)Character.localCharacter.GetBodypart((BodypartType)2)).transform;
Vector3 val = Character.localCharacter.data.lookDirection;
if (val == Vector3.zero)
{
val = transform.forward;
}
Vector3 val2 = transform.position + Vector3.up * height - ((Vector3)(ref val)).normalized * currentDistance;
Vector3 val3 = val2 - transform.position;
Vector3 normalized = ((Vector3)(ref val3)).normalized;
float num = Vector3.Distance(val2, transform.position);
RaycastHit val4 = default(RaycastHit);
if (Physics.SphereCast(transform.position, clipRadius, normalized, ref val4, num, LayerMask.op_Implicit(clipMask)))
{
val2 = ((RaycastHit)(ref val4)).point - normalized * clipBuffer;
}
((Component)self).transform.position = Vector3.Lerp(((Component)self).transform.position, val2, Time.deltaTime * lerpRate);
Quaternion val5 = Quaternion.LookRotation(transform.position - ((Component)self).transform.position);
float num2 = ((!settingsInitialized) ? 1f : (((int)InputHandler.GetCurrentUsedInputScheme() == 1) ? ((FloatSetting)controllerSensSetting).Value : ((FloatSetting)mouseSensSetting).Value));
((Component)self).transform.rotation = Quaternion.RotateTowards(((Component)self).transform.rotation, val5, turnSpeed * num2 * Time.deltaTime);
}
else
{
orig.Invoke(self);
}
}
private void CharacterClimbing_TryToStartWallClimb(orig_TryToStartWallClimb orig, CharacterClimbing self, bool forceAttempt, Vector3 overide, bool botGrab)
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
Transform transform = ((Component)self.character.GetBodypart((BodypartType)2)).transform;
Transform transform2 = ((Component)MainCamera.instance).transform;
Vector3 position = transform2.position;
transform2.position = transform.position;
orig.Invoke(self, forceAttempt, overide, botGrab);
transform2.position = position;
}
}
public static class EnumerableExtensions
{
public static void ForEachTry<T>(this IEnumerable<T> list, Action<T> action, IDictionary<T, Exception> exceptions = null)
{
list.ToList().ForEach(delegate(T element)
{
try
{
action(element);
}
catch (Exception value)
{
exceptions?.Add(element, value);
}
});
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "ThirdPersonToggle";
public const string PLUGIN_NAME = "ThirdPersonToggle";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}