mirror of
https://github.com/soarqin/DSP_Mods.git
synced 2026-11-19 17:05:20 +08:00
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`).
113 lines
7.2 KiB
C#
113 lines
7.2 KiB
C#
using System.Reflection;
|
|
using BepInEx;
|
|
using BepInEx.Configuration;
|
|
using CheatEnabler.Patches;
|
|
using CheatEnabler.Patches.Factory;
|
|
using FactoryPatch = CheatEnabler.Patches.Factory.FactoryPatch;
|
|
using UXAssist.Common;
|
|
using UXAssist.Common.ModFeatures;
|
|
|
|
namespace CheatEnabler;
|
|
|
|
[BepInPlugin(PluginInfo.PLUGIN_GUID, PluginInfo.PLUGIN_NAME, PluginInfo.PLUGIN_VERSION)]
|
|
[BepInDependency(UXAssist.PluginInfo.PLUGIN_GUID)]
|
|
public class CheatEnabler : BaseUnityPlugin
|
|
{
|
|
public new static readonly BepInEx.Logging.ManualLogSource Logger =
|
|
BepInEx.Logging.Logger.CreateLogSource(PluginInfo.PLUGIN_NAME);
|
|
|
|
private void Awake()
|
|
{
|
|
I18N.Init();
|
|
|
|
GamePatch.DevShortcutsEnabled = Config.Bind("General", "DevShortcuts", false, "Enable DevMode shortcuts");
|
|
GamePatch.AbnormalDisablerEnabled = Config.Bind("General", "DisableAbnormalChecks", false,
|
|
"disable all abnormal checks");
|
|
TechTweaksPatch.Enabled = Config.Bind("General", "UnlockTech", false,
|
|
"Unlock clicked tech by holding key-modifilers(Shift/Alt/Ctrl), and downgrade them by holding the " +
|
|
"same modifiers while downgrade mode is on (toggle it with Caps Lock)");
|
|
FactoryPatch.ImmediateEnabled = Config.Bind("Build", "ImmediateBuild", false,
|
|
"Build immediately");
|
|
FactoryPatch.ArchitectModeEnabled = Config.Bind("Build", "Architect", false,
|
|
"Architect Mode");
|
|
FactoryPatch.NoConditionEnabled = Config.Bind("Build", "BuildWithoutCondition", false,
|
|
"Build without condition");
|
|
FactoryPatch.NoCollisionEnabled = Config.Bind("Build", "NoCollision", false,
|
|
"No collision");
|
|
FactoryPatch.BeltSignalGeneratorEnabled = Config.Bind("Build", "BeltSignalGenerator", false,
|
|
"Belt signal generator");
|
|
FactoryPatch.BeltSignalNumberAltFormat = Config.Bind("Build", "BeltSignalNumberFormat", false,
|
|
"Belt signal number format alternative format (AAAA=generation speed in minutes, B=proliferate points, C=stack count):\n AAAABC by default\n BCAAAA as alternative");
|
|
FactoryPatch.BeltSignalCountGenEnabled = Config.Bind("Build", "BeltSignalCountGenerations", true,
|
|
"Belt signal count generations as production in statistics");
|
|
FactoryPatch.BeltSignalCountRemEnabled = Config.Bind("Build", "BeltSignalCountRemovals", true,
|
|
"Belt signal count removals as comsumption in statistics");
|
|
FactoryPatch.BeltSignalCountRecipeEnabled = Config.Bind("Build", "BeltSignalCountRecipe", false,
|
|
"Belt signal count all raws and intermediates in statistics");
|
|
FactoryPatch.BeltSignalUseProliferatorEnabled = Config.Bind("Build", "BeltSignalUseProliferator", false,
|
|
"Belt signal count proliferators used for raws/intermediates and finished products");
|
|
FactoryPatch.RemovePowerSpaceLimitEnabled = Config.Bind("Build", "RemovePowerDistanceLimit", false,
|
|
"Remove distance limit for wind turbines and geothermals");
|
|
FactoryPatch.BoostWindPowerEnabled = Config.Bind("Build", "BoostWindPower", false,
|
|
"Boost wind power");
|
|
FactoryPatch.BoostSolarPowerEnabled = Config.Bind("Build", "BoostSolarPower", false,
|
|
"Boost solar power");
|
|
FactoryPatch.BoostFuelPowerEnabled = Config.Bind("Build", "BoostFuelPower", false,
|
|
"Boost fuel power");
|
|
FactoryPatch.BoostGeothermalPowerEnabled = Config.Bind("Build", "BoostGeothermalPower", false,
|
|
"Boost geothermal power");
|
|
FactoryPatch.WindTurbinesPowerGlobalCoverageEnabled = Config.Bind("Build", "PowerGlobalCoverage", false,
|
|
"Global power coverage");
|
|
FactoryPatch.ControlPanelRemoteLogisticsEnabled = Config.Bind("Build", "ControlPanelRemoteLogistics", false,
|
|
"Retrieve/Place items from/to remote planets on logistics control panel");
|
|
ResourcePatch.InfiniteResourceEnabled = Config.Bind("Planet", "AlwaysInfiniteResource", false,
|
|
"always infinite natural resource");
|
|
ResourcePatch.FastMiningEnabled = Config.Bind("Planet", "FastMining", false,
|
|
"super-fast mining speed");
|
|
PlanetPatch.WaterPumpAnywhereEnabled = Config.Bind("Planet", "WaterPumpAnywhere", false,
|
|
"Can pump water anywhere (while water type is not None)");
|
|
PlanetPatch.TerraformAnywayEnabled = Config.Bind("Planet", "TerraformAnyway", false,
|
|
"Can do terraform without enough soil piless");
|
|
PlayerPatch.InstantHandCraftEnabled = Config.Bind("Player", "InstantHandCraft", false,
|
|
"Enable instant hand-craft");
|
|
PlayerPatch.InstantTeleportEnabled = Config.Bind("Player", "InstantTeleport", false,
|
|
"Enable instant teleport (like that in Sandbox mode)");
|
|
PlayerPatch.WarpWithoutSpaceWarpersEnabled = Config.Bind("Player", "WarpWithoutWarper", false,
|
|
"Enable warp without warper");
|
|
DysonSpherePatch.SkipBulletEnabled = Config.Bind("DysonSphere", "SkipBullet", false,
|
|
"Skip bullet");
|
|
DysonSpherePatch.FireAllBulletsEnabled = Config.Bind("DysonSphere", "FireAllBullets", false,
|
|
"Fire all bullets at once");
|
|
DysonSpherePatch.SkipAbsorbEnabled = Config.Bind("DysonSphere", "SkipAbsorb", false,
|
|
"Skip absorption");
|
|
DysonSpherePatch.QuickAbsorbEnabled = Config.Bind("DysonSphere", "QuickAbsorb", false,
|
|
"Quick absorb");
|
|
DysonSpherePatch.EjectAnywayEnabled = Config.Bind("DysonSphere", "EjectAnyway", false,
|
|
"Eject anyway");
|
|
DysonSpherePatch.OverclockEjectorEnabled = Config.Bind("DysonSphere", "OverclockEjector", false,
|
|
"Overclock ejector");
|
|
DysonSpherePatch.OverclockSiloEnabled = Config.Bind("DysonSphere", "OverclockSilo", false,
|
|
"Overclock silo");
|
|
DysonSpherePatch.UnlockMaxOrbitRadiusEnabled = Config.Bind("DysonSphere", "UnlockMaxOrbitRadius", false,
|
|
"Unlock Dyson Sphere max orbit radius");
|
|
DysonSpherePatch.UnlockMaxOrbitRadiusValue = Config.Bind("DysonSphere", "MaxOrbitRadiusValue", 10_000_000f,
|
|
"Unlocked Dyson Sphere max orbit radius value");
|
|
Functions.DysonSphereFunctions.IllegalDysonShellFunctionsEnabled = Config.Bind("DysonSphere", "IllegalDysonShellFunctions", false,
|
|
"Enable illegal dyson shell functions");
|
|
Functions.DysonSphereFunctions.ShellsCountForFunctions = Config.Bind("DysonSphere", "ShellsCountForFunctions", 2048,
|
|
new ConfigDescription("Shells count for various functions", new AcceptableValueRange<int>(
|
|
Functions.DysonSphereFunctions.MinShellsCountForFunctions,
|
|
Functions.DysonSphereFunctions.MaxShellsCountForFunctions)));
|
|
CombatPatch.MechaInvincibleEnabled = Config.Bind("Battle", "MechaInvincible", false,
|
|
"Mecha and Drones/Fleets invincible");
|
|
CombatPatch.BuildingsInvincibleEnabled = Config.Bind("Battle", "BuildingsInvincible", false,
|
|
"Buildings invincible");
|
|
Localization.Register();
|
|
UIConfigWindow.Init();
|
|
// Register features (Init runs eagerly here); UXAssist drives the deferred lifecycle and starts
|
|
// this feature set immediately if its lifecycle has already begun.
|
|
ModFeatureRegistry.Discover(Assembly.GetExecutingAssembly());
|
|
|
|
I18N.Apply();
|
|
}
|
|
} |