using System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("Build Camera Focus")] [assembly: AssemblyProduct("Build Camera Focus")] [assembly: ComVisible(false)] [assembly: Guid("8a83b49b-7176-4d1e-8515-dca4b8737746")] [assembly: AssemblyFileVersion("0.1.0.0")] [assembly: AssemblyVersion("0.1.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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 BuildCameraFocus { [BepInPlugin("com.cotl.betterbuildertools.buildcamerafocus", "Build Camera Focus", "0.1.0")] public sealed class BuildCameraFocusPlugin : BaseUnityPlugin { public const string PluginGuid = "com.cotl.betterbuildertools.buildcamerafocus"; public const string PluginName = "Build Camera Focus"; public const string PluginVersion = "0.1.0"; private Harmony _harmony; internal static ManualLogSource Log { get; private set; } internal static BuildCameraFocusPlugin Instance { get; private set; } private void Awake() { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown Instance = this; Log = ((BaseUnityPlugin)this).Logger; BuildCameraFocusConfig.Bind(((BaseUnityPlugin)this).Config); _harmony = new Harmony("com.cotl.betterbuildertools.buildcamerafocus"); _harmony.PatchAll(typeof(BuildCameraFocusPlugin).Assembly); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Build Camera Focus 0.1.0 loaded."); } private void OnDestroy() { Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } _harmony = null; Instance = null; } internal void Focus(CameraFollowTarget followTarget) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003c: 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_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: 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_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) if (BuildCameraFocusConfig.Enabled.Value && !((Object)(object)followTarget == (Object)null) && !((Object)(object)PlacementObject.Instance == (Object)null)) { Vector3 val = ((Component)PlacementObject.Instance).transform.position + Vector3.back * 0.5f; float value = BuildCameraFocusConfig.CameraDistance.Value; float num = BuildCameraFocusConfig.CameraAngle.Value * ((float)Math.PI / 180f); Vector3 val2 = val + new Vector3(0f, value * Mathf.Sin(num), (0f - value) * Mathf.Cos(num)); float num2 = 1f - Mathf.Exp((0f - BuildCameraFocusConfig.FollowSharpness.Value) * Time.unscaledDeltaTime); Vector3 val3 = Vector3.Lerp(((Component)followTarget).transform.position, val2, num2); ((Component)followTarget).transform.position = val3; ((Component)followTarget).transform.rotation = Quaternion.Euler(BuildCameraFocusConfig.CameraAngle.Value, 0f, 0f); followTarget.CurrentPosition = val3; followTarget.CurrentTargetCameraPosition = val3; } } } internal static class BuildCameraFocusConfig { internal static ConfigEntry Enabled; internal static ConfigEntry CameraDistance; internal static ConfigEntry CameraAngle; internal static ConfigEntry FollowSharpness; internal static void Bind(ConfigFile config) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Expected O, but got Unknown //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Expected O, but got Unknown Enabled = config.Bind("General", "Enabled", true, "Enable Build Camera Focus."); CameraDistance = config.Bind("Camera", "CameraDistance", 11f, new ConfigDescription("Camera distance while following the placement object.", (AcceptableValueBase)(object)new AcceptableValueRange(4f, 30f), Array.Empty())); CameraAngle = config.Bind("Camera", "CameraAngle", -45f, new ConfigDescription("Camera pitch while following the placement object.", (AcceptableValueBase)(object)new AcceptableValueRange(-80f, -15f), Array.Empty())); FollowSharpness = config.Bind("Camera", "FollowSharpness", 16f, new ConfigDescription("How quickly the camera follows placement.", (AcceptableValueBase)(object)new AcceptableValueRange(1f, 80f), Array.Empty())); } } [HarmonyPatch(typeof(CameraFollowTarget), "LateUpdate")] internal static class CameraFollowTargetLateUpdatePatch { private static void Postfix(CameraFollowTarget __instance) { BuildCameraFocusPlugin.Instance?.Focus(__instance); } } }