using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using Microsoft.CodeAnalysis;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Omniscye")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("EmpressThirdPerson")]
[assembly: AssemblyTitle("EmpressThirdPerson")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[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.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]
[Microsoft.CodeAnalysis.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]
[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;
}
}
}
[BepInPlugin("com.empress.thirdperson", "Empress Third Person", "1.7.0")]
public class EmpressThirdPerson : BaseUnityPlugin
{
private ConfigEntry<KeyCode> Hotkey;
private ConfigEntry<float> OffsetX;
private ConfigEntry<float> OffsetY;
private ConfigEntry<float> OffsetZ;
private ConfigEntry<KeyCode> ZoomInKey;
private ConfigEntry<KeyCode> ZoomOutKey;
private ConfigEntry<float> ScrollSensitivity;
private ConfigEntry<float> KeyZoomSpeed;
private bool isThirdPerson = false;
private float currentZoom = 3f;
private Camera tpcCamera;
private GameObject tpcObject;
private int originalCullingMask;
private bool wasSprinting = false;
private void Awake()
{
Hotkey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("General", "ToggleKey", (KeyCode)120, "Key to toggle 3rd person mode");
OffsetX = ((BaseUnityPlugin)this).Config.Bind<float>("Camera", "OffsetX", 0.5f, "Horizontal camera offset");
OffsetY = ((BaseUnityPlugin)this).Config.Bind<float>("Camera", "OffsetY", 1.6f, "Vertical camera offset");
OffsetZ = ((BaseUnityPlugin)this).Config.Bind<float>("Camera", "OffsetZ", 3f, "Distance behind player");
ZoomInKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Controls", "ZoomInKey", (KeyCode)270, "Key to zoom in");
ZoomOutKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Controls", "ZoomOutKey", (KeyCode)269, "Key to zoom out");
ScrollSensitivity = ((BaseUnityPlugin)this).Config.Bind<float>("Controls", "ScrollSensitivity", 1f, "Sensitivity of the mouse scroll wheel");
KeyZoomSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Controls", "KeyZoomSpeed", 5f, "Speed of zooming when using keys");
currentZoom = OffsetZ.Value;
}
private void Update()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
if (Input.GetKeyDown(Hotkey.Value))
{
ToggleThirdPerson();
}
if (isThirdPerson)
{
HandleZoomInput();
UpdateCameraPosition();
UpdateAnimations();
}
}
private void HandleZoomInput()
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
float y = Input.mouseScrollDelta.y;
if (y != 0f)
{
currentZoom -= y * ScrollSensitivity.Value;
}
if (Input.GetKey(ZoomInKey.Value))
{
currentZoom -= KeyZoomSpeed.Value * Time.deltaTime;
}
if (Input.GetKey(ZoomOutKey.Value))
{
currentZoom += KeyZoomSpeed.Value * Time.deltaTime;
}
currentZoom = Mathf.Clamp(currentZoom, 1f, 10f);
}
private void ToggleThirdPerson()
{
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: Expected O, but got Unknown
isThirdPerson = !isThirdPerson;
if (isThirdPerson)
{
currentZoom = OffsetZ.Value;
if (Object.op_Implicit((Object)(object)Camera.main))
{
Camera main = Camera.main;
originalCullingMask = main.cullingMask;
tpcObject = new GameObject("EmpressTPC");
tpcCamera = tpcObject.AddComponent<Camera>();
tpcCamera.CopyFrom(main);
tpcCamera.depth = main.depth + 10f;
tpcCamera.nearClipPlane = 0.05f;
AudioListener component = tpcObject.GetComponent<AudioListener>();
if (Object.op_Implicit((Object)(object)component))
{
Object.Destroy((Object)(object)component);
}
main.cullingMask = 0;
}
if (Object.op_Implicit((Object)(object)HUD.instance))
{
HUD.instance.Hide();
}
if (Object.op_Implicit((Object)(object)PlayerAvatar.instance) && Object.op_Implicit((Object)(object)PlayerAvatar.instance.playerAvatarVisuals))
{
PlayerAvatar.instance.playerAvatarVisuals.meshParent.SetActive(true);
((Behaviour)PlayerAvatar.instance.playerAvatarVisuals.animator).enabled = true;
}
}
else
{
if (Object.op_Implicit((Object)(object)Camera.main))
{
Camera.main.cullingMask = originalCullingMask;
}
if (Object.op_Implicit((Object)(object)tpcObject))
{
Object.Destroy((Object)(object)tpcObject);
}
if (Object.op_Implicit((Object)(object)HUD.instance))
{
HUD.instance.Show();
}
if (Object.op_Implicit((Object)(object)PlayerAvatar.instance) && Object.op_Implicit((Object)(object)PlayerAvatar.instance.playerAvatarVisuals) && !PlayerAvatar.instance.playerAvatarVisuals.isMenuAvatar && (!GameManager.Multiplayer() || PlayerAvatar.instance.photonView.IsMine))
{
PlayerAvatar.instance.playerAvatarVisuals.meshParent.SetActive(false);
((Behaviour)PlayerAvatar.instance.playerAvatarVisuals.animator).enabled = false;
}
}
}
private void UpdateCameraPosition()
{
//IL_004a: 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_0061: 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_006c: 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_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: 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_0089: 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_009e: 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_00a4: 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_010b: Unknown result type (might be due to invalid IL or missing references)
//IL_0110: Unknown result type (might be due to invalid IL or missing references)
//IL_011c: Unknown result type (might be due to invalid IL or missing references)
//IL_0133: Unknown result type (might be due to invalid IL or missing references)
//IL_00d9: 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_00e9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
if (Object.op_Implicit((Object)(object)PlayerAvatar.instance) && Object.op_Implicit((Object)(object)CameraAim.Instance) && Object.op_Implicit((Object)(object)tpcObject))
{
Transform transform = ((Component)CameraAim.Instance).transform;
Vector3 position = ((Component)PlayerAvatar.instance).transform.position;
Vector3 val = position + Vector3.up * OffsetY.Value + transform.right * OffsetX.Value;
Vector3 val2 = val - transform.forward * Mathf.Abs(currentZoom);
RaycastHit val3 = default(RaycastHit);
if (Physics.Linecast(val, val2, ref val3, LayerMask.GetMask(new string[3] { "Default", "Ground", "Wall" })))
{
val2 = ((RaycastHit)(ref val3)).point + transform.forward * 0.2f;
}
tpcObject.transform.position = Vector3.Lerp(tpcObject.transform.position, val2, Time.deltaTime * 20f);
tpcObject.transform.rotation = transform.rotation;
}
}
private void UpdateAnimations()
{
//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
//IL_01a8: Invalid comparison between Unknown and I4
//IL_029d: Unknown result type (might be due to invalid IL or missing references)
//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
if (!Object.op_Implicit((Object)(object)PlayerAvatar.instance) || !Object.op_Implicit((Object)(object)PlayerAvatar.instance.playerAvatarVisuals))
{
return;
}
PlayerAvatar instance = PlayerAvatar.instance;
PlayerAvatarVisuals playerAvatarVisuals = instance.playerAvatarVisuals;
Animator animator = playerAvatarVisuals.animator;
bool isTumbling = instance.isTumbling;
if (isTumbling)
{
animator.SetBool("Tumbling", true);
bool flag = (((Vector3)(ref instance.tumble.physGrabObject.rbVelocity)).magnitude > 1f && !instance.tumble.physGrabObject.impactDetector.inCart) || ((Vector3)(ref instance.tumble.physGrabObject.rbAngularVelocity)).magnitude > 1f;
animator.SetBool("TumblingMove", flag);
}
else
{
animator.SetBool("Tumbling", false);
animator.SetBool("TumblingMove", false);
}
if (Object.op_Implicit((Object)(object)playerAvatarVisuals.playerAvatarRightArm) && playerAvatarVisuals.playerAvatarRightArm.poseNew == playerAvatarVisuals.playerAvatarRightArm.grabberPose)
{
animator.SetBool("Grabbing", true);
}
else
{
animator.SetBool("Grabbing", false);
}
animator.SetBool("Crouching", instance.isCrouching || instance.isTumbling);
animator.SetBool("Crawling", instance.isCrawling || instance.isTumbling);
animator.SetBool("Moving", (!instance.isMoving || instance.isGrounded) && instance.isMoving);
animator.SetBool("Sliding", instance.isSliding);
bool flag2 = (int)instance.physGrabber.grabState == 4;
bool flag3 = false;
if (!instance.isGrounded && !flag2 && !instance.isTumbling)
{
if (instance.rbVelocity.y > 0f)
{
animator.SetBool("Jumping", true);
flag3 = true;
}
else
{
animator.SetBool("Falling", true);
}
}
else
{
animator.SetBool("Jumping", false);
animator.SetBool("Falling", false);
}
if (instance.isSprinting && !flag3 && !isTumbling && !instance.isSliding)
{
if (!wasSprinting)
{
animator.SetTrigger("SprintingImpulse");
wasSprinting = true;
}
animator.SetBool("Sprinting", true);
}
else
{
animator.SetBool("Sprinting", false);
wasSprinting = false;
}
float num = 1f;
AnimatorStateInfo currentAnimatorStateInfo = animator.GetCurrentAnimatorStateInfo(0);
if (((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsName("Sprint"))
{
if (StatsManager.instance.playerUpgradeSpeed.ContainsKey(instance.steamID))
{
num = 1f + (float)StatsManager.instance.playerUpgradeSpeed[instance.steamID] * 0.1f;
}
}
else if (instance.isMoving && instance.mapToolController.Active)
{
num = 0.5f;
}
animator.speed = num * playerAvatarVisuals.animationSpeedMultiplier;
}
}