using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Reptile;
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(".NETFramework,Version=v4.8.1", FrameworkDisplayName = ".NET Framework 4.8.1")]
[assembly: AssemblyCompany("DynamicZoom")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1+e5b9b2af322a5f2cd341cd78e4e7d89536707c5b")]
[assembly: AssemblyProduct("Adjust camera zoom and drag with velocity")]
[assembly: AssemblyTitle("DynamicZoom")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.1.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 DynamicZoom
{
[BepInPlugin("goatgirl.DynamicZoom", "DynamicZoom", "1.0.1")]
[BepInProcess("Bomb Rush Cyberfunk.exe")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class DynamicZoom : BaseUnityPlugin
{
public const string PluginName = "DynamicZoom";
public const string PluginGUID = "goatgirl.DynamicZoom";
public const string PluginVersion = "1.0.1";
internal static Harmony Harmony = new Harmony("goatgirl.DynamicZoom");
internal static ManualLogSource Logger;
public static bool hasCamUtils = false;
public static float currentZoom;
public static float currentDrag;
private static AnimationCurve zoomCurve;
private static float zoomTime;
public static DynamicZoom Instance { get; private set; }
public string Directory => Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
public static ManualLogSource Log => Logger;
public static Player player
{
get
{
WorldHandler instance = WorldHandler.instance;
return (instance != null) ? instance.GetCurrentPlayer() : null;
}
}
private void Awake()
{
Logger = ((BaseUnityPlugin)this).Logger;
Log.LogInfo((object)"Plugin DynamicZoom is loaded!");
foreach (KeyValuePair<string, PluginInfo> pluginInfo in Chainloader.PluginInfos)
{
if (pluginInfo.Value.Metadata.GUID.Equals("com.Dragsun.Savestate"))
{
hasCamUtils = true;
}
}
Harmony.PatchAll();
DynamicZoomConfig.BindSettings(((BaseUnityPlugin)this).Config);
UpdateCurve();
}
public static void UpdateCurve()
{
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: 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)
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Expected O, but got Unknown
zoomCurve = new AnimationCurve((Keyframe[])(object)new Keyframe[2]
{
new Keyframe(0f, 0f, 0f, DynamicZoomConfig.zoomEaseOut.Value),
new Keyframe(1f, 1f, DynamicZoomConfig.zoomEaseIn.Value, 0f)
});
}
public static void SetDrag(GameplayCamera gcam)
{
if (DynamicZoomConfig.overrideDrag.Value)
{
if (DynamicZoomConfig.enableDynamicDrag.Value)
{
gcam.dragDistanceDefault = (gcam.dragDistanceMax = currentDrag);
return;
}
gcam.dragDistanceDefault = DynamicZoomConfig.dragDistanceDefault.Value;
gcam.dragDistanceMax = DynamicZoomConfig.dragDistanceMax.Value;
}
}
public static float UpdateZoomLevel()
{
float num = DynamicZoomConfig.zoomAdjustmentSpeed.Value * Core.dt;
float num2 = (DynamicZoomConfig.useTotalSpeed.Value ? player.GetTotalSpeed() : player.GetForwardSpeed()) / DynamicZoomConfig.maxPlayerSpeed.Value;
if (zoomTime < num2)
{
zoomTime = Mathf.Min(zoomTime + num, num2);
}
else if (zoomTime > num2)
{
zoomTime = Mathf.Max(zoomTime - num, num2);
}
float num3 = zoomCurve.Evaluate(zoomTime);
currentZoom = Mathf.Lerp(DynamicZoomConfig.minZoom.Value, DynamicZoomConfig.maxZoom.Value, num3);
currentDrag = Mathf.Lerp(DynamicZoomConfig.minDDrag.Value, DynamicZoomConfig.maxDDrag.Value, num3);
return currentZoom;
}
}
internal class DynamicZoomConfig
{
public static ConfigEntry<bool> useTotalSpeed;
public static ConfigEntry<float> maxPlayerSpeed;
public static ConfigEntry<bool> ignoreObstructions;
public static ConfigEntry<bool> enableDynamicZoom;
public static ConfigEntry<float> minZoom;
public static ConfigEntry<float> maxZoom;
public static ConfigEntry<float> zoomAdjustmentSpeed;
public static ConfigEntry<float> zoomEaseIn;
public static ConfigEntry<float> zoomEaseOut;
public static ConfigEntry<bool> overrideDrag;
public static ConfigEntry<float> dragDistanceDefault;
public static ConfigEntry<float> dragDistanceMax;
public static ConfigEntry<bool> enableDynamicDrag;
public static ConfigEntry<float> minDDrag;
public static ConfigEntry<float> maxDDrag;
public static ConfigEntry<float> xOffset;
public static ConfigEntry<float> yOffset;
public static ConfigEntry<float> defaultCameraHeight;
public static void BindSettings(ConfigFile Config)
{
useTotalSpeed = Config.Bind<bool>("1. Settings", "Use Total Speed", false, "Whether to use the player's forward speed or total speed to calculate camera distance.");
maxPlayerSpeed = Config.Bind<float>("1. Settings", "Max Player Speed (KM/H)", 200f, "The speed the player has to go to reach maximum camera distance.");
ignoreObstructions = Config.Bind<bool>("1. Settings", "Ignore Obstructions", false, "Whether to ignore any walls the camera would typically collide with when applying dynamic zoom.");
enableDynamicZoom = Config.Bind<bool>("2. Dynamic Zoom", "Enable Dynamic Zoom", true, "Adjust how far the camera is from the player relative to their speed.");
minZoom = Config.Bind<float>("2. Dynamic Zoom", "Minimum Camera Distance", 0f, "Minimum camera distance, relative to the game's default camera distance. Higher values are farther away, negative values are close-up.");
maxZoom = Config.Bind<float>("2. Dynamic Zoom", "Maximum Camera Distance", 3f, "Maximum camera distance, relative to the game's default camera distance. Higher values are farther away, negative values are close-up.");
zoomAdjustmentSpeed = Config.Bind<float>("2. Dynamic Zoom", "Zoom Adjustment Speed", 1f, (ConfigDescription)null);
zoomEaseIn = Config.Bind<float>("2. Dynamic Zoom", "Zoom Curve Ease In", 2f, (ConfigDescription)null);
zoomEaseIn.SettingChanged += UpdateSettingsEvent;
zoomEaseOut = Config.Bind<float>("2. Dynamic Zoom", "Zoom Curve Ease Out", 0f, (ConfigDescription)null);
zoomEaseOut.SettingChanged += UpdateSettingsEvent;
overrideDrag = Config.Bind<bool>("3. Dynamic Drag", "Apply Camera Drag Settings", true, "Overrides SaveStatesAndCamUtils' camera drag settings. If set to false, all drag settings below (both vanilla and dynamic drag) will be disabled, and (if present) the SaveStatesAndCamUtils drag settings will apply instead.");
enableDynamicDrag = Config.Bind<bool>("3. Dynamic Drag", "Enable Dynamic Camera Drag", false, "Change camera drag values along with dynamic zoom. Will match the zoom's adjustment curve and speed. Can be used along with dynamic zoom or standalone.");
minDDrag = Config.Bind<float>("3. Dynamic Drag", "(Dynamic) Minimum Drag Distance", 3f, "Minimum camera drag. Higher values lead to the camera dragging further behind, while lower values will stay closer to the player.");
maxDDrag = Config.Bind<float>("3. Dynamic Drag", "(Dynamic) Maximum Drag Distance", 5f, "Maximum camera drag. Higher values lead to the camera dragging further behind, while lower values will stay closer to the player.");
dragDistanceDefault = Config.Bind<float>("3. Dynamic Drag", "(Vanilla) Default Drag Distance", 2.9f, "Overrides SaveStatesAndCamUtils. Will not apply if dynamic drag is enabled.");
dragDistanceMax = Config.Bind<float>("3. Dynamic Drag", "(Vanilla) Maximum Drag Distance", 3.55f, "Overrides SaveStatesAndCamUtils. Will not apply if dynamic drag is enabled.");
xOffset = Config.Bind<float>("4. Misc.", "Camera X Offset", 0f, (ConfigDescription)null);
yOffset = Config.Bind<float>("4. Misc.", "Camera Y Offset", 0f, (ConfigDescription)null);
defaultCameraHeight = Config.Bind<float>("4. Misc.", "Default Camera Height", 2f, "2 is vanilla");
}
public static void UpdateSettingsEvent(object sender, EventArgs args)
{
DynamicZoom.UpdateCurve();
}
}
[HarmonyPatch(typeof(GameplayCamera))]
internal class GameplayCameraPatches
{
[HarmonyPostfix]
[HarmonyPatch("UpdateCamera")]
[HarmonyPriority(200)]
private static void Postfix_UpdateGameplayCamera(GameplayCamera __instance)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: 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_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: 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_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: 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_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
Vector3 val = __instance.realTf.position;
Vector3 position = __instance.realTf.position;
Vector3 val2 = ((Component)__instance).transform.forward * (0f - DynamicZoom.UpdateZoomLevel());
if (DynamicZoomConfig.enableDynamicZoom.Value)
{
val += val2;
}
Vector3 val3 = default(Vector3);
((Vector3)(ref val3))..ctor(DynamicZoomConfig.xOffset.Value, DynamicZoomConfig.yOffset.Value, 0f);
val += val3;
if (!DynamicZoomConfig.ignoreObstructions.Value)
{
bool wasObstructed = __instance.cameraMode.wasObstructed;
bool lerpDefaultDistance = __instance.cameraMode.lerpDefaultDistance;
val = __instance.cameraMode.HandleObstructions(val);
__instance.cameraMode.wasObstructed = wasObstructed;
__instance.cameraMode.lerpDefaultDistance = lerpDefaultDistance;
}
__instance.realTf.position = val;
DynamicZoom.SetDrag(__instance);
__instance.defaultCamHeight = DynamicZoomConfig.defaultCameraHeight.Value;
}
}
internal class DragPatch
{
[HarmonyPostfix]
[HarmonyPriority(200)]
[HarmonyAfter(new string[] { "com.Dragsun.Savestate" })]
[HarmonyPatch(typeof(Player), "Awake")]
[HarmonyPatch(typeof(WorldHandler), "Awake")]
[HarmonyPatch(typeof(CameraRegisterer), "UpdateCameraFov")]
[HarmonyPatch("UpdateCamera")]
private static void DragPostfix()
{
if (DynamicZoom.hasCamUtils)
{
DynamicZoom.SetDrag(GameplayCamera.instance);
}
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "DynamicZoom";
public const string PLUGIN_NAME = "Adjust camera zoom and drag with velocity";
public const string PLUGIN_VERSION = "1.0.1";
}
}