1
0
mirror of https://github.com/soarqin/DSP_Mods.git synced 2025-12-08 23:33:33 +08:00

CheatEnabler 2.3.16 and UXAssist 1.0.24

This commit is contained in:
2024-05-24 17:18:34 +08:00
parent 3db7fa5194
commit b1f27a2633
12 changed files with 206 additions and 131 deletions

View File

@@ -44,6 +44,8 @@ public class CheatEnabler : BaseUnityPlugin
"Boost fuel power");
FactoryPatch.BoostGeothermalPowerEnabled = Config.Bind("Build", "BoostGeothermalPower", false,
"Boost geothermal power");
FactoryPatch.GreaterPowerUsageInLogisticsEnabled = Config.Bind("Build", "GreaterPowerUsageInLogistics", false,
"Increase maximum power usage in Logistic Stations and Advanced Mining Machines");
ResourcePatch.InfiniteResourceEnabled = Config.Bind("Planet", "AlwaysInfiniteResource", false,
"always infinite natural resource");
ResourcePatch.FastMiningEnabled = Config.Bind("Planet", "FastMining", false,

View File

@@ -5,7 +5,7 @@
<TargetFramework>net472</TargetFramework>
<BepInExPluginGuid>org.soardev.cheatenabler</BepInExPluginGuid>
<Description>DSP MOD - CheatEnabler</Description>
<Version>2.3.15</Version>
<Version>2.3.16</Version>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>latest</LangVersion>
<PackageId>CheatEnabler</PackageId>

View File

@@ -5,6 +5,7 @@ using BepInEx.Configuration;
using CommonAPI.Systems;
using HarmonyLib;
using UnityEngine;
using UnityEngine.UI;
using UXAssist.Common;
namespace CheatEnabler;
@@ -25,6 +26,7 @@ public static class FactoryPatch
public static ConfigEntry<bool> BoostSolarPowerEnabled;
public static ConfigEntry<bool> BoostFuelPowerEnabled;
public static ConfigEntry<bool> BoostGeothermalPowerEnabled;
public static ConfigEntry<bool> GreaterPowerUsageInLogisticsEnabled;
private static Harmony _factoryPatch;
private static PressKeyBind _noConditionKey;
@@ -66,6 +68,7 @@ public static class FactoryPatch
BoostSolarPowerEnabled.SettingChanged += (_, _) => BoostSolarPower.Enable(BoostSolarPowerEnabled.Value);
BoostFuelPowerEnabled.SettingChanged += (_, _) => BoostFuelPower.Enable(BoostFuelPowerEnabled.Value);
BoostGeothermalPowerEnabled.SettingChanged += (_, _) => BoostGeothermalPower.Enable(BoostGeothermalPowerEnabled.Value);
GreaterPowerUsageInLogisticsEnabled.SettingChanged += (_, _) => GreaterPowerUsageInLogistics.Enable(GreaterPowerUsageInLogisticsEnabled.Value);
ImmediateBuild.Enable(ImmediateEnabled.Value);
ArchitectMode.Enable(ArchitectModeEnabled.Value);
NoConditionBuild.Enable(NoConditionEnabled.Value);
@@ -76,9 +79,26 @@ public static class FactoryPatch
BoostSolarPower.Enable(BoostSolarPowerEnabled.Value);
BoostFuelPower.Enable(BoostFuelPowerEnabled.Value);
BoostGeothermalPower.Enable(BoostGeothermalPowerEnabled.Value);
GreaterPowerUsageInLogistics.Enable(GreaterPowerUsageInLogisticsEnabled.Value);
_factoryPatch = Harmony.CreateAndPatchAll(typeof(FactoryPatch));
}
public static void Uninit()
{
_factoryPatch?.UnpatchSelf();
_factoryPatch = null;
ImmediateBuild.Enable(false);
ArchitectMode.Enable(false);
NoConditionBuild.Enable(false);
BeltSignalGenerator.Enable(false);
RemovePowerSpaceLimit.Enable(false);
BoostWindPower.Enable(false);
BoostSolarPower.Enable(false);
BoostFuelPower.Enable(false);
BoostGeothermalPower.Enable(false);
GreaterPowerUsageInLogistics.Enable(false);
}
public static void OnUpdate()
{
if (_noConditionKey.keyValue)
@@ -99,21 +119,6 @@ public static class FactoryPatch
}
}
public static void Uninit()
{
_factoryPatch?.UnpatchSelf();
_factoryPatch = null;
ImmediateBuild.Enable(false);
ArchitectMode.Enable(false);
NoConditionBuild.Enable(false);
BeltSignalGenerator.Enable(false);
RemovePowerSpaceLimit.Enable(false);
BoostWindPower.Enable(false);
BoostSolarPower.Enable(false);
BoostFuelPower.Enable(false);
BoostGeothermalPower.Enable(false);
}
private static void NoCollisionValueChanged()
{
var coll = ColliderPool.instance;
@@ -1277,4 +1282,161 @@ public static class FactoryPatch
return matcher.InstructionEnumeration();
}
}
private static class GreaterPowerUsageInLogistics
{
private static Harmony _patch;
public static void Enable(bool enable)
{
if (enable)
{
_patch ??= Harmony.CreateAndPatchAll(typeof(GreaterPowerUsageInLogistics));
return;
}
_patch?.UnpatchSelf();
_patch = null;
}
[HarmonyTranspiler]
[HarmonyPatch(typeof(UIStationWindow), nameof(UIStationWindow._OnInit))]
private static IEnumerable<CodeInstruction> UIStationWindow__OnInit_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
{
var matcher = new CodeMatcher(instructions, generator);
matcher.Start().Insert(
new CodeInstruction(OpCodes.Ldarg_0),
Transpilers.EmitDelegate((UIStationWindow window) =>
{
window.maxMiningSpeedSlider.maxValue = 27f;
})
);
return matcher.InstructionEnumeration();
}
[HarmonyTranspiler]
[HarmonyPatch(typeof(UIStationWindow), nameof(UIStationWindow.OnStationIdChange))]
private static IEnumerable<CodeInstruction> UIStationWindow_OnStationIdChange_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
{
var matcher = new CodeMatcher(instructions, generator);
matcher.MatchForward(false,
new CodeMatch(OpCodes.Ldarg_0),
new CodeMatch(OpCodes.Ldfld, AccessTools.Field(typeof(UIStationWindow), nameof(UIStationWindow.maxChargePowerSlider))),
new CodeMatch(ci => ci.IsLdloc()),
new CodeMatch(ci => ci.opcode == OpCodes.Ldc_I4 && ci.OperandIs(0xC350)),
new CodeMatch(OpCodes.Conv_I8)
);
var pos = matcher.Pos + 1;
matcher.Advance(5).MatchForward(false,
new CodeMatch(OpCodes.Conv_R4),
new CodeMatch(OpCodes.Callvirt, AccessTools.PropertySetter(typeof(Slider), nameof(Slider.value)))
);
var pos2 = matcher.Pos + 2;
matcher.Start().Advance(pos);
var ldvar = matcher.InstructionAt(1).Clone();
var locWorkEnergyPerTick = matcher.InstructionAt(-2).operand;
matcher.RemoveInstructions(pos2 - pos).InsertAndAdvance(
ldvar,
new CodeInstruction(OpCodes.Ldloc_S, locWorkEnergyPerTick),
Transpilers.EmitDelegate((UIStationWindow window, long maxWorkEnergy, long workEnergyPerTick) =>
{
var maxSliderValue = maxWorkEnergy / 50000L;
window.maxChargePowerSlider.maxValue = maxSliderValue + 9;
window.maxChargePowerSlider.minValue = maxWorkEnergy / 500000L;
if (workEnergyPerTick <= maxWorkEnergy)
window.maxChargePowerSlider.value = workEnergyPerTick / 50000L;
else
window.maxChargePowerSlider.value = maxSliderValue + (workEnergyPerTick - 1) / maxWorkEnergy + 1;
})
);
matcher.MatchForward(false,
new CodeMatch(OpCodes.Ldarg_0),
new CodeMatch(OpCodes.Ldfld, AccessTools.Field(typeof(UIStationWindow), nameof(UIStationWindow.maxMiningSpeedSlider))),
new CodeMatch(OpCodes.Ldarg_0),
new CodeMatch(OpCodes.Ldfld, AccessTools.Field(typeof(UIStationWindow), nameof(UIStationWindow.factorySystem))),
new CodeMatch(OpCodes.Ldfld, AccessTools.Field(typeof(FactorySystem), nameof(FactorySystem.minerPool))),
new CodeMatch(ci => ci.IsLdloc()),
new CodeMatch(OpCodes.Ldfld, AccessTools.Field(typeof(StationComponent), nameof(StationComponent.minerId))),
new CodeMatch(OpCodes.Ldelema, typeof(MinerComponent)),
new CodeMatch(OpCodes.Ldfld, AccessTools.Field(typeof(MinerComponent), nameof(MinerComponent.speed)))
);
pos = matcher.Pos + 9;
matcher.Advance(5).MatchForward(false,
new CodeMatch(OpCodes.Conv_R4),
new CodeMatch(OpCodes.Callvirt, AccessTools.PropertySetter(typeof(Slider), nameof(Slider.value)))
);
pos2 = matcher.Pos;
matcher.Start().Advance(pos).RemoveInstructions(pos2 - pos).Insert(
Transpilers.EmitDelegate((int speed) =>
{
if (speed <= 30000)
return (speed - 10000) / 1000;
return (speed - 30000) / 10000 + 20;
})
);
return matcher.InstructionEnumeration();
}
[HarmonyTranspiler]
[HarmonyPatch(typeof(UIStationWindow), nameof(UIStationWindow.OnMaxMiningSpeedChange))]
private static IEnumerable<CodeInstruction> UIStationWindow_OnMaxMiningSpeedChange_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
{
var matcher = new CodeMatcher(instructions, generator);
matcher.MatchForward(false,
new CodeMatch(ci => ci.opcode == OpCodes.Ldc_I4 && ci.OperandIs(10000)),
new CodeMatch(OpCodes.Ldarg_1)
);
var pos = matcher.Pos;
matcher.MatchForward(false,
new CodeMatch(OpCodes.Stloc_1)
);
var pos2 = matcher.Pos;
matcher.Start().Advance(pos);
var labels = matcher.Labels;
matcher.RemoveInstructions(pos2 - pos);
matcher.Insert(
new CodeInstruction(OpCodes.Ldarg_1).WithLabels(labels),
Transpilers.EmitDelegate((float value) =>
{
var intval = (int)(value + 0.5f);
if (intval <= 20)
return intval * 1000 + 10000;
return (intval - 20) * 10000 + 30000;
})
);
return matcher.InstructionEnumeration();
}
[HarmonyTranspiler]
[HarmonyPatch(typeof(UIStationWindow), nameof(UIStationWindow.OnMaxChargePowerSliderValueChange))]
private static IEnumerable<CodeInstruction> UIStationWindow_OnMaxChargePowerSliderValueChange_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
{
var matcher = new CodeMatcher(instructions, generator);
matcher.MatchForward(false,
new CodeMatch(OpCodes.Ldarg_0),
new CodeMatch(OpCodes.Ldfld, AccessTools.Field(typeof(UIStationWindow), nameof(UIStationWindow.factory))),
new CodeMatch(OpCodes.Ldfld, AccessTools.Field(typeof(PlanetFactory), nameof(PlanetFactory.powerSystem))),
new CodeMatch(OpCodes.Ldfld, AccessTools.Field(typeof(PowerSystem), nameof(PowerSystem.consumerPool)))
);
var labels = matcher.Labels;
matcher.Labels = null;
matcher.Insert(
new CodeInstruction(OpCodes.Ldarg_0).WithLabels(labels),
new CodeInstruction(OpCodes.Ldarg_1),
Transpilers.EmitDelegate((UIStationWindow window, float value) =>
{
float prevMax = window.workEnergyPrefab * 5L / 50000L;
if (value <= prevMax)
{
return value;
}
return prevMax * (value - prevMax + 1);
}),
new CodeInstruction(OpCodes.Starg_S, 1)
);
return matcher.InstructionEnumeration();
}
}
}

