Files
DSP_Mods/CheatEnabler/Patches/Tech/TechKeyCombo.cs
T
soarqin 5fb8695348 fix(cheatenabler): make tech downgrades safe and refresh docs
Validate the full dependency cascade and capacity reductions before applying tech downgrades. Preserve shared recipes, restore native bonus values and station limits, and clamp stored energy to the remaining capacity.

Fix warning integration and tech-tree help button ownership, cleanup and localization. Use the shared patch lifecycle and guarded transpilers.

Refresh bilingual feature and usage documentation, and consolidate the 2.4.7 changelog around the final user-visible behavior.
2026-10-11 03:09:47 +08:00

60 lines
1.6 KiB
C#

namespace CheatEnabler.Patches.Tech;
/// <summary>
/// The key-modifier semantics shared by the upgrade and the downgrade side.
///
/// Both directions use the same modifier mapping:
///
/// <list type="table">
/// <item><term>Shift</term><description>+1 / -1</description></item>
/// <item><term>Ctrl</term><description>+10 / -10</description></item>
/// <item><term>Ctrl + Shift</term><description>+100 / -100</description></item>
/// <item><term>Alt</term><description>to MAX / back to locked</description></item>
/// <item><term>Shift + Alt, Ctrl + Alt</term><description>ignored</description></item>
/// </list>
/// </summary>
internal static class TechKeyCombo
{
/// <summary>Sentinel for the "Alt" combination: apply or revert everything this click can.</summary>
public const int LevelToMax = int.MaxValue;
/// <summary>
/// Decodes the currently held modifiers.
/// Returns false when the combination carries no meaning and the click must be left alone.
/// </summary>
public static bool TryDecode(out int steps)
{
steps = 0;
if (VFInput.shift)
{
if (VFInput.alt)
{
return false;
}
steps = VFInput.control ? 100 : 1;
return true;
}
if (VFInput.control)
{
if (VFInput.alt)
{
return false;
}
steps = 10;
return true;
}
if (VFInput.alt)
{
steps = LevelToMax;
return true;
}
return false;
}
}