1
0
mirror of https://github.com/soarqin/DSP_Mods.git synced 2025-12-09 03:33:29 +08:00
This commit is contained in:
2024-03-10 18:25:51 +08:00
parent d9a4cb312d
commit 456598f2a1
14 changed files with 166 additions and 16 deletions

View File

@@ -82,4 +82,11 @@ public class CheatEnabler : BaseUnityPlugin
AbnormalDisabler.Uninit();
DevShortcuts.Uninit();
}
private void Update()
{
if (VFInput.inputing) return;
FactoryPatch.OnUpdate();
}
}

View File

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

View File

@@ -2,8 +2,10 @@
using System.Collections.Generic;
using System.Reflection.Emit;
using BepInEx.Configuration;
using CommonAPI.Systems;
using HarmonyLib;
using UnityEngine;
using UXAssist.Common;
namespace CheatEnabler;
@@ -23,10 +25,20 @@ public static class FactoryPatch
public static ConfigEntry<bool> BoostGeothermalPowerEnabled;
private static Harmony _factoryPatch;
private static PressKeyBind _noConditionKey;
public static void Init()
{
if (_factoryPatch != null) return;
_noConditionKey = KeyBindings.RegisterKeyBinding(new BuiltinKey
{
key = new CombineKey((int)KeyCode.Q, CombineKey.ALT_COMB, ECombineKeyAction.OnceClick, false),
conflictGroup = KeyBindConflict.BUILD_MODE_1 | KeyBindConflict.KEYBOARD_KEYBIND,
name = "ToggleNoCondition",
canOverride = true
}
);
I18N.Add("KEYToggleNoCondition", "Toggle No Condition Build", "切换无条件建造");
ImmediateEnabled.SettingChanged += (_, _) => ImmediateBuild.Enable(ImmediateEnabled.Value);
ArchitectModeEnabled.SettingChanged += (_, _) => ArchitectMode.Enable(ArchitectModeEnabled.Value);
NoConditionEnabled.SettingChanged += (_, _) => NoConditionBuild.Enable(NoConditionEnabled.Value);
@@ -51,6 +63,14 @@ public static class FactoryPatch
_factoryPatch = Harmony.CreateAndPatchAll(typeof(FactoryPatch));
}
public static void OnUpdate()
{
if (_noConditionKey.keyValue)
{
NoConditionEnabled.Value = !NoConditionEnabled.Value;
}
}
public static void Uninit()
{
_factoryPatch?.UnpatchSelf();

View File

@@ -4,6 +4,8 @@
#### 添加一些作弊功能,同时屏蔽异常检测
## Changlog
* 2.3.11
+ Add a shortcut to toggle `No condition build`, you can modify the shortcut on system settings window. This depends on [UXAssist](https://dsp.thunderstore.io/package/soarqin/UXAssist) 1.0.15 or later.
* 2.3.10
+ Fix following functions not working in new game updates:
- `Pump Anywhere`
@@ -124,6 +126,8 @@
* [Multifunction_mod](https://github.com/blacksnipebiu/Multifunction_mod): Some cheat functions
## 更新日志
* 2.3.11
+ 添加了一个快捷键来切换`无条件建造`,你可以在系统设置面板中修改快捷键。这依赖于[UXAssist](https://dsp.thunderstore.io/package/soarqin/UXAssist) 1.0.15或更高版本
* 2.3.10
+ 修复了以下功能在新游戏版本中不生效的问题:
- `平地抽水`

View File

@@ -1,10 +1,10 @@
{
"name": "CheatEnabler",
"version_number": "2.3.10",
"version_number": "2.3.11",
"website_url": "https://github.com/soarqin/DSP_Mods/tree/master/CheatEnabler",
"description": "Add various cheat functions while disabling abnormal determinants / 添加一些作弊功能,同时屏蔽异常检测",
"dependencies": [
"xiaoye97-BepInEx-5.4.17",
"soarqin-UXAssist-1.0.13"
"soarqin-UXAssist-1.0.15"
]
}

View File

@@ -0,0 +1,32 @@
using BepInEx.Configuration;
using CommonAPI.Systems;
using UnityEngine;
namespace UXAssist.Common;
public static class KeyBindings
{
public static PressKeyBind RegisterKeyBinding(BuiltinKey key)
{
return CustomKeyBindSystem.RegisterKeyBindWithReturn<PressKeyBind>(key);
}
public static CombineKey FromKeyboardShortcut(KeyboardShortcut shortcut)
{
byte mod = 0;
foreach (var modifier in shortcut.Modifiers)
{
mod |= modifier switch
{
KeyCode.LeftShift => 1,
KeyCode.RightShift => 1,
KeyCode.LeftControl => 2,
KeyCode.RightControl => 2,
KeyCode.LeftAlt => 4,
KeyCode.RightAlt => 4,
_ => 0
};
}
return new CombineKey((int)shortcut.MainKey, mod, ECombineKeyAction.OnceClick, false);
}
}

View File

@@ -19,6 +19,7 @@ public static class FactoryPatch
public static ConfigEntry<bool> LargerAreaForTerraformEnabled;
public static ConfigEntry<bool> OffGridBuildingEnabled;
public static ConfigEntry<bool> LogisticsCapacityTweaksEnabled;
public static ConfigEntry<bool> TreatStackingAsSingleEnabled;
private static Harmony _factoryPatch;
@@ -32,6 +33,7 @@ public static class FactoryPatch
LargerAreaForTerraformEnabled.SettingChanged += (_, _) => LargerAreaForTerraform.Enable(LargerAreaForTerraformEnabled.Value);
OffGridBuildingEnabled.SettingChanged += (_, _) => OffGridBuilding.Enable(OffGridBuildingEnabled.Value);
LogisticsCapacityTweaksEnabled.SettingChanged += (_, _) => LogisticsCapacityTweaks.Enable(LogisticsCapacityTweaksEnabled.Value);
TreatStackingAsSingleEnabled.SettingChanged += (_, _) => TreatStackingAsSingle.Enable(TreatStackingAsSingleEnabled.Value);
UnlimitInteractive.Enable(UnlimitInteractiveEnabled.Value);
RemoveSomeConditionBuild.Enable(RemoveSomeConditionEnabled.Value);
NightLight.Enable(NightLightEnabled.Value);
@@ -40,6 +42,7 @@ public static class FactoryPatch
LargerAreaForTerraform.Enable(LargerAreaForTerraformEnabled.Value);
OffGridBuilding.Enable(OffGridBuildingEnabled.Value);
LogisticsCapacityTweaks.Enable(LogisticsCapacityTweaksEnabled.Value);
TreatStackingAsSingle.Enable(TreatStackingAsSingleEnabled.Value);
_factoryPatch ??= Harmony.CreateAndPatchAll(typeof(FactoryPatch));
}
@@ -54,6 +57,7 @@ public static class FactoryPatch
LargerAreaForTerraform.Enable(false);
OffGridBuilding.Enable(false);
LogisticsCapacityTweaks.Enable(false);
TreatStackingAsSingle.Enable(false);
_factoryPatch?.UnpatchSelf();
_factoryPatch = null;
@@ -917,4 +921,39 @@ public static class FactoryPatch
return false;
}
}
public static class TreatStackingAsSingle
{
private static Harmony _patch;
public static void Enable(bool enable)
{
if (enable)
{
_patch ??= Harmony.CreateAndPatchAll(typeof(TreatStackingAsSingle));
return;
}
_patch?.UnpatchSelf();
_patch = null;
}
[HarmonyTranspiler]
[HarmonyPatch(typeof(MonitorComponent), nameof(MonitorComponent.InternalUpdate))]
private static IEnumerable<CodeInstruction> MonitorComponent_InternalUpdate_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
{
var matcher = new CodeMatcher(instructions, generator);
matcher.MatchForward(false,
new CodeMatch(OpCodes.Call, AccessTools.Method(typeof(MonitorComponent), nameof(MonitorComponent.GetCargoAtIndexByFilter)))
);
matcher.Advance(-3);
var localVar = matcher.Operand;
matcher.Advance(4).Insert(
new CodeInstruction(OpCodes.Ldloca, localVar),
new CodeInstruction(OpCodes.Ldc_I4_1),
new CodeInstruction(OpCodes.Stfld, AccessTools.Field(typeof(Cargo), nameof(Cargo.stack)))
);
return matcher.InstructionEnumeration();
}
}
}

