using System;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
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: AssemblyTitle("Erenshor-Dynamic-Cam")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Erenshor-Dynamic-Cam")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("f5bc46b6-4ba8-400e-acac-46f6b3eeea77")]
[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 Erenshor_Dynamic_Cam;
internal class DynamicCam : MonoBehaviour
{
private GameObject playerCameraTarget;
private bool dynamicCamEnabled = false;
private Vector3 originalPosition;
public void OnDestroy()
{
SceneManager.activeSceneChanged -= OnSceneChanged;
}
public void OnSceneChanged(Scene oldScene, Scene newScene)
{
//IL_0066: 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_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
if (!SceneValidator.IsValidScene(((Scene)(ref newScene)).name))
{
Debug.Log((object)"Scene is not valid for DynamicCam Check - Skipping Cam Check");
return;
}
playerCameraTarget = ((Component)GameObject.Find("Player").transform.Find("CamTar (1)")).gameObject;
if ((Object)(object)playerCameraTarget == (Object)null)
{
Debug.LogError((object)"Could not find the camera target object");
}
else if (originalPosition == Vector3.zero)
{
originalPosition = playerCameraTarget.transform.localPosition;
}
}
public void Update()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
if (Input.GetKeyDown(Mod.toggleKey.Value))
{
Toggle();
}
}
public void Toggle()
{
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
dynamicCamEnabled = !dynamicCamEnabled;
if (dynamicCamEnabled)
{
playerCameraTarget.transform.localPosition = new Vector3(Mod.cameraX.Value, Mod.cameraY.Value, Mod.cameraZ.Value);
}
else
{
playerCameraTarget.transform.localPosition = originalPosition;
}
}
}
[BepInPlugin("org.lenzork.dynamiccam", "Dynamic Cam", "1.0.1")]
public class Mod : BaseUnityPlugin
{
public static ConfigEntry<float> cameraX;
public static ConfigEntry<float> cameraY;
public static ConfigEntry<float> cameraZ;
public static ConfigEntry<KeyCode> toggleKey;
public void Awake()
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Expected O, but got Unknown
((BaseUnityPlugin)this).Logger.LogInfo((object)"Dynamic Cam loaded");
CreateConfig();
GameObject val = new GameObject("DynamicCam");
val.AddComponent<DynamicCam>();
SceneManager.activeSceneChanged += val.GetComponent<DynamicCam>().OnSceneChanged;
Object.DontDestroyOnLoad((Object)(object)val);
}
public void CreateConfig()
{
cameraX = ((BaseUnityPlugin)this).Config.Bind<float>("Camera", "X", 1f, "X position of the camera");
cameraY = ((BaseUnityPlugin)this).Config.Bind<float>("Camera", "Y", -0f, "Y position of the camera");
cameraZ = ((BaseUnityPlugin)this).Config.Bind<float>("Camera", "Z", 1f, "Z position of the camera");
toggleKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Controls", "Key", (KeyCode)308, "Key to toggle the dynamic camera");
((BaseUnityPlugin)this).Logger.LogInfo((object)"Config created");
}
}
internal static class SceneValidator
{
private static string[] InvalidScenes = new string[2] { "Menu", "LoadScene" };
public static bool IsValidScene(string sceneName)
{
return !InvalidScenes.Contains<string>(sceneName, StringComparer.OrdinalIgnoreCase);
}
}