From 1cbda9a1d6d6501022438e6051f610cf3cd29618 Mon Sep 17 00:00:00 2001 From: Soar Qin Date: Sun, 13 Sep 2026 23:36:06 +0800 Subject: [PATCH] fix(uxassist): poll shortcuts after native input updates Dispatch shortcut polling from VFInput.OnUpdate's postfix so key-down events use fresh modifier and typing state. Keep regular feature updates in the plugin Update loop. --- AGENTS.md | 1 + UXAssist/Common/GameLogic.cs | 11 +++++++++++ UXAssist/UXAssist.cs | 8 +++++++- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/AGENTS.md b/AGENTS.md index 621ab70..6b37e56 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -158,6 +158,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 local hash-space coverage and player/drone travel costs, and only replans on a coarse interval or after reaching a site. Candidate evaluation has fixed limits and uses allocation-free arrays; local construction checks also include ghosts whose materials can be delivered from the mecha package, so the planner does not abandon a site before the native item-placement pass can run. - **Auto-navigation modes:** The legacy auto-navigation and the new navigation algorithm are mutually exclusive; legacy mode wins if both configuration values load as enabled. The shared `ToggleAutoCruise` key dispatches to only the selected implementation. New-navigation teardown is unconditional for configuration, target, capability, and lifecycle failures, while the manual-input option controls only user-override behavior. Its session state and cloned status label are reset through `GameLogic.OnGameEnd` and patch teardown. When the new algorithm is selected but inactive, the cloned status label prompts the player with the currently configured `ToggleAutoCruise` key; it shows the active status while navigation is running. - **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 legacy 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. - **Transpiler patches:** Performance-critical mods (LabOpt, MechaDronesTweaks) use `[HarmonyTranspiler]` to rewrite IL instructions directly for maximum efficiency. All transpilers in UXAssist, CheatEnabler, and UniverseGenTweaks carry a standard header comment (`// Harmony transpiler:`, `// Target:`, `// Fallback:`) documenting the target method and fallback behavior. `UXAssist.Common.Patching.TranspilerGuard` provides a reusable `CodeMatcher.Finish` helper that returns original instructions when a matcher becomes invalid. - **Mod-compatibility reflection:** Use `UXAssist.Common.ModCompat.ModCompatHelper` for BepInEx plugin detection, external mod type/method/field resolution, and property-setter lookup. Preserve the old public type identity with a forwarding or inherited compatibility facade when a refactor moves a type that external mods may locate through reflection; build and verify that the legacy reflection target forwards to the refactored implementation. Use `UXAssist.Common.Utils.DysonSphereReflection` for the DSPOptimizations-compatible `DysonSphereLayer` private fields (`totalNodeSP`, `totalFrameSP`, `totalCP`) instead of resolving them locally in each consumer. diff --git a/UXAssist/Common/GameLogic.cs b/UXAssist/Common/GameLogic.cs index 99a8921..e477b8b 100644 --- a/UXAssist/Common/GameLogic.cs +++ b/UXAssist/Common/GameLogic.cs @@ -34,6 +34,17 @@ public class GameLogic : PatchImpl OnDataLoaded.InvokeSafe(UXAssist.Logger, nameof(OnDataLoaded)); } + /// + /// Harmony postfix for . + /// Dispatches mod updates after the game has refreshed its input state. + /// + [HarmonyPostfix, HarmonyPriority(Priority.Last)] + [HarmonyPatch(typeof(VFInput), nameof(VFInput.OnUpdate))] + public static void VFInput_OnUpdate_Postfix() + { + UXAssist.OnInputUpdate(); + } + /// /// Harmony postfix for . /// Raises . diff --git a/UXAssist/UXAssist.cs b/UXAssist/UXAssist.cs index d507aaf..e693aaf 100644 --- a/UXAssist/UXAssist.cs +++ b/UXAssist/UXAssist.cs @@ -287,13 +287,19 @@ public class UXAssist : BaseUnityPlugin, IModCanSave GameLogicProc.Enable(false); } - private void Update() + internal static void OnInputUpdate() { if (VFInput.inputing) return; ModFeatureRegistry.OnInputUpdateAll(); if (DSPGame.IsMenuDemo) return; GamePatch.OnInputUpdate(); PlayerPatch.OnInputUpdate(); + } + + private void Update() + { + if (VFInput.inputing) return; + if (DSPGame.IsMenuDemo) return; ModFeatureRegistry.OnUpdateAll(); } }