From 4336412a9778e8274ac1ddfd7d24f9ab9aeaa8ba Mon Sep 17 00:00:00 2001 From: Aleksandr Date: Mon, 1 Nov 2021 23:23:08 +0500 Subject: [PATCH] Update for OWML 2.X --- OW_SmoothThrust/OW_SmoothThrust.csproj | 36 ++++++++++++++-------- OW_SmoothThrust/SmoothThrust.cs | 42 +++++++++++++++----------- OW_SmoothThrust/manifest.json | 4 +-- 3 files changed, 49 insertions(+), 33 deletions(-) diff --git a/OW_SmoothThrust/OW_SmoothThrust.csproj b/OW_SmoothThrust/OW_SmoothThrust.csproj index e56991c..b501dac 100644 --- a/OW_SmoothThrust/OW_SmoothThrust.csproj +++ b/OW_SmoothThrust/OW_SmoothThrust.csproj @@ -9,9 +9,10 @@ Properties OW_SmoothThrust OW_SmoothThrust - v3.5 + v4.0 512 true + true @@ -32,34 +33,43 @@ - ..\packages\Lib.Harmony.1.2.0.1\lib\net35\0Harmony.dll + ..\..\..\..\..\..\Games\Steam\steamapps\common\Outer Wilds\OuterWilds_Data\Managed\0Harmony.dll - ..\..\..\..\Games\Outer Wilds\OuterWilds_Data\Managed\Assembly-CSharp.dll + ..\..\..\..\..\..\Games\Steam\steamapps\common\Outer Wilds\OuterWilds_Data\Managed\Assembly-CSharp.dll - ..\packages\OWML.0.3.46\lib\net35\NAudio-Unity.dll + ..\..\..\..\..\..\Games\Steam\steamapps\common\Outer Wilds\OuterWilds_Data\Managed\NAudio-Unity.dll + + + ..\..\..\..\..\..\Games\Steam\steamapps\common\Outer Wilds\OuterWilds_Data\Managed\netstandard.dll - ..\packages\Json.Net.Unity3D.9.0.1\lib\net35\Newtonsoft.Json.dll + ..\..\..\..\..\..\Games\Steam\steamapps\common\Outer Wilds\OuterWilds_Data\Managed\Newtonsoft.Json.dll ..\packages\OWML.0.3.46\lib\net35\OWML.dll + + ..\..\..\..\..\..\Games\Steam\steamapps\common\Outer Wilds\OuterWilds_Data\Managed\OWML.Abstractions.dll + - ..\packages\OWML.0.3.46\lib\net35\OWML.Common.dll + ..\..\..\..\..\..\Games\Steam\steamapps\common\Outer Wilds\OuterWilds_Data\Managed\OWML.Common.dll - - ..\packages\OWML.0.3.46\lib\net35\OWML.ModHelper.dll + + ..\..\..\..\..\..\Games\Steam\steamapps\common\Outer Wilds\OuterWilds_Data\Managed\OWML.ModHelper.dll - ..\packages\OWML.0.3.46\lib\net35\OWML.ModHelper.Assets.dll + ..\..\..\..\..\..\Games\Steam\steamapps\common\Outer Wilds\OuterWilds_Data\Managed\OWML.ModHelper.Assets.dll - ..\packages\OWML.0.3.46\lib\net35\OWML.ModHelper.Events.dll + ..\..\..\..\..\..\Games\Steam\steamapps\common\Outer Wilds\OuterWilds_Data\Managed\OWML.ModHelper.Events.dll - ..\packages\OWML.0.3.46\lib\net35\OWML.ModHelper.Menus.dll + ..\..\..\..\..\..\Games\Steam\steamapps\common\Outer Wilds\OuterWilds_Data\Managed\OWML.ModHelper.Menus.dll + + + ..\..\..\..\..\..\Games\Steam\steamapps\common\Outer Wilds\OuterWilds_Data\Managed\OWML.Utils.dll @@ -68,10 +78,10 @@ - ..\..\..\..\Games\Outer Wilds\OuterWilds_Data\Managed\UnityEngine.dll + ..\..\..\..\..\..\Games\Steam\steamapps\common\Outer Wilds\OuterWilds_Data\Managed\UnityEngine.dll - ..\..\..\..\Games\Outer Wilds\OuterWilds_Data\Managed\UnityEngine.CoreModule.dll + ..\..\..\..\..\..\Games\Steam\steamapps\common\Outer Wilds\OuterWilds_Data\Managed\UnityEngine.CoreModule.dll diff --git a/OW_SmoothThrust/SmoothThrust.cs b/OW_SmoothThrust/SmoothThrust.cs index 82cdae3..15ba3ed 100644 --- a/OW_SmoothThrust/SmoothThrust.cs +++ b/OW_SmoothThrust/SmoothThrust.cs @@ -9,26 +9,26 @@ namespace TAI_SmoothThrust { class ThrusterModel_SmoothPatch { - public static void Prefix(ThrusterModel __instance, ref Vector3 input) + public static void Prefix(ThrusterModel __instance, ref Vector3 ____translationalInput) { if (!SmoothThrust.container.ContainsKey(__instance)) { SmoothThrust.container.Add(__instance, new SmoothThrust.SmoothCont()); } SmoothThrust.SmoothCont iter = SmoothThrust.container[__instance]; - if (OWInput.IsNewlyPressed(InputLibrary.interact, InputMode.All)) + if (OWInput.IsNewlyPressed(InputLibrary.interact)) { - iter._prevTranslation = input; + iter._prevTranslation = ____translationalInput; iter._buildupVelocity = Vector3.zero; } - if (input.magnitude > 0.0001f && OWInput.IsHeld(InputLibrary.interact, 0.05f, InputMode.All)) + if (OWInput.IsPressed(InputLibrary.interact, 0.05f)) { - iter._prevTranslation.x = Mathf.SmoothDamp(iter._prevTranslation.x, input.x, ref iter._buildupVelocity.x, SmoothThrust._analogSmoothTime); - iter._prevTranslation.z = Mathf.SmoothDamp(iter._prevTranslation.z, input.z, ref iter._buildupVelocity.z, SmoothThrust._analogSmoothTime); - iter._prevTranslation.y = Mathf.SmoothDamp(iter._prevTranslation.y, input.y, ref iter._buildupVelocity.y, SmoothThrust._analogSmoothTime); - input = iter._prevTranslation; + iter._prevTranslation.x = Mathf.SmoothDamp(iter._prevTranslation.x, ____translationalInput.x, ref iter._buildupVelocity.x, SmoothThrust._analogSmoothTime); + iter._prevTranslation.z = Mathf.SmoothDamp(iter._prevTranslation.z, ____translationalInput.z, ref iter._buildupVelocity.z, SmoothThrust._analogSmoothTime); + iter._prevTranslation.y = Mathf.SmoothDamp(iter._prevTranslation.y, ____translationalInput.y, ref iter._buildupVelocity.y, SmoothThrust._analogSmoothTime); + ____translationalInput = iter._prevTranslation; } - if (SmoothThrust.anglerSafety) + if (SmoothThrust.anglerSafety && (SmoothThrust.ShipNMBody != null || SmoothThrust.PlayerNMBody != null)) { Vector3 myPos; if (__instance is ShipThrusterModel) @@ -55,9 +55,9 @@ public static void Prefix(ThrusterModel __instance, ref Vector3 input) { if (mindist <= 400.1f) { - if (input.magnitude * __instance.GetMaxTranslationalThrust() >= mindist / 20f) + if (____translationalInput.magnitude * __instance.GetMaxTranslationalThrust() >= mindist / 20f) { - input = input.normalized * (mindist / 21f) / __instance.GetMaxTranslationalThrust(); + ____translationalInput = ____translationalInput.normalized * (mindist / 21f) / __instance.GetMaxTranslationalThrust(); } } } @@ -65,14 +65,14 @@ public static void Prefix(ThrusterModel __instance, ref Vector3 input) { if (mindist <= 210f) { - if (input.magnitude * 100f * __instance.GetMaxTranslationalThrust() >= mindist * 3f) + if (____translationalInput.magnitude * 100f * __instance.GetMaxTranslationalThrust() >= mindist * 3f) { - input = input.normalized * (mindist / 35f) / __instance.GetMaxTranslationalThrust(); + ____translationalInput = ____translationalInput.normalized * (mindist / 35f) / __instance.GetMaxTranslationalThrust(); } } } } - iter._prevTranslation = input; + iter._prevTranslation = ____translationalInput; SmoothThrust.container[__instance] = iter; } @@ -100,9 +100,11 @@ public class SmoothThrust : ModBehaviour { private void Start() { - ModHelper.HarmonyHelper.AddPrefix("AddTranslationalInput", typeof(ThrusterModel_SmoothPatch), "Prefix"); + ModHelper.HarmonyHelper.AddPrefix("FireTranslationalThrusters", typeof(ThrusterModel_SmoothPatch), "Prefix"); + ModHelper.HarmonyHelper.AddPrefix("FireTranslationalThrusters", typeof(ThrusterModel_SmoothPatch), "Prefix"); ModHelper.HarmonyHelper.AddPostfix("OnDestroy", typeof(ThrusterModel_SmoothPatch), "Postfix"); ModHelper.HarmonyHelper.AddPostfix("OnSectorOccupantsUpdated", typeof(ThrusterModel_SmoothPatch), "Angler_Postfix"); + console = ModHelper.Console; ModHelper.Console.WriteLine("Smooth Thrust Ready!"); } public override void Configure(IModConfig config) @@ -116,15 +118,18 @@ private void Update() if (LoadManager.GetCurrentScene() == OWScene.SolarSystem || LoadManager.GetCurrentScene() == OWScene.EyeOfTheUniverse) { if (PlayerNMBody == null) - PlayerNMBody = GameObject.FindObjectOfType().GetAttachedBody(); - + { + PlayerNMBody = GameObject.FindObjectOfType()?.GetAttachedBody(); + } } else PlayerNMBody = null; if (LoadManager.GetCurrentScene() == OWScene.SolarSystem) { if (ShipNMBody == null) - ShipNMBody = GameObject.FindObjectOfType().GetAttachedBody(); + { + ShipNMBody = GameObject.FindObjectOfType()?.GetAttachedBody(); + } } else { @@ -141,6 +146,7 @@ private void Update() public static float limiter; public static Vector3 latest; + public static IModConsole console; public struct SmoothCont { diff --git a/OW_SmoothThrust/manifest.json b/OW_SmoothThrust/manifest.json index ff5f138..ecf69b6 100644 --- a/OW_SmoothThrust/manifest.json +++ b/OW_SmoothThrust/manifest.json @@ -3,6 +3,6 @@ "author": "TAImatem & Schinken", "name": "SmoothThrust", "uniqueName": "TruAI.SmoothThrust", - "version": "1.5", - "owmlVersion": "0.3.46" + "version": "2.0", + "owmlVersion": "2.1.0" } \ No newline at end of file