View File

@@ -8,6 +8,9 @@
+ Add 2 options to `Belt signal item generation`:
- `Count generations as production in statistics`
- `Count removals as consumption in statistics`
+ New feature: `Increase maximum power usage in Logistic Stations and Advanced Mining Machines`
- Logistic Stations: Increased max charging power to 3GW(ILS) and 600MW(PLS) (10x of original)
- Advanced Mining Machines: Increased max mining speed to 1000%
* 2.3.15
+ New features:
- `Instant teleport (like that in Sandbox mode)`
@@ -38,7 +41,7 @@
* 2.3.6
+ Support for UXAssist's new function within `Finish build immediately`.
+ Add a warning message when `Build without condition` is enabled.
+ Fix a issue in `Finish build immediately` that some buildings are not finished immediately.
+ Fix an issue in `Finish build immediately` that some buildings are not finished immediately.
* 2.3.5
+ Fix another crash in `Skip bullet period`.
* 2.3.4
@@ -121,6 +124,9 @@
- Count removals as consumption in statistics
- Count all raws and intermediates in statistics
- Belt signal alt format
+ Increase maximum power usage in Logistic Stations and Advanced Mining Machines
- Logistic Stations: Increased max charging power to 3GW(ILS) and 600MW(PLS) (10x of original)
- Advanced Mining Machines: Increased max mining speed to 1000%
+ Remove space limit between wind turbines and solar panels
+ Boost power generations for kinds of power generators
+ Planet:
@@ -153,6 +159,9 @@
+ 为`传送带信号物品生成`添加了两个选项:
- `统计信息里将生成计算为产物`
- `统计信息里将移除计算为消耗`
+ 新功能:`提升物流塔和大型采矿机的最大功耗`
- 物流塔将最大充电功率提高到3GW(星际物流塔)和600MW(行星物流塔)原来的10倍
- 大型采矿机将最大采矿速度提高到1000%
* 2.3.15
+ 新功能:
- `快速传送(和沙盒模式一样)`
@@ -266,6 +275,9 @@
- 统计信息里将移除计算为消耗
- 统计面板中计算所有原材料和中间产物
- 传送带信号替换格式
+ 提升物流塔和大型采矿机的最大功耗
- 物流塔将最大充电功率提高到3GW(星际物流塔)和600MW(行星物流塔)原来的10倍
- 大型采矿机将最大采矿速度提高到1000%
+ 风力发电机和太阳能板无间距限制
+ 提升各种发电设备发电量
+ 行星:

