Decompiled source of FaceCam v1.0.0

Mods/FaceCam.dll

Decompiled 2 days ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BoneLib;
using BoneLib.BoneMenu;
using FaceCam;
using MelonLoader;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(Main), "FaceCam", "1.0.0", "speckk", null)]
[assembly: MelonGame("Stress Level Zero", "BONELAB")]
[assembly: AssemblyTitle("FaceCam")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("FaceCam")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("16a36523-ae65-4e2f-9c11-943fbffa7e79")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace FaceCam;

public class Main : MelonMod
{
	private bool isEnabled = false;

	private float smoothing = 5f;

	private Page speckkCategory;

	private GameObject faceCamObj;

	private Camera faceCam;

	public override void OnInitializeMelon()
	{
		//IL_000c: 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_004b: Unknown result type (might be due to invalid IL or missing references)
		speckkCategory = Page.Root.CreatePage("SPECKK", Color.white, 0, true);
		speckkCategory.CreateBool("Toggle FaceCam", Color.white, false, (Action<bool>)delegate(bool val)
		{
			isEnabled = val;
			ToggleFaceCam(val);
		});
		speckkCategory.CreateFloat("Smoothing", Color.white, 5f, 0.5f, 1f, 30f, (Action<float>)delegate(float val)
		{
			smoothing = val;
		});
	}

	public override void OnUpdate()
	{
		if (Input.GetKeyDown((KeyCode)105))
		{
			isEnabled = !isEnabled;
			ToggleFaceCam(isEnabled);
		}
	}

	private void ToggleFaceCam(bool active)
	{
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_002b: Expected O, but got Unknown
		if (active)
		{
			if ((Object)(object)faceCamObj == (Object)null)
			{
				faceCamObj = new GameObject("FaceCam_Spectator");
				faceCam = faceCamObj.AddComponent<Camera>();
				if ((Object)(object)Camera.main != (Object)null)
				{
					faceCam.CopyFrom(Camera.main);
				}
				faceCam.stereoTargetEye = (StereoTargetEyeMask)0;
				faceCam.depth = 100f;
			}
			faceCamObj.SetActive(true);
		}
		else if ((Object)(object)faceCamObj != (Object)null)
		{
			faceCamObj.SetActive(false);
		}
	}

	public override void OnLateUpdate()
	{
		//IL_006e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0074: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_0092: Unknown result type (might be due to invalid IL or missing references)
		//IL_0097: Unknown result type (might be due to invalid IL or missing references)
		//IL_009c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
		if (!isEnabled || (Object)(object)faceCamObj == (Object)null || (Object)(object)faceCam == (Object)null)
		{
			return;
		}
		try
		{
			if ((Object)(object)Player.RigManager != (Object)null)
			{
				Transform val = (((Object)(object)Player.Head != (Object)null) ? ((Component)Player.Head).transform : ((Component)Player.RigManager.physicsRig).transform);
				Vector3 val2 = val.position + val.forward * 0.8f + Vector3.up * 0.1f;
				faceCamObj.transform.position = Vector3.Lerp(faceCamObj.transform.position, val2, Time.deltaTime * smoothing);
				faceCamObj.transform.LookAt(val.position, Vector3.up);
			}
		}
		catch
		{
		}
	}
}