Rework `Unlock Tech with Key-Modifiers` into a full upgrade/downgrade feature,
ported from the standalone TechTweaks plugin.
- Holding Shift / Ctrl / Ctrl+Shift / Alt while clicking a tech adds 1 / 10 /
100 / all levels and unlocks the direct prerequisites, as before.
- `Caps Lock` toggles a session downgrade mode; the same modifiers then
subtract 1 / 10 / 100 levels or revert the tech to locked. Downgrading walks
the dependent techs so no "prerequisite locked, dependent unlocked" state is
left behind, and it reverts the upgrade values the tech had applied
(`TechFuncRevert`), including the multiplicative, assignment and boolean
`UnlockTechFunction` cases, so repeated up/down cycles do not drift.
- Toggling downgrade mode reports itself like the other toggles: a realtime tip
popup plus the critical warning banner. The banner now shows on its own
instead of requiring `Build without condition` or `No collision` to be on,
and outranks both in the shared priority chains.
- The `?` button in the tech tree shows the full key reference, using the same
title and text as the config panel's tip button. While the option is off, the
button is absent and `Caps Lock` is inert, so the key cannot collide with
other bindings.
- The option keeps its original `General/UnlockTech` config entry, so existing
configurations carry over.
The old unlock-only handler in `Patches/GamePatch.cs` is replaced by
`Patches/TechTweaksPatch.cs`, which follows the repository's mod feature
lifecycle (per-frame input through the registry's `OnInputUpdate`).
ModFeatureRegistry is a static class with shared collections accumulating
features from all mods. Dependent mods (CheatEnabler, UniverseGenTweaks)
each independently called InitAll/StartAll/OnInputUpdateAll/OnUpdateAll/
UninitAll, re-running lifecycle for ALL accumulated features including
other mods' — per-frame Update ran 2-3x (breaking CheatEnabler key toggles
to net no-ops), Init/Start/Uninit ran 2-3x (double RegisterExporter causing
save corruption, double SettingChanged subscriptions, double keybind
registration).
Fix:
- Init now runs eagerly at Discover/Register time (Awake-phase), preserving
the original timing that keybind registration depends on (game's
UIOptionWindow._OnCreate copies keybinds only after all plugins load)
- InitAll removed entirely
- StartAll/UninitAll/OnInputUpdateAll/OnUpdateAll made internal so only
UXAssist (host, same assembly, no InternalsVisibleTo) can drive them
- Start deferred to UXAssist.Start (after all dependents' Awake complete;
BepInEx runs all Awakes before any Start)
- Per-feature Started idempotency + per-frame Time.frameCount guards as
defense-in-depth
- Dependent mods reduced to Discover-only in Awake
Document the Init/Start timing contract on IModFeature and
ModFeatureAttribute so future mods can rely on it.