View File

@@ -45,6 +45,7 @@ public static class UIConfigWindow
I18N.Add("Boost fuel power", "Boost fuel power(x50,000)", "提升燃料发电(x50,000)");
I18N.Add("Boost fuel power 2", "(x20,000 for deuteron, x10,000 for antimatter)", "(氘核燃料棒x20,000反物质燃料棒x10,000)");
I18N.Add("Boost geothermal power", "Boost geothermal power(x50,000)", "提升地热发电(x50,000)");
I18N.Add("Increase maximum power usage in Logistic Stations and Advanced Mining Machines", "Increase maximum power usage in Logistic Stations and Advanced Mining Machines", "提升物流塔和大型采矿机的最大功耗");
I18N.Add("Infinite Natural Resources", "Infinite natural resources", "自然资源采集不消耗");
I18N.Add("Fast Mining", "Fast mining", "高速采集");
I18N.Add("Pump Anywhere", "Pump anywhere", "平地抽水");
@@ -111,6 +112,8 @@ public static class UIConfigWindow
x += 180f;
y += 6f;
var tip1 = MyWindow.AddTipsButton(x, y, tab2, "Belt signal alt format", "Belt signal alt format tips", "belt-signal-alt-format-tips");
y += 30f;
MyCheckBox.CreateCheckBox(x, y, tab2, FactoryPatch.GreaterPowerUsageInLogisticsEnabled, "Increase maximum power usage in Logistic Stations and Advanced Mining Machines");
FactoryPatch.BeltSignalGeneratorEnabled.SettingChanged += (_, _) =>
{

View File

@@ -1,6 +1,6 @@
{
"name": "CheatEnabler",
"version_number": "2.3.15",
"version_number": "2.3.16",
"website_url": "https://github.com/soarqin/DSP_Mods/tree/master/CheatEnabler",
"description": "Add various cheat functions while disabling abnormal determinants / 添加一些作弊功能,同时屏蔽异常检测",
"dependencies": [