From 91184ccc3a7f56c46c4d78e20e028dac3f45684a Mon Sep 17 00:00:00 2001 From: Soar Qin Date: Sun, 15 Feb 2026 22:34:05 +0800 Subject: [PATCH] UXAssist 1.5.4 --- UXAssist/CHANGELOG.md | 2 ++ UXAssist/Patches/PlayerPatch.cs | 45 +++++++++++++++++++++++++++++---- UXAssist/UXAssist.csproj | 2 +- UXAssist/package/manifest.json | 2 +- 4 files changed, 44 insertions(+), 7 deletions(-) diff --git a/UXAssist/CHANGELOG.md b/UXAssist/CHANGELOG.md index 55e9ac9..3d04297 100644 --- a/UXAssist/CHANGELOG.md +++ b/UXAssist/CHANGELOG.md @@ -7,6 +7,7 @@ * `Auto-contruct`: * Add a UI option to hide it completely. * Fix an issue that may cause circling. + * `Auto-cruise`: Fix some user experience related logics. * 1.5.3 * New feature: `Auto-contruct` * Fly to buildings to be contructed automatically. @@ -385,6 +386,7 @@ * `自动建造`: * 增加了一个 UI 选项,可完全隐藏该功能。 * 修复了可能导致盘旋的问题。 + * `自动巡航`:修复了一些用户体验相关的逻辑问题。 * 1.5.3 * 新功能:`自动建造` * 自动飞行到待建造的建筑处进行建造。 diff --git a/UXAssist/Patches/PlayerPatch.cs b/UXAssist/Patches/PlayerPatch.cs index 3ef1610..879c8a8 100644 --- a/UXAssist/Patches/PlayerPatch.cs +++ b/UXAssist/Patches/PlayerPatch.cs @@ -337,9 +337,19 @@ public class PlayerPatch : PatchImpl private static int _indicatorAstroId; private static bool _speedUp; private static Vector3 _direction; + private static EMovementState _movementState = EMovementState.Walk; public static int IndicatorAstroId => _indicatorAstroId; + protected override void OnEnable() + { + _canUseWarper = false; + _indicatorAstroId = 0; + _speedUp = false; + _direction = Vector3.zero; + _movementState = EMovementState.Walk; + } + public static void ToggleAutoCruise() { AutoCruiseEnabled.Value = !AutoCruiseEnabled.Value; @@ -349,6 +359,16 @@ public class PlayerPatch : PatchImpl } } + private static bool UpdateMovementState(PlayerController controller) + { + var movementStateChanged = controller.movementStateInFrame != _movementState; + if (movementStateChanged) + { + _movementState = controller.movementStateInFrame; + } + return movementStateChanged; + } + [HarmonyTranspiler] [HarmonyPatch(typeof(PlayerController), nameof(PlayerController.GameTick))] private static IEnumerable PlayerController_GameTick_Transpiler(IEnumerable instructions, ILGenerator generator) @@ -365,7 +385,8 @@ public class PlayerPatch : PatchImpl var player = controller.player; if (player.mecha.thrusterLevel < 2) return; var navi = player.navigation; - if (navi.indicatorAstroId != _indicatorAstroId) + var astroChanged = navi.indicatorAstroId != _indicatorAstroId; + if (astroChanged) { _indicatorAstroId = navi.indicatorAstroId; Functions.UIFunctions.UpdateToggleAutoCruiseCheckButtonVisiblility(); @@ -377,25 +398,33 @@ public class PlayerPatch : PatchImpl case EMovementState.Drift: if (!AutoCruiseEnabled.Value) return; if (GameMain.localStar?.astroId == _indicatorAstroId) return; + UpdateMovementState(controller); /* Press jump key to fly */ controller.input0.z = 1f; break; case EMovementState.Fly: if (!AutoCruiseEnabled.Value) return; if (GameMain.localStar?.astroId == _indicatorAstroId) return; + UpdateMovementState(controller); /* Keep pressing jump and pullup key to sail */ - controller.input0.y = 1f; + controller.input0.y = -1f; controller.input1.y = 1f; break; case EMovementState.Sail: if (VFInput._pullUp.pressing || VFInput._pushDown.pressing || VFInput._moveLeft.pressing || VFInput._moveRight.pressing || (!player.warping && UIRoot.instance.uiGame.disableLockCursor && (VFInput._moveForward.pressing || VFInput._moveBackward.pressing))) return; + var movementStateChanged = UpdateMovementState(controller); var playerPos = player.uPosition; var isHive = _indicatorAstroId > 1000000; ref var astro = ref isHive ? ref GameMain.spaceSector.astros[_indicatorAstroId - 1000000] : ref GameMain.galaxy.astrosData[_indicatorAstroId]; var astroVec = astro.uPos - playerPos; var distance = astroVec.magnitude; + astroVec = astroVec.normalized; + if (astroChanged || movementStateChanged) + { + controller.actionSail.sailPoser.targetURotWanted = Quaternion.LookRotation(astroVec); + } if (distance < astro.type switch { EAstroType.Planet => 800.0 + astro.uRadius, @@ -413,7 +442,7 @@ public class PlayerPatch : PatchImpl var autoCruise = AutoCruiseEnabled.Value; if (GameMain.instance.timei % 6 == 0 || _direction == Vector3.zero) { - _direction = astroVec.normalized; + _direction = astroVec; /* Check nearest astroes, try to bypass them */ var localStar = GameMain.localStar; @@ -477,11 +506,11 @@ public class PlayerPatch : PatchImpl var speed = uVel.magnitude; if (player.warping) { - _speedUp = false; if (autoCruise) { - /* Speed down if too close */ var actionSail = controller.actionSail; + _speedUp = actionSail.currentWarpSpeed < actionSail.maxWarpSpeed; + /* Speed down if too close */ if (distance < GalaxyData.LY * 1.5) { if (distance < actionSail.currentWarpSpeed * distance switch @@ -493,9 +522,14 @@ public class PlayerPatch : PatchImpl }) { controller.input0.y = -1f; + _speedUp = false; } } } + else + { + _speedUp = false; + } } else { @@ -505,6 +539,7 @@ public class PlayerPatch : PatchImpl { player.warpCommand = true; VFAudio.Create("warp-begin", player.transform, Vector3.zero, true); + controller.actionSail.sailPoser.targetURotWanted = Quaternion.LookRotation(astroVec); } else { diff --git a/UXAssist/UXAssist.csproj b/UXAssist/UXAssist.csproj index 9375d26..2ee36a5 100644 --- a/UXAssist/UXAssist.csproj +++ b/UXAssist/UXAssist.csproj @@ -4,7 +4,7 @@ net472 org.soardev.uxassist DSP MOD - UXAssist - 1.5.3 + 1.5.4 true latest UXAssist diff --git a/UXAssist/package/manifest.json b/UXAssist/package/manifest.json index 595678f..db1eab0 100644 --- a/UXAssist/package/manifest.json +++ b/UXAssist/package/manifest.json @@ -1,6 +1,6 @@ { "name": "UXAssist", - "version_number": "1.5.3", + "version_number": "1.5.4", "website_url": "https://github.com/soarqin/DSP_Mods/tree/master/UXAssist", "description": "Some functions and patches for better user experience / 一些提升用户体验的功能和补丁", "dependencies": [