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.
This commit is contained in:
soarqin committed 2026-09-13 23:36:06 +08:00
1 parent 82f6f53fa8
commit 1cbda9a1d6
3 files changed
+19 -1

No files matched your search

+1
View File
@@ -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.
+11
View File
@@ -34,6 +34,17 @@ public class GameLogic : PatchImpl<GameLogic>
OnDataLoaded.InvokeSafe(UXAssist.Logger, nameof(OnDataLoaded));
}
/// <summary>
/// Harmony postfix for <see cref="VFInput.OnUpdate"/>.
/// Dispatches mod updates after the game has refreshed its input state.
/// </summary>
[HarmonyPostfix, HarmonyPriority(Priority.Last)]
[HarmonyPatch(typeof(VFInput), nameof(VFInput.OnUpdate))]
public static void VFInput_OnUpdate_Postfix()
{
UXAssist.OnInputUpdate();
}
/// <summary>
/// Harmony postfix for <see cref="GameMain.Begin"/>.
/// Raises <see cref="OnGameBegin"/>.
+7 -1
View File
@@ -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();
}
}