BBZoom.dll

Decompiled 2 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BBModMenu;
using BBZoom;
using HarmonyLib;
using MelonLoader;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.UIElements;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("BBZoom")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("BBZoom")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: MelonInfo(typeof(Zoom), "Beton Brutal Zoom Mod", "1.0.0", "MiaouZart", null)]
[assembly: MelonGame("", "Beton Brutal")]
[assembly: MelonAdditionalDependencies(new string[] { "BBModMenu" })]
[assembly: Guid("a2eb745a-4456-4035-a3c6-3eac55640783")]
[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 BBZoom;

public class Zoom : MelonMod
{
	[HarmonyPatch(typeof(GameUI), "Awake")]
	private static class PatchFlashLightAwake
	{
		[HarmonyPrefix]
		private static void HarmonyPatchCamera(GameUI __instance)
		{
			((Component)__instance).gameObject.AddComponent<BBZoomMod>();
		}
	}
}
public class BBZoomMod : MonoBehaviour
{
	public Camera cam;

	private readonly float _zoomSpeed = 10f;

	private readonly float _minFov = 10f;

	private readonly float _maxFov = 120f;

	private float _zoomvValue = 20f;

	private string _zoomKey;

	private void Start()
	{
		cam = Camera.main;
		GameUI component = GameObject.Find("GameUI").GetComponent<GameUI>();
		UIScreen? obj = ((typeof(GameUI).GetField("screens", BindingFlags.Instance | BindingFlags.NonPublic)?.GetValue(component) is List<UIScreen> source) ? ((IEnumerable<UIScreen>)source).FirstOrDefault((Func<UIScreen, bool>)((UIScreen screen) => screen is ModMenu)) : null);
		ModMenu val = (ModMenu)(object)((obj is ModMenu) ? obj : null);
		if (val == null)
		{
			MelonLogger.Msg("ModMenu not found");
			return;
		}
		string text = "Zoom";
		VisualElement val2 = val.AddSetting(text);
		VisualElement val3 = val.CreateWrapper();
		Label val4 = val.CreateLabel("Key to zoom");
		HotKeyEntry val5 = val.CreateHotKey(text, "ZoomKey", (KeyCode)99);
		_zoomKey = val5.Value;
		val5.OnChanged = (Action<string>)Delegate.Combine(val5.OnChanged, (Action<string>)delegate(string s)
		{
			_zoomKey = s;
		});
		val3.Add((VisualElement)(object)val4);
		val3.Add(val5.Root);
		val2.Add(val3);
	}

	private void Update()
	{
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		if (Utils.IsHotkeyHeld(_zoomKey))
		{
			cam.fieldOfView = _zoomvValue;
		}
		float y = ((InputControl<Vector2>)(object)Mouse.current.scroll).ReadValue().y;
		if (Mathf.Abs(y) > 0.01f && Utils.IsHotkeyHeld(_zoomKey))
		{
			_zoomvValue -= y * _zoomSpeed * Time.deltaTime;
			_zoomvValue = Mathf.Clamp(_zoomvValue, _minFov, _maxFov);
		}
	}
}