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 BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using PreciseRotation.Utils; using UnityEngine; using UnityEngine.InputSystem; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("PreciseRotation")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("PreciseRotation")] [assembly: AssemblyTitle("PreciseRotation")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [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 PreciseRotation { [BepInPlugin("dev.zag.PreciseRotation", "PreciseRotation", "1.0.0")] public class Plugin : BaseUnityPlugin { public const string modGUID = "dev.zag.PreciseRotation"; public const string modName = "PreciseRotation"; public const string modVersion = "1.0.0"; private static Harmony _harmony = new Harmony("dev.zag.PreciseRotation"); internal static ManualLogSource mls = Logger.CreateLogSource("dev.zag.PreciseRotation"); private void Awake() { mls.LogInfo((object)"Loading PreciseRotation"); ModConfig.allConfigs(((BaseUnityPlugin)this).Config); patchAllStuff(); } private static void patchAllStuff() { _harmony.PatchAll(); } } public static class PluginInfo { public const string PLUGIN_GUID = "PreciseRotation"; public const string PLUGIN_NAME = "PreciseRotation"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace PreciseRotation.Utils { internal class ModConfig { private static bool printConfigs = true; public static ConfigEntry rotationAngle; public static void allConfigs(ConfigFile cfg) { rotationAngle = cfg.Bind("General", "Rotation Angle", 45, "Enter a value from 5° to 90°. Values outside this range can cause crashes or are useless."); if (printConfigs) { printConfig(); } } private static void printConfig() { Plugin.mls.LogInfo((object)$"Rotation Angle: {rotationAngle.Value}"); } } } namespace PreciseRotation.Patches { [HarmonyPatch(typeof(ShipBuildModeManager))] internal class ShipBuildModeManagerPatch { private const float timeUntilSpin = 0.25f; private static float pressedTimer; private static bool wasPressed; [HarmonyPatch("Update")] [HarmonyPrefix] public static void UpdatePrePatch(out float __state, ShipBuildModeManager __instance) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) __state = 0f; if (__instance.InBuildMode && !((Object)(object)__instance.ghostObject == (Object)null)) { __state = __instance.ghostObject.eulerAngles.y; } } [HarmonyPatch("Update")] [HarmonyPostfix] public static void UpdatePostPatch(float __state, ShipBuildModeManager __instance) { //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) if (!__instance.InBuildMode) { return; } InputAction obj = InputSystem.actions.FindAction("ReloadBatteries", false); if (obj.IsPressed()) { pressedTimer += Time.deltaTime; wasPressed = true; if (pressedTimer > 0.25f) { float num = __state + Time.deltaTime * 155f; __instance.ghostObject.eulerAngles = new Vector3(__instance.ghostObject.eulerAngles.x, num, __instance.ghostObject.eulerAngles.z); } } if (obj.WasReleasedThisFrame() && wasPressed) { if (pressedTimer <= 0.25f) { float num2 = Mathf.Ceil(__state / (float)ModConfig.rotationAngle.Value) * (float)ModConfig.rotationAngle.Value; __instance.ghostObject.eulerAngles = new Vector3(__instance.ghostObject.eulerAngles.x, num2, __instance.ghostObject.eulerAngles.z); Plugin.mls.LogInfo((object)"Rotate Snapped"); } pressedTimer = 0f; wasPressed = false; } } } }