fix(uxassist): improve warp steering responsiveness

Top up the warp heading toward the requested direction after game rotation so the actual heading achieves the 1.6-degree-per-tick turn step. Reduce warp speed control during large heading errors while preserving manual warp speed input.
This commit is contained in:
soarqin committed 2026-09-16 00:49:11 +08:00
1 parent 7f9f0b62ae
commit 27c6a959ad
2 files changed
+59 -1

No files matched your search

+1 -1
View File
@@ -160,7 +160,7 @@ The sync is implemented as an inline PowerShell `Exec` step inside the `ZipMod`
- **Auto-construct planner:** `AutoConstructPatch` keeps a construction-site plan while drones work, chooses among a fixed candidate set using the native 120-target construction capacity, total drone travel cost, and player travel cost, then refines the strongest candidates to an actual ghost nearest the target-group center. Candidate scoring uses the planned flight altitude when evaluating build-range coverage. It replans before the current site is empty when the remaining local workload no longer covers the next flight. Candidate evaluation has fixed limits and uses allocation-free arrays; local construction checks scan actual hash entries instead of trusting stale module counters and include ghosts whose materials can be delivered from the mecha package.
- **Auto-construct final pass:** When at most eight eligible construction ghosts remain, the planner bypasses site-hold hysteresis and routes directly to the nearest remaining ghost. The final-pass count is capped at nine during the existing prebuild scan, so large construction queues do not incur an additional unbounded performance cost.
- **Auto-construct maintenance:** Planner scan reset, final-pass nearest-ghost routing, and route-arrival/recovery transitions use shared state helpers; no-op UI lifecycle forwarding is removed.
- **Auto-navigation:** UXAssist now exposes one auto-cruise implementation through `PlayerPatch.AutoNavigation`; the former legacy cruise path and algorithm-selection branch are removed. The shared `ToggleAutoCruise` key and in-game button control the session state. The configuration entry is presented as `Enable auto-cruise`, and its navigation options are grouped beneath it as indented 13-point sub-options. Steering follows the original `PlayerMove_Sail.GameTick` interpolation cap of 1.6 degrees per tick and explicitly chooses a stable turn plane for antiparallel velocity and target directions. Target resolution is validated once and applied atomically for both the UI and tick path; moving-target velocity is converted to universal coordinates; direct sail steering only runs while the player is sailing. Target state and reusable obstacle data are reset through one navigation lifecycle path. Satellite targets use a target corridor: an orbiting parent is ignored when the direct player-to-target segment is clear, shrinks its avoidance radius so it cannot contain the target, and otherwise follows a current-heading-selected tangent around the parent before returning to the satellite.
- **Auto-navigation:** UXAssist now exposes one auto-cruise implementation through `PlayerPatch.AutoNavigation`; the former legacy cruise path and algorithm-selection branch are removed. The shared `ToggleAutoCruise` key and in-game button control the session state. The configuration entry is presented as `Enable auto-cruise`, and its navigation options are grouped beneath it as indented 13-point sub-options. Steering follows the original `PlayerMove_Sail.GameTick` interpolation cap of 1.6 degrees per tick for the ordinary sail velocity and explicitly chooses a stable turn plane for antiparallel velocity and target directions. During warp, the added displacement uses `currentWarpVelocity` along mecha heading; after the game's heading update, a postfix tops up the warp heading toward the requested direction so the actual heading reaches the same 1.6-degree-per-tick minimum instead of lagging behind the ordinary velocity vector. Auto-navigation also reduces `warpSpeedControl` toward the game's 0.2 floor as heading error grows; manual warp speed controls take precedence. Target resolution is validated once and applied atomically for both the UI and tick path; moving-target velocity is converted to universal coordinates; direct sail steering only runs while the player is sailing. Target state and reusable obstacle data are reset through one navigation lifecycle path. Satellite targets use a target corridor: an orbiting parent is ignored when the direct player-to-target segment is clear, shrinks its avoidance radius so it cannot contain the target, and otherwise follows a current-heading-selected tangent around the parent before returning to the satellite.
- **Auto-cruise flight input:** In the original `PlayerMove_Fly.GameTick`, `PlayerController.input0.y = 1` matches manual forward movement and `input1.y = 1` matches manual upward thrust. The auto-cruise `Fly` handler must preserve these signs so the mecha leaves a planet with the same orientation and motion as manual control.
- **Shortcut input timing:** UXAssist dispatches mod shortcuts from a postfix of the original `VFInput.OnUpdate`, after DSP has refreshed its current modifier and UI input state. Do not move shortcut polling back to an independent plugin `Update()` or a logic-tick callback: CommonAPI `PressKeyBind.keyValue` combines Unity's current-frame `Input.GetKeyDown()` with `CombineKey` modifier caches refreshed by `VFInput.OnUpdate`. Polling before that refresh can miss a shortcut when a modifier changes in the same frame, which is easier to encounter at low frame rates. Keep the typing/menu guards and per-frame registry guards.
- **UI clone initialization and text measurement:** UXAssist UI factories and dependent mods' direct UI clones treat runtime DSP objects as style sources only; after `Instantiate`, they explicitly reset stateful `UIButton`, `Text`, `Image`, `InputField`, `Slider`, and `UIComboBox` fields that can otherwise carry source state. Use `UXAssist.UI.Util.GetPreferredWidth` for dynamic text width because it invalidates DSP's custom text-generator cache before reading `preferredWidth`; do not replace it with a generic `TextGenerator` or canvas-wide rebuild without validating the rendered result.
+58
View File
@@ -359,6 +359,7 @@ public class PlayerPatch : PatchImpl<PlayerPatch>
private const double ResidualCompensationMaxDistance = GalaxyData.AU * 0.5;
private const double ResidualCompensationSpeedRatio = 0.5;
private const double ResidualCompensationMinSpeed = 100;
private const float WarpTurnDegreesPerTick = 1.6f;
private static bool _enabled;
private static Text _uiTipText;
@@ -372,6 +373,9 @@ public class PlayerPatch : PatchImpl<PlayerPatch>
private static readonly List<Obstacle> Obstacles = new(64);
private static bool _wasSailing;
private static bool _followModeLock;
private static bool _warpSteeringPending;
private static Quaternion _warpHeadingBeforeRotation;
private static VectorLF3 _warpTargetDirection;
public static bool IsActive => _enabled;
@@ -487,6 +491,9 @@ public class PlayerPatch : PatchImpl<PlayerPatch>
_targetId = 0;
_wasSailing = false;
_followModeLock = false;
_warpSteeringPending = false;
_warpHeadingBeforeRotation = Quaternion.identity;
_warpTargetDirection = default;
_targetUniversePosition = default;
_targetUniverseVelocity = default;
_targetType = default;
@@ -956,6 +963,12 @@ public class PlayerPatch : PatchImpl<PlayerPatch>
stepSpeed = Math.Max(0, (currentVel - dVelocityBrake).magnitude);
}
_warpSteeringPending = player.warping && targetDir.sqrMagnitude > Epsilon;
_warpHeadingBeforeRotation = player.uRotation;
_warpTargetDirection = _warpSteeringPending ? targetDir : default;
AdaptWarpSpeedControl(controller, targetDir);
// Smooth velocity changes.
VectorLF3 targetVelocity = targetDir * stepSpeed;
float angle = Vector3.Angle(targetVelocity, currentVel);
@@ -970,6 +983,51 @@ public class PlayerPatch : PatchImpl<PlayerPatch>
UpdateRotation(controller: controller);
}
[HarmonyPatch(typeof(PlayerController), "UpdateRotation")]
[HarmonyPostfix]
private static void PlayerController_UpdateRotation_Postfix(PlayerController __instance)
{
if (!_enabled || !_warpSteeringPending)
return;
_warpSteeringPending = false;
Player player = __instance.player;
if (player == null || __instance.movementStateInFrame != EMovementState.Sail || !player.warping)
return;
Vector3 previousDirection = _warpHeadingBeforeRotation * Vector3.forward;
Vector3 currentDirection = player.uRotation * Vector3.forward;
Vector3 targetDirection = (Vector3)_warpTargetDirection;
float appliedAngle = Vector3.Angle(previousDirection, currentDirection);
float targetAngle = Vector3.Angle(currentDirection, targetDirection);
float remainingAngle = Mathf.Min(targetAngle, Mathf.Max(0f, WarpTurnDegreesPerTick - appliedAngle));
if (remainingAngle < 0.01f)
return;
Vector3 turnAxis = GetStableTurnAxis(currentDirection, targetDirection);
player.uRotation = Quaternion.AngleAxis(remainingAngle, turnAxis) * player.uRotation;
}
private static void AdaptWarpSpeedControl(PlayerController controller, VectorLF3 targetDir)
{
Player player = controller.player;
if (!player.warping || VFInput._sailSpeedUp || controller.input0.y < 0f)
return;
Vector3 warpDirection = player.uRotation * Vector3.forward;
float turnAngle = Vector3.Angle(warpDirection, targetDir);
double turnSeverity = Clamp((turnAngle - 15.0) / 45.0, 0.0, 1.0);
double targetControl = 1.0 - turnSeverity * turnSeverity * (3.0 - 2.0 * turnSeverity) * 0.8;
double controlDelta = Clamp(
targetControl - controller.actionSail.warpSpeedControl,
-0.02,
0.02);
controller.actionSail.warpSpeedControl = Clamp(
controller.actionSail.warpSpeedControl + controlDelta,
0.2,
1.0);
}
private static VectorLF3 SmoothVelocity(
VectorLF3 currentVelocity,
VectorLF3 targetVelocity,