View File

@@ -4,6 +4,10 @@
#### 一些提升用户体验的功能和补丁
## Changlog
* 1.0.15
+ Move shortcut key settings to system options window, which depends on [CommonAPI](https://dsp.thunderstore.io/package/CommonAPI/CommonAPI)
+ Enable `Hide UI` function(`F11` by default) while on Star Map view
+ New function: `Treat stack items as single in monitor components`
* 1.0.14
+ Fix crash in `Re-initialize planet` again
+ `Off-grid building and stepped rotation`: Add Z coordinate to display, and adjust the precision to 4 decimal after point
@@ -66,6 +70,7 @@
+ Sort blueprint structures before saving, to reduce generated blueprint data size a little
+ Increase maximum count of Metadata Instantiations to 20000 (from 2000)
+ Increase capacity of player order queue to 128 (from 16)
+ Enable `Hide UI` function(`F11` by default) while on Star Map view
* Features:
+ General
- Enable game window resize
@@ -79,6 +84,7 @@
- Larger area for upgrade and dismantle(30x30 at max)
- Larger area for terraform(30x30 at max)
- Enable player actions in globe view
- Treat stack items as single in monitor components
- Enhanced control for logistic storage limits
- Logistic storage limits are not scaled on upgrading `Logistics Carrier Capacity`, if they are not set to maximum capacity.
- You can use arrow keys to adjust logistic storage limits gracefully.
@@ -104,6 +110,10 @@
* [OffGridConstruction](https://github.com/Velociraptor115-DSPModding/OffGridConstruction): Off-grid building & stepped rotation implementations
## 更新日志
* 1.0.15
+ 将快捷键设置移动到系统选项窗口,依赖于[CommonAPI](https://dsp.thunderstore.io/package/CommonAPI/CommonAPI)
+ 在星图视图中启用`隐藏UI`功能(默认按键为`F11`)
+ 新功能:`在流速计中将堆叠物品视为单个物品`
* 1.0.14
+ 再次尝试修复`初始化本行星`导致的崩溃问题
+ `脱离网格建造和小角度旋转`现在显示建筑Z坐标并将精度调整为小数点后4位
@@ -164,6 +174,9 @@
+ 更严格的建造菜单热键检测因此在按住Ctrl/Alt/Shift时不再会触发建造热键(0~9, F1~F10, X, U)
+ 修复了`矿物利用`升级到8000级以上时弹出警告的bug
+ 保存蓝图前对建筑进行排序,以减少生成的蓝图数据大小
+ 将元数据提取的最大数量增加到20000(原来为2000)
+ 将玩家指令队列的容量增加到128(原来为16)
+ 在星图视图中启用`隐藏UI`功能(默认按键为`F11`)
* 功能:
+ 通用
- 可调整游戏窗口大小(可最大化和拖动边框)
@@ -179,6 +192,7 @@
- 范围升级和拆除的最大区域扩大(最大30x30)
- 范围铺设地基的最大区域扩大(最大30x30)
- 在行星视图中允许玩家操作
- 在流速计中将堆叠物品视为单个物品
- 物流塔存储数量限制控制改进
- 当升级`运输机舱扩容`时,不会对各种物流塔的存储限制按比例提升,除非设置为最大允许容量。
- 你可以使用方向键微调物流塔存储限制

View File

@@ -1,4 +1 @@
#### TODO
* Shortcut key interface
* Enable F11 in Galaxy View
* Ignore stacking on monitors

View File

@@ -18,7 +18,7 @@ public class MyConfigWindow : MyWindowWithTabs
public override void _OnCreate()
{
_windowTrans = GetComponent<RectTransform>();
_windowTrans.sizeDelta = new Vector2(810f, 440f);
_windowTrans.sizeDelta = new Vector2(810f, 476f);
OnUICreated?.Invoke(this, _windowTrans);
SetCurrentTab(0);

View File

@@ -35,6 +35,7 @@ public static class UIConfigWindow
I18N.Add("Enhance control for logistic storage limits tips", "Logistic storage limits are not scaled on upgrading 'Logistics Carrier Capacity', if they are not set to maximum capacity.\nUse arrow keys to adjust logistic storage limits:\n \u2190/\u2192: -/+10 \u2193\u2191: -/+100", "当升级'运输机舱扩容'时,不会对各种物流塔的存储限制按比例提升,除非设置为最大允许容量。\n你可以使用方向键微调物流塔存储限制\n \u2190\u2192: -/+10 \u2193\u2191: -/+100");
I18N.Add("Enhanced count control for hand-make", "Enhanced count control for hand-make", "手动制造物品的数量控制改进");
I18N.Add("Enhanced count control for hand-make tips", "Maximum count is increased to 1000.\nHold Ctrl/Shift/Alt to change the count rapidly.", "最大数量提升至1000\n按住Ctrl/Shift/Alt可快速改变数量");
I18N.Add("Treat stack items as single in monitor components", "Treat stack items as single in monitor components", "在流速计中将堆叠物品视为单个物品");
I18N.Add("Initialize This Planet", "Initialize this planet", "初始化本行星");
I18N.Add("Initialize This Planet Confirm", "This operation will destroy all buildings and revert terrains on this planet, are you sure?", "此操作将会摧毁本行星上的所有建筑并恢复地形,确定吗?");
I18N.Add("Dismantle All Buildings", "Dismantle all buildings", "拆除所有建筑");
@@ -74,9 +75,6 @@ public static class UIConfigWindow
y += 30f;
*/
MyCheckBox.CreateCheckBox(x, y, tab1, GamePatch.ConvertSavesFromPeaceEnabled, "Convert old saves to Combat Mode on loading");
x += 10f;
y = 278f;
MyKeyBinder.CreateKeyBinder(x, y, tab1, UXAssist.Hotkey, "Hotkey");
var tab2 = wnd.AddTab(trans, "Planet/Factory");
x = 0f;
y = 10f;
@@ -94,6 +92,8 @@ public static class UIConfigWindow
y += 36f;
MyCheckBox.CreateCheckBox(x, y, tab2, FactoryPatch.OffGridBuildingEnabled, "Off-grid building and stepped rotation");
y += 36f;
MyCheckBox.CreateCheckBox(x, y, tab2, FactoryPatch.TreatStackingAsSingleEnabled, "Treat stack items as single in monitor components");
y += 36f;
MyCheckBox.CreateCheckBox(x, y, tab2, PlanetPatch.PlayerActionsInGlobeViewEnabled, "Enable player actions in globe view");
y += 36f;
MyCheckBox.CreateCheckBox(x, y, tab2, FactoryPatch.LogisticsCapacityTweaksEnabled, "Enhance control for logistic storage limits");

View File

@@ -2,7 +2,8 @@
using System.Collections.Generic;
using System.Reflection.Emit;
using BepInEx;
using BepInEx.Configuration;
using CommonAPI;
using CommonAPI.Systems;
using HarmonyLib;
using UnityEngine;
using UnityEngine.UI;
@@ -11,21 +12,29 @@ using UXAssist.UI;
namespace UXAssist;
[BepInDependency(CommonAPIPlugin.GUID)]
[CommonAPISubmoduleDependency(nameof(CustomKeyBindSystem))]
[BepInPlugin(PluginInfo.PLUGIN_GUID, PluginInfo.PLUGIN_NAME, PluginInfo.PLUGIN_VERSION)]
public class UXAssist : BaseUnityPlugin
{
public new static readonly BepInEx.Logging.ManualLogSource Logger =
BepInEx.Logging.Logger.CreateLogSource(PluginInfo.PLUGIN_NAME);
public static ConfigEntry<KeyboardShortcut> Hotkey;
private static bool _configWinInitialized;
private static MyConfigWindow _configWin;
private static Harmony _patch;
private static bool _initialized;
private static PressKeyBind _toggleKey;
private void Awake()
{
Hotkey = Config.Bind("General", "Shortcut", KeyboardShortcut.Deserialize("BackQuote + LeftAlt"), "Shortcut to open config window");
_toggleKey = KeyBindings.RegisterKeyBinding(new BuiltinKey
{
key = new CombineKey((int)KeyCode.BackQuote, CombineKey.ALT_COMB, ECombineKeyAction.OnceClick, false),
conflictGroup = KeyBindConflict.BUILD_MODE_1 | KeyBindConflict.KEYBOARD_KEYBIND,
name = "OpenUXAssistConfigWindow",
canOverride = true
});
GamePatch.EnableWindowResizeEnabled = Config.Bind("Game", "EnableWindowResize", false,
"Enable game window resize (maximum box and thick frame)");
GamePatch.LoadLastWindowRectEnabled = Config.Bind("Game", "LoadLastWindowRect", false,
@@ -56,6 +65,8 @@ public class UXAssist : BaseUnityPlugin
"Enable off grid building and stepped rotation");
FactoryPatch.LogisticsCapacityTweaksEnabled = Config.Bind("Factory", "LogisticsCapacityTweaks", true,
"Logistics capacity related tweaks");
FactoryPatch.TreatStackingAsSingleEnabled = Config.Bind("Factory", "TreatStackingAsSingle", false,
"Treat stack items as single in monitor components");
PlanetFunctions.OrbitalCollectorMaxBuildCount = Config.Bind("Factory", "OCMaxBuildCount", 0, "Maximum Orbital Collectors to build once, set to 0 to build as many as possible");
PlayerPatch.EnhancedMechaForgeCountControlEnabled = Config.Bind("Player", "EnhancedMechaForgeCountControl", false,
"Enhanced count control for hand-make, increases maximum of count to 1000, and you can hold Ctrl/Shift/Alt to change the count rapidly");
@@ -66,6 +77,7 @@ public class UXAssist : BaseUnityPlugin
I18N.Init();
I18N.Add("UXAssist Config", "UXAssist Config", "UX助手设置");
I18N.Add("KEYOpenUXAssistConfigWindow", "Open UXAssist Config Window", "打开UX助手设置面板");
I18N.Apply();
// UI Patch
@@ -100,7 +112,10 @@ public class UXAssist : BaseUnityPlugin
{
FactoryPatch.LogisticsCapacityTweaks.OnUpdate();
}
if (Hotkey.Value.IsDown()) ToggleConfigWindow();
if (_toggleKey.keyValue)
{
ToggleConfigWindow();
}
}
private void LateUpdate()
@@ -333,6 +348,7 @@ public class UXAssist : BaseUnityPlugin
return matcher.InstructionEnumeration();
}
// Increase Player Command Queue from 16 to 128
[HarmonyTranspiler]
[HarmonyPatch(typeof(PlayerOrder), nameof(PlayerOrder._trimEnd))]
[HarmonyPatch(typeof(PlayerOrder), nameof(PlayerOrder.Enqueue))]
@@ -348,4 +364,24 @@ public class UXAssist : BaseUnityPlugin
});
return matcher.InstructionEnumeration();
}
// Allow F11 in star map
[HarmonyTranspiler]
[HarmonyPatch(typeof(UIGame), nameof(UIGame._OnLateUpdate))]
private static IEnumerable<CodeInstruction> UIGame__OnLateUpdate_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
{
var matcher = new CodeMatcher(instructions, generator);
matcher.MatchForward(false,
new CodeMatch(OpCodes.Ldsfld, AccessTools.Field(typeof(VFInput), nameof(VFInput.inFullscreenGUI))),
new CodeMatch(ci => ci.opcode == OpCodes.Brfalse || ci.opcode == OpCodes.Brfalse_S)
);
var jumpPos = matcher.Advance(1).Operand;
matcher.Advance(-1).Insert(
new CodeInstruction(OpCodes.Ldarg_0),
new CodeInstruction(OpCodes.Ldfld, AccessTools.Field(typeof(UIGame), nameof(UIGame.starmap))),
new CodeInstruction(OpCodes.Callvirt, AccessTools.PropertyGetter(typeof(ManualBehaviour), nameof(ManualBehaviour.active))),
new CodeInstruction(OpCodes.Brtrue_S, jumpPos)
);
return matcher.InstructionEnumeration();
}
}

View File

@@ -4,7 +4,7 @@
<TargetFramework>net472</TargetFramework>
<BepInExPluginGuid>org.soardev.uxassist</BepInExPluginGuid>
<Description>DSP MOD - UXAssist</Description>
<Version>1.0.14</Version>
<Version>1.0.15</Version>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>latest</LangVersion>
<PackageId>UXAssist</PackageId>
@@ -17,6 +17,7 @@
<PackageReference Include="BepInEx.PluginInfoProps" Version="1.*" />
<PackageReference Include="DysonSphereProgram.GameLibs" Version="0.10.29.21950-r.0" />
<PackageReference Include="UnityEngine.Modules" Version="2018.4.12" IncludeAssets="compile" />
<PackageReference Include="DysonSphereProgram.Modding.CommonAPI" Version="1.6.5" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework.TrimEnd(`0123456789`))' == 'net'">

View File

@@ -1,6 +1,6 @@
{
"name": "UXAssist",
"version_number": "1.0.14",
"version_number": "1.0.15",
"website_url": "https://github.com/soarqin/DSP_Mods/tree/master/UXAssist",
"description": "Some functions and patches for better user experience / 一些提升用户体验的功能和补丁",
"dependencies": [