Decompiled source of WoodzCameraTweaks v1.2.0

WoodzCamera.dll

Decompiled 2 weeks ago
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 HarmonyLib;
using Microsoft.CodeAnalysis;
using Reptile;
using UnityEngine;
using UnityEngine.SceneManagement;

[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.6", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("WoodzCamera")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Camera tweaks for Bomb Rush Cyberfunk")]
[assembly: AssemblyFileVersion("1.2.0.0")]
[assembly: AssemblyInformationalVersion("1.2.0")]
[assembly: AssemblyProduct("WoodzCamera")]
[assembly: AssemblyTitle("WoodzCamera")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.2.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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace woodzcamera
{
	[BepInPlugin("info.mariobluegloves.woodzcamerap", "Woodz Camera Tweaks", "1.2.0")]
	[BepInProcess("Bomb Rush Cyberfunk.exe")]
	public class WoodzCameraTweaks : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(StageChunk), "UpdateChunk")]
		public class Patch_UpdateChunk
		{
			public static void Prefix(ref bool __runOriginal)
			{
				if (CameraTweaksWoodz.applyWoodzChunkPatches.Value)
				{
					__runOriginal = false;
				}
				else
				{
					__runOriginal = true;
				}
			}

			public static void Postfix(StageChunk __instance)
			{
				//IL_002c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0031: Unknown result type (might be due to invalid IL or missing references)
				//IL_0033: Unknown result type (might be due to invalid IL or missing references)
				//IL_003b: Unknown result type (might be due to invalid IL or missing references)
				if (CameraTweaksWoodz.applyWoodzChunkPatches.Value)
				{
					if (!__instance.isActive)
					{
						__instance.ActivateChunk(true);
					}
					Vector3 currentCameraPosition = WorldHandler.instance.CurrentCameraPosition;
					__instance.UpdateStreetLife(currentCameraPosition);
					__instance.UpdateMoveObjects(currentCameraPosition);
					JunkBehaviour.JunkUpdate(__instance.junkBehaviour, Core.dt);
				}
			}
		}

		private float updateTimer = 0f;

		private bool sceneLoaded = false;

		private bool enabledIsoCam = false;

		private const double N = 1.5;

		private const double S = 12.5;

		private const double J = 3.0;

		private const double A = 45.0;

		private const double M = 100.0;

		private const double O = -1.0;

		private const double T = 10.0;

		private void Awake()
		{
			SceneManager.sceneLoaded += OnSceneLoaded;
		}

		private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
		{
			sceneLoaded = true;
		}

		private void Update()
		{
			//IL_00df: 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)
			updateTimer += Time.deltaTime;
			if (updateTimer < 1f || !sceneLoaded)
			{
				return;
			}
			if (!CameraTweaksWoodz.isometricCam.Value)
			{
				GameObject val = GameObject.Find("gameplayCamera(Clone)");
				if (!((Object)(object)val != (Object)null))
				{
					return;
				}
				Camera component = val.GetComponent<Camera>();
				GameplayCamera component2 = val.GetComponent<GameplayCamera>();
				if ((Object)(object)component2 != (Object)null && (Object)(object)component != (Object)null)
				{
					component.farClipPlane = CameraTweaksWoodz.setCulling.Value;
					component2.joystickFactor = CameraTweaksWoodz.setJoy.Value;
					component2.lookAngleHighest = 89f;
					component2.lookAngleLowest = -89f;
					if (Input.GetKey(CameraTweaksWoodz.holdOfd.Value))
					{
						component2.orbitFadeDuration = CameraTweaksWoodz.setOfd2.Value;
					}
					else
					{
						component2.orbitFadeDuration = CameraTweaksWoodz.setOfd.Value;
					}
					if (Input.GetKeyUp(CameraTweaksWoodz.holdOfd.Value))
					{
						component2.orbitFadeDuration = CameraTweaksWoodz.setOfd.Value;
					}
					if (enabledIsoCam)
					{
						component.orthographic = false;
						component.nearClipPlane = 0.1f;
						component2.maxAbovePlayer = 4.15f;
						component2.topLocalLookAt = 1.4f;
						enabledIsoCam = false;
					}
				}
				return;
			}
			GameObject val2 = GameObject.Find("gameplayCamera(Clone)");
			if (!((Object)(object)val2 != (Object)null))
			{
				return;
			}
			Camera component3 = val2.GetComponent<Camera>();
			GameplayCamera component4 = val2.GetComponent<GameplayCamera>();
			if ((Object)(object)component4 != (Object)null && (Object)(object)component3 != (Object)null)
			{
				float farClipPlane = (component3.farClipPlane = 1000f);
				component3.farClipPlane = farClipPlane;
				component3.orthographicSize = 12.5f;
				component4.joystickFactor = CameraTweaksWoodz.setJoy.Value;
				component4.lookAngleHighest = 45f;
				component4.lookAngleLowest = 45f;
				component4.orbitFadeDuration = -1f;
				if (!enabledIsoCam)
				{
					component3.orthographic = true;
					component3.nearClipPlane = 1.5f;
					component4.maxAbovePlayer = 100f;
					component4.topLocalLookAt = 10f;
					enabledIsoCam = true;
				}
			}
		}

		[HarmonyPatch(typeof(GrindAbility), "Init")]
		[HarmonyPostfix]
		public static void InitGRPatch(GrindAbility __instance)
		{
			if (CameraTweaksWoodz.setOfd.Value < 0f)
			{
				((Ability)__instance).customCameraMode = null;
			}
		}

		[HarmonyPatch(typeof(WallrunLineAbility), "Init")]
		[HarmonyPostfix]
		public static void InitWRPatch(WallrunLineAbility __instance)
		{
			if (CameraTweaksWoodz.applyWoodzWallrideCamPatch.Value)
			{
				((Ability)__instance).customCameraMode = null;
			}
		}

		[HarmonyPatch(typeof(WallrunLineAbility), "FixedUpdateAbility")]
		[HarmonyPostfix]
		public static void UpdateWRPatch(WallrunLineAbility __instance)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Expected O, but got Unknown
			if (CameraTweaksWoodz.applyWoodzWallrideCamPatch.Value)
			{
				((Ability)__instance).customCameraMode = null;
			}
			else
			{
				((Ability)__instance).customCameraMode = (CameraMode)new CameraModeWallrun(__instance);
			}
		}

		[HarmonyPatch(typeof(VertAbility), "Init")]
		[HarmonyPostfix]
		public static void InitVertPatch(VertAbility __instance)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Expected O, but got Unknown
			if (CameraTweaksWoodz.applyWoodzVertCamPatch.Value)
			{
				((Ability)__instance).customCameraMode = null;
			}
			else
			{
				((Ability)__instance).customCameraMode = (CameraMode)new CameraModeVert(__instance);
			}
		}

		[HarmonyPatch(typeof(HandplantAbility), "Init")]
		[HarmonyPostfix]
		public static void InitHandplantPatch(HandplantAbility __instance)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Expected O, but got Unknown
			if (CameraTweaksWoodz.applyWoodzHandplantCamPatch.Value)
			{
				((Ability)__instance).customCameraMode = null;
			}
			else
			{
				((Ability)__instance).customCameraMode = (CameraMode)new CameraModeHandplant(__instance);
			}
		}

		[HarmonyPatch(typeof(GameplayCamera), "CameraZoneActive")]
		[HarmonyPrefix]
		public static bool CameraZoneActivePatch(GameplayCamera __instance)
		{
			if (CameraTweaksWoodz.disableCameraZones.Value)
			{
				return false;
			}
			return true;
		}
	}
	[BepInPlugin("info.mariobluegloves.woodzcamera", "Woodz Camera Tweaks", "1.2.0")]
	[BepInProcess("Bomb Rush Cyberfunk.exe")]
	public class CameraTweaksWoodz : BaseUnityPlugin
	{
		private float configTimer = 0f;

		public static ConfigEntry<bool> applyWoodzChunkPatches;

		public static ConfigEntry<bool> applyWoodzWallrideCamPatch;

		public static ConfigEntry<bool> applyWoodzVertCamPatch;

		public static ConfigEntry<bool> applyWoodzHandplantCamPatch;

		public static ConfigEntry<float> setCulling;

		public static ConfigEntry<float> setOfd;

		public static ConfigEntry<float> setOfd2;

		public static ConfigEntry<KeyCode> holdOfd;

		public static ConfigEntry<float> setJoy;

		public static ConfigEntry<bool> disableCameraZones;

		public static ConfigEntry<bool> isometricCam;

		public void Awake()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			Harmony val = new Harmony("info.mariobluegloves.woodzcamerap");
			val.PatchAll();
			val.PatchAll(typeof(WoodzCameraTweaks));
		}

		private void Update()
		{
			configTimer += Time.deltaTime;
			if (!(configTimer < 1f))
			{
				configTimer = 0f;
				applyWoodzChunkPatches = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "KeepChunksLoaded", false, "Keeps chunks always loaded regardless of camera position. Not recommended for low-end PCs. Will cause problems on certain maps, for example Brink Terminal's LOD.");
				applyWoodzWallrideCamPatch = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "DisableWallrideCam", false, "Disables the wallride custom camera.");
				applyWoodzVertCamPatch = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "DisableVertCam", false, "Disables the vert custom camera. (Requires map restart to take effect.)");
				applyWoodzHandplantCamPatch = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "DisableHandplantCam", false, "Disables the handplant/invert custom camera. (Requires map restart to take effect.)");
				setCulling = ((BaseUnityPlugin)this).Config.Bind<float>("Settings", "SetClipping", 1000f, "Sets the far clip plane, which is what cuts off things from being rendered at a distance. Set higher to have things that are further away be rendered that normally wouldn't.");
				setOfd = ((BaseUnityPlugin)this).Config.Bind<float>("Settings", "SetOfd", 5f, "Sets the orbit fade duration. Set this to -1 to disable camera's automatic re-centering (and custom grind camera,) set to 5 for vanilla, lower will be a higher time it will take to re-center and higher will be a lower one.");
				setJoy = ((BaseUnityPlugin)this).Config.Bind<float>("Settings", "SetJoy", 1.5f, "Sets joystick sensitivity. This is a separate value than the one in your options menu which will scale this one, so feel free to set both. Vanilla is 1.5.");
				holdOfd = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Settings", "Set second OFD", (KeyCode)339, "Hold this key/button to set your OFD to your second OFD value. Requires camera stick input to reset back to first OFD value.");
				setOfd2 = ((BaseUnityPlugin)this).Config.Bind<float>("Settings", "SetOfd2", 0f, "Which OFD to use while holding the set OFD key/button.");
				disableCameraZones = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "DisableCameraZones", false, "Disables camera zones.)");
				isometricCam = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "IsometricCam", false, "Toggle isometric camera.)");
			}
		}
	}
}