feat(cheatenabler): add tech downgrade and make the tech modifiers upgradable

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`).
This commit is contained in:
TTenYX authored and Soar Qin committed 2026-10-10 23:49:40 +08:00
1 parent 6a292e0816
commit 6ced106901
19 files changed
+2072 -143

No files matched your search

+2
View File
@@ -28,6 +28,8 @@
## Architecture
- UXAssist Dark Fog buy-out belt signals keep each item ID, per-Metaverse rate, localization key, and embedded icon path in one definition. Name embedded icon files after the current English item names and synchronize resource includes and loader paths when renaming them. Preserve the legacy signal and saved-stock order. Rates represent equivalent single-material value: a native bundle of 10 Silicon-based Neurons, 10 Negentropy Singularities, and 10 Matter Recombinators per Metaverse corresponds to 30 of any one selected material per Metaverse.
- CheatEnabler's tech upgrade / downgrade feature lives under `Patches/Tech`; `TechTweaksPatch` owns the config (reusing `General/UnlockTech`), the `[ModFeature]` lifecycle, the `UITechTree` UI patches and the `UITechNode.OnPointerDown` transpiler, while the click decision, key-modifier decoding, downgrade recursion, UI and the per-function inverse of `GameHistoryData.UnlockTechFunction` stay in their own classes. Per-frame input goes through the registry's `OnInputUpdate`, so no separate `VFInput.OnUpdate` patch is added. `TechFuncRevert` must keep covering every `UnlockTechFunction` case: functions without a drift-free inverse are recomputed from the `Configs.freeMode` base values plus the levels still applied across all techs, never by replaying the whole tech tree, because a replay would re-apply the `func 30/31` station rescaling and the `func 5/38` package resize instead of restoring them.
- CheatEnabler's custom critical-warning texts are a single string behind two gates, and every feature that wants one takes part in both priority chains: `WarningSystem_hasCriticalWarning_Transpiler` (an OR chain deciding whether the banner appears at all) and `WarningSystem_UpdateCriticalWarningText_Transpiler` (deciding which text it shows). Tech downgrade mode is first in both so it displays on its own, without either build toggle being on; previously the banner could only appear while `Build without condition` or `No collision` was enabled. Extend the chains instead of overwriting `criticalWarningTexts` from another patch.
- `ModFeatureRegistry` discovers dependent-mod features during `Awake`; feature initialization is eager, while UXAssist alone drives the deferred start, input, update, and uninitialization lifecycle. Keep dispatchers internal and idempotent.
- Apply config-controlled patches from their owning feature's `Start` and `SettingChanged` handlers. Shared lifecycle helpers must only manage always-on patches and must not override saved option states.
- Proto-dependent features must tolerate calls before preload completes and retry via `UXAssist.Common.GameLogic.OnDataLoaded`. Mark changes applied only after capturing valid originals and successfully mutating the proto.