Decompiled source of Free Cammer v1.0.2

FreeCammer.dll

Decompiled 2 years ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using FreeCammer.Scripts;
using GameNetcodeStuff;
using HarmonyLib;
using Unity.Netcode;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("FreeCammer")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("FreeCammer")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("a9c64b17-f023-4fda-931b-d9b7e62bad35")]
[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 FreeCammer
{
	[BepInPlugin("grug.lethalcompany.freecammer", "Free Cammer", "0.1.0.1")]
	public class MyCammer : BaseUnityPlugin
	{
		public const string modGUID = "grug.lethalcompany.freecammer";

		public const string modName = "Free Cammer";

		public const string modVersion = "0.1.0.1";

		private static GameObject cammerHolder;

		private readonly Harmony harmony = new Harmony("grug.lethalcompany.freecammer");

		public static ManualLogSource mls;

		private static MyCammer instance;

		public void Awake()
		{
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Expected O, but got Unknown
			if ((Object)(object)instance == (Object)null)
			{
				instance = this;
			}
			mls = Logger.CreateLogSource("grug.lethalcompany.freecammer");
			mls.LogInfo((object)"Cammer Loaded!!!");
			if ((Object)(object)cammerHolder == (Object)null)
			{
				cammerHolder = new GameObject("cammerHolder");
				Object.DontDestroyOnLoad((Object)(object)cammerHolder);
				((Object)cammerHolder).hideFlags = (HideFlags)61;
				cammerHolder.AddComponent<CammerScript>();
			}
			if ((Object)(object)cammerHolder != (Object)null)
			{
				mls.LogInfo((object)"Cammer not null");
				if ((Object)(object)cammerHolder.GetComponent<CammerScript>() != (Object)null)
				{
					mls.LogInfo((object)"CammerScript not null");
				}
			}
		}
	}
}
namespace FreeCammer.Scripts
{
	internal class CammerScript : MonoBehaviour
	{
		public bool inCammer = false;

		public float speed = 10f;

		public Camera cammer;

		public PlayerControllerB me;

		private GameObject myarms;

		private Renderer myhead;

		private LODGroup lodg;

		private float x;

		private float y;

		private float lastFrameX;

		private float lastFrameY;

		private float mouseDeltaX;

		private float mouseDeltaY;

		private Vector3 rotateValue;

		public void Awake()
		{
			MyCammer.mls.LogInfo((object)"Script Active");
		}

		public void Update()
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: 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_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_027e: Unknown result type (might be due to invalid IL or missing references)
			//IL_028e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0299: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_024b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e3: 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_02f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0328: Unknown result type (might be due to invalid IL or missing references)
			//IL_0338: Unknown result type (might be due to invalid IL or missing references)
			//IL_0343: Unknown result type (might be due to invalid IL or missing references)
			//IL_034d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0352: Unknown result type (might be due to invalid IL or missing references)
			//IL_037d: Unknown result type (might be due to invalid IL or missing references)
			//IL_038d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0398: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a7: Unknown result type (might be due to invalid IL or missing references)
			lastFrameX = x;
			lastFrameY = y;
			x = UnityInput.Current.mousePosition.x;
			y = UnityInput.Current.mousePosition.y;
			mouseDeltaX = x - lastFrameX;
			mouseDeltaY = y - lastFrameY;
			if (UnityInput.Current.GetMouseButton(1))
			{
				rotateValue = new Vector3(mouseDeltaY, mouseDeltaX * -1f, 0f) * 0.1f;
				((Component)this).transform.eulerAngles = ((Component)this).transform.eulerAngles - rotateValue;
			}
			if ((Object)(object)me == (Object)null)
			{
				PlayerControllerB[] array = Object.FindObjectsOfType<PlayerControllerB>();
				foreach (PlayerControllerB val in array)
				{
					if (((NetworkBehaviour)val).IsOwner)
					{
						me = val;
						myarms = ((Component)me.cameraContainerTransform.parent.GetChild(1)).gameObject;
						myhead = GameObject.Find("Systems/Rendering/PlayerHUDHelmetModel/ScavengerHelmet").GetComponent<Renderer>();
						if (Object.op_Implicit((Object)(object)((Component)me).GetComponentInChildren<LODGroup>()))
						{
							lodg = ((Component)me).GetComponentInChildren<LODGroup>();
						}
					}
				}
			}
			if ((Object)(object)cammer == (Object)null)
			{
				cammer = ((Component)this).gameObject.AddComponent<Camera>();
				((Behaviour)cammer).enabled = false;
				if ((Object)(object)((Component)this).gameObject.GetComponent<Camera>() != (Object)null)
				{
					MyCammer.mls.LogInfo((object)"Cammer Added!");
					cammer.cullingMask = 20649983;
				}
			}
			if (UnityInput.Current.GetKeyDown((KeyCode)91))
			{
				((Behaviour)cammer).enabled = !((Behaviour)cammer).enabled;
				inCammer = !inCammer;
				if ((Object)(object)me != (Object)null)
				{
					((Component)cammer).transform.position = ((Component)me.gameplayCamera).transform.position;
				}
				ChangeStates();
			}
			if (UnityInput.Current.GetKey((KeyCode)117))
			{
				Transform transform = ((Component)cammer).transform;
				transform.position += ((Component)cammer).transform.forward * speed * Time.deltaTime;
			}
			if (UnityInput.Current.GetKey((KeyCode)106))
			{
				Transform transform2 = ((Component)cammer).transform;
				transform2.position -= ((Component)cammer).transform.forward * speed * Time.deltaTime;
			}
			if (UnityInput.Current.GetKey((KeyCode)104))
			{
				Transform transform3 = ((Component)cammer).transform;
				transform3.position -= ((Component)cammer).transform.right * speed * Time.deltaTime;
			}
			if (UnityInput.Current.GetKey((KeyCode)107))
			{
				Transform transform4 = ((Component)cammer).transform;
				transform4.position += ((Component)cammer).transform.right * speed * Time.deltaTime;
			}
		}

		public void ChangeStates()
		{
			me.inSpecialInteractAnimation = inCammer;
			myarms.SetActive(!inCammer);
			Cursor.visible = inCammer;
			myhead.forceRenderingOff = inCammer;
			if ((Object)(object)lodg != (Object)null)
			{
				lodg.enabled = !inCammer;
			}
			if (inCammer && (Object)(object)me != (Object)null)
			{
				Cursor.lockState = (CursorLockMode)2;
			}
			else if ((Object)(object)me != (Object)null && !me.quickMenuManager.isMenuOpen)
			{
				Cursor.lockState = (CursorLockMode)1;
			}
		}
	}
}