Decompiled source of Empress Cinematic v1.0.0

CinematicOverhaul.dll

Decompiled 17 hours ago
using System;
using System.Collections.Generic;
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("CinematicOverhaul")]
[assembly: AssemblyTitle("CinematicOverhaul")]
[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.cinematic", "Empress Cinematic", "2.1.3")]
public class EmpressCinematic : BaseUnityPlugin
{
	private ConfigEntry<KeyCode> MenuKey;

	private bool showUI = false;

	private Rect windowRect = new Rect(20f, 20f, 450f, 750f);

	private Vector2 scrollPosition;

	private bool cineCameraEnabled = false;

	private bool cineCameraLocked = false;

	private bool wasCineCameraEnabled = false;

	private GameObject tpcObject;

	private Camera tpcRootCam;

	private List<Camera> tpcAllCams = new List<Camera>();

	private List<Behaviour> tpcAllPostLayers = new List<Behaviour>();

	private Camera originalMainCameraRef;

	private List<Camera> originalAllCams = new List<Camera>();

	private string originalMainCameraTag;

	private bool originalMainCameraEnabled;

	private Dictionary<Camera, int> originalCullingMasks = new Dictionary<Camera, int>();

	private float flySpeed = 5f;

	private float flySpeedFastMultiplier = 3f;

	private float mouseSensitivity = 2f;

	private float rotationX = 0f;

	private float rotationY = 0f;

	private float cameraRoll = 0f;

	private bool shadowsEnabled = true;

	private float ambientIntensity = 1f;

	private float timeScale = 1f;

	private bool fovEnabled = false;

	private float fovValue = 60f;

	private bool smoothEnabled = false;

	private float smoothValue = 2f;

	private bool satEnabled = false;

	private float satValue = 0f;

	private bool conEnabled = false;

	private float conValue = 0f;

	private bool vigEnabled = false;

	private float vigIntensity = 0.5f;

	private float vigSmoothness = 0.5f;

	private Color vigColor = Color.black;

	private bool effectMatrix = false;

	private bool effectNoir = false;

	private bool effectPsycho = false;

	private float psychoTimer = 0f;

	private bool animSprinting;

	private bool animSliding;

	private bool animSlidingImpulse;

	private bool animJumping;

	private bool animJumpingImpulse;

	private float animJumpTimer;

	private float animJumpedTimer;

	private float animFallingTimer;

	private bool animTumbling;

	private Texture2D windowBg;

	private Texture2D buttonBg;

	private Texture2D buttonHoverBg;

	private Texture2D sliderBg;

	private Texture2D sliderThumb;

	private GUIStyle windowStyle;

	private GUIStyle buttonStyle;

	private GUIStyle labelStyle;

	private GUIStyle headerStyle;

	private GUIStyle sliderStyle;

	private GUIStyle sliderThumbStyle;

	private GUIStyle toggleStyle;

	private Transform flashlightOriginalParent;

	private Vector3 flashlightOriginalLocalPos;

	private Quaternion flashlightOriginalLocalRot;

	private Vector3 flashlightOriginalLocalScale;

	private bool flashlightRebound;

	private int flashlightLayer = -1;

	private int playerLayer = -1;

	private void Awake()
	{
		MenuKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("General", "CinematicMenuKey", (KeyCode)120, "Key to toggle the Empress Cinematic Menu");
	}

	private void Start()
	{
		//IL_0004: Unknown result type (might be due to invalid IL or missing references)
		//IL_000e: Expected O, but got Unknown
		//IL_002a: 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_004e: Expected O, but got Unknown
		//IL_006a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0084: Unknown result type (might be due to invalid IL or missing references)
		//IL_008e: Expected O, but got Unknown
		//IL_00aa: 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_00ce: Expected O, but got Unknown
		//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_0104: Unknown result type (might be due to invalid IL or missing references)
		//IL_010e: Expected O, but got Unknown
		//IL_0116: Unknown result type (might be due to invalid IL or missing references)
		//IL_012e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0134: Invalid comparison between Unknown and I4
		windowBg = new Texture2D(1, 1);
		windowBg.SetPixel(0, 0, new Color(0.05f, 0f, 0f, 0.95f));
		windowBg.Apply();
		buttonBg = new Texture2D(1, 1);
		buttonBg.SetPixel(0, 0, new Color(0.4f, 0f, 0f, 1f));
		buttonBg.Apply();
		buttonHoverBg = new Texture2D(1, 1);
		buttonHoverBg.SetPixel(0, 0, new Color(0.7f, 0f, 0f, 1f));
		buttonHoverBg.Apply();
		sliderBg = new Texture2D(1, 1);
		sliderBg.SetPixel(0, 0, new Color(0.2f, 0f, 0f, 1f));
		sliderBg.Apply();
		sliderThumb = new Texture2D(1, 1);
		sliderThumb.SetPixel(0, 0, Color.red);
		sliderThumb.Apply();
		shadowsEnabled = (int)QualitySettings.shadows > 0;
		try
		{
			ambientIntensity = RenderSettings.ambientIntensity;
		}
		catch
		{
		}
	}

	private void Update()
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		if (Input.GetKeyDown(MenuKey.Value))
		{
			showUI = !showUI;
			if (showUI)
			{
				Cursor.visible = true;
				Cursor.lockState = (CursorLockMode)0;
			}
			else
			{
				if (Object.op_Implicit((Object)(object)GameDirector.instance))
				{
					GameDirector.instance.SetDisableInput(0f);
				}
				Cursor.visible = false;
				Cursor.lockState = (CursorLockMode)1;
			}
		}
		if (showUI)
		{
			if (Object.op_Implicit((Object)(object)GameDirector.instance))
			{
				GameDirector.instance.SetDisableInput(0.1f);
			}
			Cursor.visible = true;
			Cursor.lockState = (CursorLockMode)0;
		}
		if (effectPsycho)
		{
			psychoTimer += Time.deltaTime;
			cameraRoll = Mathf.Sin(psychoTimer) * 10f;
			fovValue = 60f + Mathf.Sin(psychoTimer * 2f) * 20f;
			fovEnabled = true;
		}
		HandleCinematicCamera();
		ApplyPostProcessingOverrides();
		if (cineCameraEnabled)
		{
			SyncFlashlightToClientHand();
		}
	}

	private void ApplyPostProcessingOverrides()
	{
		//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bf: 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)
		//IL_0116: Unknown result type (might be due to invalid IL or missing references)
		//IL_011b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0148: Unknown result type (might be due to invalid IL or missing references)
		//IL_014d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0193: Unknown result type (might be due to invalid IL or missing references)
		//IL_0198: Unknown result type (might be due to invalid IL or missing references)
		//IL_025f: Unknown result type (might be due to invalid IL or missing references)
		if (fovEnabled && Object.op_Implicit((Object)(object)CameraZoom.Instance))
		{
			CameraZoom.Instance.OverrideZoomSet(fovValue, 0.1f, 100f, 100f, ((Component)this).gameObject, -999);
		}
		if (smoothEnabled && Object.op_Implicit((Object)(object)CameraAim.Instance))
		{
			CameraAim.Instance.OverrideAimSmooth(smoothValue, 0.1f);
		}
		if (Object.op_Implicit((Object)(object)PostProcessing.Instance))
		{
			float num = (satEnabled ? satValue : 0f);
			float num2 = (conEnabled ? conValue : 0f);
			Color val = (vigEnabled ? vigColor : Color.black);
			float num3 = (vigEnabled ? vigIntensity : 0f);
			float num4 = (vigEnabled ? vigSmoothness : 0f);
			if (effectMatrix)
			{
				num = -50f;
				num2 = 50f;
				val = Color.green;
				num3 = 0.4f;
				num4 = 1f;
			}
			else if (effectNoir)
			{
				num = -100f;
				num2 = 30f;
				val = Color.black;
				num3 = 0.6f;
				num4 = 0.6f;
			}
			else if (effectPsycho)
			{
				num = 100f;
				num2 = 20f;
				val = Color.HSVToRGB(Mathf.Repeat(Time.time, 1f), 1f, 1f);
				num3 = 0.5f;
			}
			if (satEnabled || effectMatrix || effectNoir || effectPsycho)
			{
				PostProcessing.Instance.SaturationOverride(num, 100f, 100f, 0.1f, ((Component)this).gameObject);
			}
			if (conEnabled || effectMatrix || effectNoir || effectPsycho)
			{
				PostProcessing.Instance.ContrastOverride(num2, 100f, 100f, 0.1f, ((Component)this).gameObject);
			}
			if (vigEnabled || effectMatrix || effectNoir || effectPsycho)
			{
				PostProcessing.Instance.VignetteOverride(val, num3, num4, 100f, 100f, 0.1f, ((Component)this).gameObject);
			}
		}
	}

	private void HandleCinematicCamera()
	{
		//IL_07ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_07f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0802: Unknown result type (might be due to invalid IL or missing references)
		//IL_080f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0814: Unknown result type (might be due to invalid IL or missing references)
		//IL_0819: Unknown result type (might be due to invalid IL or missing references)
		//IL_0828: Unknown result type (might be due to invalid IL or missing references)
		//IL_0835: Unknown result type (might be due to invalid IL or missing references)
		//IL_083a: Unknown result type (might be due to invalid IL or missing references)
		//IL_083f: Unknown result type (might be due to invalid IL or missing references)
		//IL_084e: Unknown result type (might be due to invalid IL or missing references)
		//IL_085b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0860: Unknown result type (might be due to invalid IL or missing references)
		//IL_0865: Unknown result type (might be due to invalid IL or missing references)
		//IL_0874: Unknown result type (might be due to invalid IL or missing references)
		//IL_0881: Unknown result type (might be due to invalid IL or missing references)
		//IL_0886: Unknown result type (might be due to invalid IL or missing references)
		//IL_088b: Unknown result type (might be due to invalid IL or missing references)
		//IL_089a: Unknown result type (might be due to invalid IL or missing references)
		//IL_089c: Unknown result type (might be due to invalid IL or missing references)
		//IL_08a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_08a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_08cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_08d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_08d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_08e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_08e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_08b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_08b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_08bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_08c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_09a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_0976: Unknown result type (might be due to invalid IL or missing references)
		//IL_03d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_03d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_03e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_03e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_03eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_03f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_03fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_0412: Unknown result type (might be due to invalid IL or missing references)
		//IL_0420: Unknown result type (might be due to invalid IL or missing references)
		//IL_0432: Unknown result type (might be due to invalid IL or missing references)
		if (cineCameraEnabled != wasCineCameraEnabled)
		{
			if (cineCameraEnabled)
			{
				if (Object.op_Implicit((Object)(object)Camera.main))
				{
					Camera val = (originalMainCameraRef = Camera.main);
					originalMainCameraTag = ((Component)val).tag;
					originalMainCameraEnabled = ((Behaviour)val).enabled;
					originalAllCams.Clear();
					originalAllCams.AddRange(((Component)val).GetComponentsInChildren<Camera>(true));
					originalCullingMasks.Clear();
					foreach (Camera originalAllCam in originalAllCams)
					{
						originalCullingMasks[originalAllCam] = originalAllCam.cullingMask;
					}
					tpcObject = Object.Instantiate<GameObject>(((Component)val).gameObject);
					((Object)tpcObject).name = "EmpressCinematicCam";
					tpcObject.tag = "MainCamera";
					AudioListener component = tpcObject.GetComponent<AudioListener>();
					if (Object.op_Implicit((Object)(object)component))
					{
						Object.Destroy((Object)(object)component);
					}
					MonoBehaviour[] components = tpcObject.GetComponents<MonoBehaviour>();
					MonoBehaviour[] array = components;
					foreach (MonoBehaviour val2 in array)
					{
						string name = ((object)val2).GetType().Name;
						if (name.Contains("CameraZoom") || name.Contains("CameraAim") || name.Contains("GameDirector") || name.Contains("Recorder"))
						{
							Object.Destroy((Object)(object)val2);
						}
					}
					tpcAllCams.Clear();
					tpcAllCams.AddRange(tpcObject.GetComponentsInChildren<Camera>(true));
					tpcRootCam = tpcObject.GetComponent<Camera>();
					foreach (Camera tpcAllCam in tpcAllCams)
					{
						((Behaviour)tpcAllCam).enabled = true;
						tpcAllCam.depth = originalMainCameraRef.depth + 10f;
						tpcAllCam.useOcclusionCulling = false;
						tpcAllCam.layerCullSpherical = true;
						float[] array2 = new float[32];
						for (int j = 0; j < 32; j++)
						{
							array2[j] = 100000f;
						}
						tpcAllCam.layerCullDistances = array2;
						if (tpcAllCam.farClipPlane < 2000f)
						{
							tpcAllCam.farClipPlane = 2000f;
						}
						if ((Object)(object)CameraZoom.Instance != (Object)null && CameraZoom.Instance.cams != null && !CameraZoom.Instance.cams.Contains(tpcAllCam))
						{
							CameraZoom.Instance.cams.Add(tpcAllCam);
						}
					}
					tpcAllPostLayers.Clear();
					Behaviour[] componentsInChildren = tpcObject.GetComponentsInChildren<Behaviour>(true);
					foreach (Behaviour val3 in componentsInChildren)
					{
						if (Object.op_Implicit((Object)(object)val3) && ((object)val3).GetType().Name == "PostProcessLayer")
						{
							Type type = ((object)val3).GetType();
							PropertyInfo property = type.GetProperty("volumeTrigger");
							if (property != null)
							{
								property.SetValue(val3, tpcObject.transform);
							}
							val3.enabled = true;
							tpcAllPostLayers.Add(val3);
						}
					}
					Transform val4 = (Object.op_Implicit((Object)(object)CameraAim.Instance) ? ((Component)CameraAim.Instance).transform : ((Component)val).transform);
					tpcObject.transform.position = val4.position - val4.forward * 2f + Vector3.up * 0.5f;
					tpcObject.transform.rotation = val4.rotation;
					rotationX = val4.eulerAngles.y;
					rotationY = val4.eulerAngles.x;
					foreach (Camera originalAllCam2 in originalAllCams)
					{
						originalAllCam2.cullingMask = 0;
					}
					((Component)val).tag = "Untagged";
				}
				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;
					SkinnedMeshRenderer[] componentsInChildren2 = ((Component)PlayerAvatar.instance.playerAvatarVisuals).GetComponentsInChildren<SkinnedMeshRenderer>();
					SkinnedMeshRenderer[] array3 = componentsInChildren2;
					foreach (SkinnedMeshRenderer val5 in array3)
					{
						((Renderer)val5).enabled = true;
					}
					playerLayer = PlayerAvatar.instance.playerAvatarVisuals.meshParent.layer;
				}
				BindFlashlightToClientHand(enable: true);
				ApplyFlashlightCameraMaskRouting();
			}
			else
			{
				if (Object.op_Implicit((Object)(object)originalMainCameraRef))
				{
					foreach (Camera originalAllCam3 in originalAllCams)
					{
						if (originalCullingMasks.TryGetValue(originalAllCam3, out var value))
						{
							originalAllCam3.cullingMask = value;
						}
					}
					((Component)originalMainCameraRef).tag = originalMainCameraTag;
					((Behaviour)originalMainCameraRef).enabled = originalMainCameraEnabled;
				}
				if ((Object)(object)CameraZoom.Instance != (Object)null && CameraZoom.Instance.cams != null)
				{
					foreach (Camera tpcAllCam2 in tpcAllCams)
					{
						CameraZoom.Instance.cams.Remove(tpcAllCam2);
					}
				}
				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))
				{
					SkinnedMeshRenderer[] componentsInChildren3 = ((Component)PlayerAvatar.instance.playerAvatarVisuals).GetComponentsInChildren<SkinnedMeshRenderer>();
					SkinnedMeshRenderer[] array4 = componentsInChildren3;
					foreach (SkinnedMeshRenderer val6 in array4)
					{
						((Renderer)val6).enabled = true;
					}
					if (!PlayerAvatar.instance.playerAvatarVisuals.isMenuAvatar && (!GameManager.Multiplayer() || PlayerAvatar.instance.photonView.IsMine))
					{
						PlayerAvatar.instance.playerAvatarVisuals.meshParent.SetActive(false);
						((Behaviour)PlayerAvatar.instance.playerAvatarVisuals.animator).enabled = false;
					}
				}
				BindFlashlightToClientHand(enable: false);
				cineCameraLocked = false;
				effectMatrix = false;
				effectNoir = false;
				effectPsycho = false;
				cameraRoll = 0f;
			}
			wasCineCameraEnabled = cineCameraEnabled;
		}
		if (!cineCameraEnabled || !Object.op_Implicit((Object)(object)tpcObject))
		{
			return;
		}
		if (!cineCameraLocked && showUI)
		{
			float num = flySpeed;
			if (Input.GetKey((KeyCode)304))
			{
				num *= flySpeedFastMultiplier;
			}
			Vector3 val7 = Vector3.zero;
			if (Input.GetKey((KeyCode)119))
			{
				val7 += tpcObject.transform.forward;
			}
			if (Input.GetKey((KeyCode)115))
			{
				val7 -= tpcObject.transform.forward;
			}
			if (Input.GetKey((KeyCode)97))
			{
				val7 -= tpcObject.transform.right;
			}
			if (Input.GetKey((KeyCode)100))
			{
				val7 += tpcObject.transform.right;
			}
			if (Input.GetKey((KeyCode)101))
			{
				val7 += Vector3.up;
			}
			if (Input.GetKey((KeyCode)113))
			{
				val7 -= Vector3.up;
			}
			Transform transform = tpcObject.transform;
			transform.position += val7 * num * Time.deltaTime;
			if (Input.GetMouseButton(1))
			{
				rotationX += Input.GetAxis("Mouse X") * mouseSensitivity;
				rotationY -= Input.GetAxis("Mouse Y") * mouseSensitivity;
				rotationY = Mathf.Clamp(rotationY, -90f, 90f);
				tpcObject.transform.rotation = Quaternion.Euler(rotationY, rotationX, cameraRoll);
			}
			else
			{
				tpcObject.transform.rotation = Quaternion.Euler(rotationY, rotationX, cameraRoll);
			}
		}
		if (Object.op_Implicit((Object)(object)PlayerAvatar.instance) && Object.op_Implicit((Object)(object)PlayerAvatar.instance.playerAvatarVisuals))
		{
			UpdateLocalPlayerAnimation(PlayerAvatar.instance.playerAvatarVisuals, PlayerAvatar.instance);
		}
	}

	private void ApplyFlashlightCameraMaskRouting()
	{
		if (flashlightLayer < 0)
		{
			return;
		}
		foreach (Camera tpcAllCam in tpcAllCams)
		{
			if (playerLayer >= 0 && (tpcAllCam.cullingMask & (1 << playerLayer)) != 0)
			{
				tpcAllCam.cullingMask |= 1 << flashlightLayer;
			}
			else
			{
				tpcAllCam.cullingMask &= ~(1 << flashlightLayer);
			}
		}
	}

	private void BindFlashlightToClientHand(bool enable)
	{
		//IL_0142: 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_0166: 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_00ce: 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_0070: Unknown result type (might be due to invalid IL or missing references)
		//IL_0075: 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)
		FlashlightController instance = FlashlightController.Instance;
		if ((Object)(object)instance == (Object)null)
		{
			return;
		}
		if (enable)
		{
			if (!((Object)(object)instance.FollowTransformClient == (Object)null))
			{
				if (!flashlightRebound)
				{
					flashlightOriginalParent = ((Component)instance).transform.parent;
					flashlightOriginalLocalPos = ((Component)instance).transform.localPosition;
					flashlightOriginalLocalRot = ((Component)instance).transform.localRotation;
					flashlightOriginalLocalScale = ((Component)instance).transform.localScale;
					flashlightRebound = true;
				}
				flashlightLayer = ((Component)instance).gameObject.layer;
				((Component)instance).transform.SetParent(instance.FollowTransformClient, false);
				((Component)instance).transform.localPosition = Vector3.zero;
				((Component)instance).transform.localRotation = Quaternion.identity;
				Renderer[] componentsInChildren = ((Component)instance).GetComponentsInChildren<Renderer>(true);
				Renderer[] array = componentsInChildren;
				foreach (Renderer val in array)
				{
					val.forceRenderingOff = false;
					val.allowOcclusionWhenDynamic = false;
				}
			}
		}
		else if (flashlightRebound)
		{
			((Component)instance).transform.SetParent(flashlightOriginalParent, false);
			((Component)instance).transform.localPosition = flashlightOriginalLocalPos;
			((Component)instance).transform.localRotation = flashlightOriginalLocalRot;
			((Component)instance).transform.localScale = flashlightOriginalLocalScale;
			flashlightRebound = false;
			flashlightOriginalParent = null;
			flashlightLayer = -1;
		}
	}

	private void SyncFlashlightToClientHand()
	{
		//IL_0040: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		FlashlightController instance = FlashlightController.Instance;
		if (!((Object)(object)instance == (Object)null) && flashlightRebound && !((Object)(object)instance.FollowTransformClient == (Object)null))
		{
			((Component)instance).transform.position = instance.FollowTransformClient.position;
			((Component)instance).transform.rotation = instance.FollowTransformClient.rotation;
		}
	}

	private void UpdateLocalPlayerAnimation(PlayerAvatarVisuals visuals, PlayerAvatar player)
	{
		//IL_0110: Unknown result type (might be due to invalid IL or missing references)
		//IL_011b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0465: Unknown result type (might be due to invalid IL or missing references)
		//IL_046a: Unknown result type (might be due to invalid IL or missing references)
		Animator animator = visuals.animator;
		float num = Time.deltaTime * visuals.animationSpeedMultiplier;
		if (player.isTumbling)
		{
			if (!animSprinting && !animTumbling)
			{
				animator.SetTrigger("TumblingImpulse");
				animTumbling = true;
			}
			if ((((Vector3)(ref player.tumble.physGrabObject.rbVelocity)).magnitude > 1f && !player.tumble.physGrabObject.impactDetector.inCart) || ((Vector3)(ref player.tumble.physGrabObject.rbAngularVelocity)).magnitude > 1f)
			{
				animator.SetBool("TumblingMove", true);
			}
			else
			{
				animator.SetBool("TumblingMove", false);
			}
			animator.SetBool("Tumbling", true);
		}
		else
		{
			animator.SetBool("Tumbling", false);
			animator.SetBool("TumblingMove", false);
			animTumbling = false;
		}
		if (Object.op_Implicit((Object)(object)visuals.playerAvatarRightArm) && visuals.playerAvatarRightArm.poseNew == visuals.playerAvatarRightArm.grabberPose)
		{
			animator.SetBool("Grabbing", true);
		}
		else
		{
			animator.SetBool("Grabbing", false);
		}
		animator.SetBool("Crouching", player.isCrouching || player.isTumbling);
		animator.SetBool("Crawling", player.isCrawling || player.isTumbling);
		animator.SetBool("Moving", player.isMoving && !animJumping);
		if (player.isSprinting && !animJumping && !animTumbling)
		{
			if (!animSprinting && !animSliding)
			{
				animator.SetTrigger("SprintingImpulse");
				animSprinting = true;
			}
			animator.SetBool("Sprinting", true);
		}
		else
		{
			animator.SetBool("Sprinting", false);
			animSprinting = false;
		}
		animSlidingImpulse = false;
		if (player.isSliding && !animJumping && !animTumbling)
		{
			if (!animSliding)
			{
				animSlidingImpulse = true;
				animator.SetTrigger("SlidingImpulse");
			}
			animator.SetBool("Sliding", true);
			animSliding = true;
		}
		else
		{
			animator.SetBool("Sliding", false);
			animSliding = false;
		}
		if (animJumping)
		{
			if (animJumpingImpulse)
			{
				animJumpTimer = 0.2f;
				animJumpingImpulse = false;
				animator.SetTrigger("JumpingImpulse");
				animator.SetBool("Jumping", true);
				animator.SetBool("Falling", false);
			}
			else if (player.rbVelocityRaw.y < -0.5f && animJumpTimer <= 0f)
			{
				animator.SetBool("Falling", true);
			}
			if (player.isGrounded && animJumpTimer <= 0f)
			{
				animJumpedTimer = 0.5f;
				animJumping = false;
			}
			animJumpTimer -= num;
		}
		else
		{
			animator.SetBool("Jumping", false);
			animator.SetBool("Falling", false);
		}
		if (animJumpedTimer > 0f)
		{
			animJumpedTimer -= num;
		}
		if (!player.isGrounded)
		{
			animFallingTimer += num;
		}
		else
		{
			animFallingTimer = 0f;
		}
		if (!player.isCrawling && !animJumping && !animSliding && !animTumbling && animFallingTimer > 0.25f && animJumpedTimer <= 0f)
		{
			animJumpTimer = 0.2f;
			animJumping = true;
			animJumpingImpulse = false;
			animator.SetTrigger("FallingImpulse");
			animator.SetBool("Jumping", true);
			animator.SetBool("Falling", true);
		}
		float num2 = 1f;
		AnimatorStateInfo currentAnimatorStateInfo = animator.GetCurrentAnimatorStateInfo(0);
		if (((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsName("Sprint") && Object.op_Implicit((Object)(object)StatsManager.instance) && StatsManager.instance.playerUpgradeSpeed.ContainsKey(player.steamID))
		{
			num2 = 1f + (float)StatsManager.instance.playerUpgradeSpeed[player.steamID] * 0.1f;
		}
		else if (player.isMoving && player.mapToolController.Active)
		{
			num2 = 0.5f;
		}
		animator.speed = num2 * visuals.animationSpeedMultiplier;
	}

	private void OnGUI()
	{
		//IL_02d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_02dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_02fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_0309: Expected O, but got Unknown
		//IL_0304: Unknown result type (might be due to invalid IL or missing references)
		//IL_0309: 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)
		//IL_0039: Expected O, but got Unknown
		//IL_0072: 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_00b9: Expected O, but got Unknown
		//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cf: Expected O, but got Unknown
		//IL_011f: 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_015b: Expected O, but got Unknown
		//IL_0167: Unknown result type (might be due to invalid IL or missing references)
		//IL_0171: Expected O, but got Unknown
		//IL_017c: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c4: Expected O, but got Unknown
		//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0206: Unknown result type (might be due to invalid IL or missing references)
		//IL_0210: Expected O, but got Unknown
		//IL_0232: Unknown result type (might be due to invalid IL or missing references)
		//IL_023c: Expected O, but got Unknown
		//IL_0275: Unknown result type (might be due to invalid IL or missing references)
		//IL_027f: Expected O, but got Unknown
		//IL_028a: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c5: Unknown result type (might be due to invalid IL or missing references)
		if (showUI)
		{
			if (windowStyle == null)
			{
				windowStyle = new GUIStyle(GUI.skin.window);
				windowStyle.normal.background = windowBg;
				windowStyle.onNormal.background = windowBg;
				windowStyle.normal.textColor = Color.red;
				windowStyle.fontStyle = (FontStyle)3;
				windowStyle.fontSize = 16;
				windowStyle.alignment = (TextAnchor)1;
				windowStyle.border = new RectOffset(4, 4, 4, 4);
				buttonStyle = new GUIStyle(GUI.skin.button);
				buttonStyle.normal.background = buttonBg;
				buttonStyle.hover.background = buttonHoverBg;
				buttonStyle.active.background = buttonHoverBg;
				buttonStyle.normal.textColor = Color.white;
				buttonStyle.fontStyle = (FontStyle)1;
				buttonStyle.fontSize = 13;
				buttonStyle.padding = new RectOffset(10, 10, 5, 5);
				headerStyle = new GUIStyle(GUI.skin.label);
				headerStyle.normal.textColor = Color.red;
				headerStyle.fontStyle = (FontStyle)1;
				headerStyle.fontSize = 14;
				headerStyle.alignment = (TextAnchor)4;
				labelStyle = new GUIStyle(GUI.skin.label);
				labelStyle.normal.textColor = new Color(0.9f, 0.9f, 0.9f, 1f);
				labelStyle.fontStyle = (FontStyle)0;
				sliderStyle = new GUIStyle(GUI.skin.horizontalSlider);
				sliderStyle.normal.background = sliderBg;
				sliderThumbStyle = new GUIStyle(GUI.skin.horizontalSliderThumb);
				sliderThumbStyle.normal.background = sliderThumb;
				sliderThumbStyle.hover.background = sliderThumb;
				toggleStyle = new GUIStyle(GUI.skin.toggle);
				toggleStyle.normal.textColor = Color.white;
				toggleStyle.onNormal.textColor = Color.red;
				toggleStyle.hover.textColor = new Color(1f, 0.5f, 0.5f);
			}
			GUI.backgroundColor = Color.white;
			GUI.contentColor = Color.white;
			windowRect = GUI.Window(999, windowRect, new WindowFunction(DrawWindow), "EMPRESS CINEMATIC SUITE");
		}
	}

	private void DrawWindow(int windowID)
	{
		//IL_0015: 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_0042: Unknown result type (might be due to invalid IL or missing references)
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		GUI.DragWindow(new Rect(0f, 0f, 10000f, 25f));
		GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
		GUILayout.Space(10f);
		scrollPosition = GUILayout.BeginScrollView(scrollPosition, Array.Empty<GUILayoutOption>());
		GUILayout.Space(5f);
		GUILayout.Label(":: CAMERA ::", headerStyle, Array.Empty<GUILayoutOption>());
		GUILayout.Space(5f);
		bool flag = GUILayout.Toggle(cineCameraEnabled, " Enable Freecam", toggleStyle, Array.Empty<GUILayoutOption>());
		if (flag != cineCameraEnabled)
		{
			cineCameraEnabled = flag;
		}
		if (cineCameraEnabled)
		{
			cineCameraLocked = GUILayout.Toggle(cineCameraLocked, " LOCK POSITION (Tripod)", toggleStyle, Array.Empty<GUILayoutOption>());
			GUILayout.Space(5f);
			GUILayout.Label("[ Controls: WASD | Q/E=Up/Down | Shift=Speed | R-Click=Rot ]", labelStyle, Array.Empty<GUILayoutOption>());
			GUILayout.Space(5f);
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.Label($"Speed: {flySpeed:F1}", labelStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(80f) });
			flySpeed = GUILayout.HorizontalSlider(flySpeed, 1f, 50f, sliderStyle, sliderThumbStyle, Array.Empty<GUILayoutOption>());
			GUILayout.EndHorizontal();
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.Label($"Sens: {mouseSensitivity:F1}", labelStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(80f) });
			mouseSensitivity = GUILayout.HorizontalSlider(mouseSensitivity, 0.1f, 10f, sliderStyle, sliderThumbStyle, Array.Empty<GUILayoutOption>());
			GUILayout.EndHorizontal();
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.Label($"Roll: {cameraRoll:F1}", labelStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(80f) });
			cameraRoll = GUILayout.HorizontalSlider(cameraRoll, -180f, 180f, sliderStyle, sliderThumbStyle, Array.Empty<GUILayoutOption>());
			GUILayout.EndHorizontal();
		}
		GUILayout.Space(15f);
		DrawSeparator();
		GUILayout.Label(":: EMPRESS FX ::", headerStyle, Array.Empty<GUILayoutOption>());
		GUILayout.Space(5f);
		if (GUILayout.Toggle(effectMatrix, " MATRIX HACK", toggleStyle, Array.Empty<GUILayoutOption>()))
		{
			if (!effectMatrix)
			{
				effectMatrix = true;
				effectNoir = false;
				effectPsycho = false;
			}
		}
		else
		{
			effectMatrix = false;
		}
		if (GUILayout.Toggle(effectNoir, " NOIR CITY", toggleStyle, Array.Empty<GUILayoutOption>()))
		{
			if (!effectNoir)
			{
				effectNoir = true;
				effectMatrix = false;
				effectPsycho = false;
			}
		}
		else
		{
			effectNoir = false;
		}
		if (GUILayout.Toggle(effectPsycho, " PSYCHO TRIP", toggleStyle, Array.Empty<GUILayoutOption>()))
		{
			if (!effectPsycho)
			{
				effectPsycho = true;
				effectMatrix = false;
				effectNoir = false;
			}
		}
		else
		{
			effectPsycho = false;
		}
		GUILayout.Space(15f);
		DrawSeparator();
		GUILayout.Label(":: POST FX ::", headerStyle, Array.Empty<GUILayoutOption>());
		GUILayout.Space(5f);
		GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
		fovEnabled = GUILayout.Toggle(fovEnabled, " FOV", toggleStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(60f) });
		if (fovEnabled)
		{
			fovValue = GUILayout.HorizontalSlider(fovValue, 10f, 150f, sliderStyle, sliderThumbStyle, Array.Empty<GUILayoutOption>());
			GUILayout.Label($"{fovValue:F0}", labelStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(30f) });
		}
		GUILayout.EndHorizontal();
		GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
		satEnabled = GUILayout.Toggle(satEnabled, " Sat", toggleStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(60f) });
		if (satEnabled)
		{
			satValue = GUILayout.HorizontalSlider(satValue, -100f, 100f, sliderStyle, sliderThumbStyle, Array.Empty<GUILayoutOption>());
		}
		GUILayout.EndHorizontal();
		GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
		conEnabled = GUILayout.Toggle(conEnabled, " Con", toggleStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(60f) });
		if (conEnabled)
		{
			conValue = GUILayout.HorizontalSlider(conValue, -100f, 100f, sliderStyle, sliderThumbStyle, Array.Empty<GUILayoutOption>());
		}
		GUILayout.EndHorizontal();
		GUILayout.Space(5f);
		vigEnabled = GUILayout.Toggle(vigEnabled, " Vignette", toggleStyle, Array.Empty<GUILayoutOption>());
		if (vigEnabled)
		{
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.Label($"Int: {vigIntensity:F2}", labelStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(60f) });
			vigIntensity = GUILayout.HorizontalSlider(vigIntensity, 0f, 1f, sliderStyle, sliderThumbStyle, Array.Empty<GUILayoutOption>());
			GUILayout.EndHorizontal();
		}
		GUILayout.Space(15f);
		DrawSeparator();
		GUILayout.Label(":: WORLD ::", headerStyle, Array.Empty<GUILayoutOption>());
		GUILayout.Space(5f);
		bool flag2 = GUILayout.Toggle(shadowsEnabled, " Shadows", toggleStyle, Array.Empty<GUILayoutOption>());
		if (flag2 != shadowsEnabled)
		{
			shadowsEnabled = flag2;
			QualitySettings.shadows = (ShadowQuality)(shadowsEnabled ? 2 : 0);
		}
		GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
		GUILayout.Label($"Ambient: {ambientIntensity:F1}", labelStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(80f) });
		float num = GUILayout.HorizontalSlider(ambientIntensity, 0f, 5f, sliderStyle, sliderThumbStyle, Array.Empty<GUILayoutOption>());
		if (num != ambientIntensity)
		{
			ambientIntensity = num;
			RenderSettings.ambientIntensity = ambientIntensity;
		}
		GUILayout.EndHorizontal();
		GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
		GUILayout.Label($"Time: {timeScale:F1}", labelStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(80f) });
		float num2 = GUILayout.HorizontalSlider(timeScale, 0f, 2f, sliderStyle, sliderThumbStyle, Array.Empty<GUILayoutOption>());
		if (Mathf.Abs(num2 - timeScale) > 0.01f)
		{
			timeScale = num2;
			Time.timeScale = timeScale;
		}
		GUILayout.EndHorizontal();
		GUILayout.Space(20f);
		DrawSeparator();
		GUILayout.Space(5f);
		if (GUILayout.Button("TOGGLE HUD (REC MODE)", buttonStyle, Array.Empty<GUILayoutOption>()) && Object.op_Implicit((Object)(object)GameDirector.instance))
		{
			GameDirector.instance.CommandRecordingDirectorToggle();
		}
		GUILayout.EndScrollView();
		GUILayout.EndVertical();
	}

	private void DrawSeparator()
	{
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: 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_0028: Unknown result type (might be due to invalid IL or missing references)
		Rect rect = GUILayoutUtility.GetRect(1f, 1f);
		GUI.color = Color.red;
		GUI.DrawTexture(rect, (Texture)(object)Texture2D.whiteTexture);
		GUI.color = Color.white;
	}
}