1
0
mirror of https://github.com/soarqin/DSP_Mods.git synced 2025-12-09 02:13:29 +08:00

UXAssist 1.0.26

This commit is contained in:
2024-06-05 21:00:29 +08:00
parent 57c5993692
commit 63e684ebf4
7 changed files with 162 additions and 11 deletions

View File

@@ -11,8 +11,7 @@ public static class TechPatch
{
public static ConfigEntry<bool> Enabled;
private static Harmony _patch;
public static void Init()
{
Enabled.SettingChanged += (_, _) => ValueChanged();
@@ -43,12 +42,11 @@ public static class TechPatch
var history = GameMain.history;
var techStates = history.techStates;
var techID = techProto.ID;
if (techStates == null || !techStates.ContainsKey(techID))
if (techStates == null || !techStates.TryGetValue(techID, out var value))
{
return;
}
var value = techStates[techID];
if (value.unlocked)
{
return;

View File

@@ -4,6 +4,13 @@
#### 一些提升用户体验的功能和补丁
## Changlog
* 1.0.26
+ New features:
- Restore upgrades of `Sorter Cargo Stacking` on panel
- Set `Sorter Cargo Stacking` to unresearched state
+ Changes to `Protect veins from exhaustion` configuration:
- The vein amount is protected at 1000 by default now
- The maximum vein amount is changed to 10000, and the maximum oil speed is changed to 10.0/s
* 1.0.25
+ Fix an issue that building entites can not be clicked through when `Do not render factory entities (except belts and sorters)` is enabled
* 1.0.24
@@ -169,6 +176,9 @@
- Construct only nodes but frames
- Re-initialize Dyson Spheres
- Quick dismantle Dyson Shells
+ Tech
- Restore upgrades of `Sorter Cargo Stacking` on panel
- Set `Sorter Cargo Stacking` to unresearched state
+ Combat
- Open Dark Fog Communicator anywhere
@@ -185,6 +195,13 @@
* [CruiseAssist](https://dsp.thunderstore.io/package/tanu/CruiseAssist/) and its extension [AutoPilot](https://dsp.thunderstore.io/package/tanu/AutoPilot/): `Auto navigation on sailings` and `Auto-cruise` implementations
## 更新日志
* 1.0.26
+ 新功能:
- 在升级面板上恢复`分拣器货物堆叠`的升级
-`分拣器货物堆叠`设为未研究状态
+ `保护矿脉不会耗尽`配置的改动:
- 现在默认矿脉数量保护在1000
- 最大矿脉数量改为10000最大采油速度改为10.0/s
* 1.0.25
+ 修复了`不渲染工厂建筑实体(除了传送带和分拣器)`启用时无法点穿工厂实体的问题
* 1.0.24
@@ -352,6 +369,9 @@
- 只建造节点不建造框架
- 初始化戴森球
- 快速拆除戴森壳
+ 科研
- 在升级面板上恢复`分拣器货物堆叠`的升级
-`分拣器货物堆叠`设为未研究状态
+ 战斗
- 在任意位置打开黑雾通讯器

109
UXAssist/TechPatch.cs Normal file
View File

@@ -0,0 +1,109 @@
using System.Collections.Generic;
using System.Reflection.Emit;
using BepInEx.Configuration;
using HarmonyLib;
using UXAssist.Common;
namespace UXAssist;
public static class TechPatch
{
public static ConfigEntry<bool> SorterCargoStackingEnabled;
public static void Init()
{
I18N.Add("分拣器运货量", "Sorter Mk.III cargo stacking : ", "极速分拣器每次可运送 ");
SorterCargoStackingEnabled.SettingChanged += (_, _) => SorterCargoStacking.Enable(SorterCargoStackingEnabled.Value);
SorterCargoStacking.Enable(SorterCargoStackingEnabled.Value);
}
public static void Uninit()
{
SorterCargoStacking.Enable(false);
}
private static class SorterCargoStacking
{
private static Harmony _patch;
private static bool _protoPatched;
public static void Enable(bool on)
{
TryPatchProto(on);
if (on)
{
_patch ??= Harmony.CreateAndPatchAll(typeof(SorterCargoStacking));
return;
}
_patch?.UnpatchSelf();
_patch = null;
}
private static void TryPatchProto(bool on)
{
var techs = LDB.techs;
if (techs == null || techs.dataArray == null || techs.dataArray.Length == 0) return;
if (on)
{
var delim = -26.0f;
var tp3301 = techs.Select(3301);
if (tp3301 != null && tp3301.IsObsolete)
{
_protoPatched = false;
delim = tp3301.Position.y + 1.0f;
}
if (_protoPatched) return;
foreach (var tp in techs.dataArray)
{
switch (tp.ID)
{
case >= 3301 and <= 3305:
tp.UnlockValues[0] = tp.ID - 3300 + 1;
tp.IsObsolete = false;
continue;
case 3306:
tp.PreTechs = [];
continue;
}
if (tp.Position.y > delim) continue;
tp.Position.y -= 4.0f;
}
_protoPatched = true;
}
else
{
var delim = -28.0f;
var tp3301 = techs.Select(3301);
if (tp3301 != null && !tp3301.IsObsolete)
{
_protoPatched = true;
delim = tp3301.Position.y - 1.0f;
}
if (!_protoPatched) return;
foreach (var tp in techs.dataArray)
{
if (tp.ID is >= 3301 and <= 3305)
{
tp.IsObsolete = true;
continue;
}
if (tp.Position.y > delim) continue;
tp.Position.y += 4.0f;
}
_protoPatched = false;
}
}
[HarmonyPostfix, HarmonyPriority(Priority.Last)]
[HarmonyPatch(typeof(VFPreload), "InvokeOnLoadWorkEnded")]
private static void VFPreload_InvokeOnLoadWorkEnded_Postfix()
{
TryPatchProto(true);
}
}
}

View File

@@ -18,7 +18,7 @@ public static class UIConfigWindow
I18N.Add("Planet/Factory", "Planet/Factory", "行星/工厂");
I18N.Add("Player/Mecha", "Player/Mecha", "玩家/机甲");
I18N.Add("Dyson Sphere", "Dyson Sphere", "戴森球");
I18N.Add("Combat", "Combat", "战斗");
I18N.Add("Tech/Combat", "Tech/Combat", "科研/战斗");
I18N.Add("Enable game window resize", "Enable game window resize (maximum box and thick frame)", "可调整游戏窗口大小(可最大化和拖动边框)");
I18N.Add("Remeber window position and size on last exit", "Remeber window position and size on last exit", "记住上次退出时的窗口位置和大小");
/*
@@ -64,6 +64,8 @@ public static class UIConfigWindow
I18N.Add("Click to dismantle selected layer", "Click to dismantle selected layer", "点击拆除对应的戴森壳");
I18N.Add("Dismantle selected layer", "Dismantle selected layer", "拆除选中的戴森壳");
I18N.Add("Dismantle selected layer Confirm", "This operation will dismantle selected layer, are you sure?", "此操作将会拆除选中的戴森壳,确定吗?");
I18N.Add("Restore upgrades of \"Sorter Cargo Stacking\" on panel", "Restore upgrades of \"Sorter Cargo Stacking\" on panel", "在升级面板上恢复\"分拣器货物叠加\"的升级");
I18N.Add("Set \"Sorter Cargo Stacking\" to unresearched state", "Set \"Sorter Cargo Stacking\" to unresearched state", "将\"分拣器货物叠加\"设为未研究状态");
I18N.Add("Open Dark Fog Communicator", "Open Dark Fog Communicator", "打开黑雾通讯器");
I18N.Apply();
MyConfigWindow.OnUICreated += CreateUI;
@@ -237,10 +239,28 @@ public static class UIConfigWindow
}
_dysonTab = tab4;
var tab5 = wnd.AddTab(_windowTrans, "Combat");
var tab5 = wnd.AddTab(_windowTrans, "Tech/Combat");
x = 10;
y = 10;
wnd.AddButton(x, y, tab5, "Open Dark Fog Communicator", 16, "button-open-df-communicator", () =>
MyCheckBox.CreateCheckBox(x, y, tab5, TechPatch.SorterCargoStackingEnabled, "Restore upgrades of \"Sorter Cargo Stacking\" on panel");
y += 36f;
wnd.AddButton(x, y, 300f, tab5, "Set \"Sorter Cargo Stacking\" to unresearched state", 16, "button-remove-cargo-stacking", () =>
{
var history = GameMain.data?.history;
if (history == null) return;
history.inserterStackCountObsolete = 1;
for (var id = 3301; id <= 3305; id++)
{
history.techStates.TryGetValue(id, out var state);
if (!state.unlocked) continue;
state.unlocked = false;
state.hashUploaded = 0;
history.techStates[id] = state;
}
});
y += 36f;
y += 36f;
wnd.AddButton(x, y, 300f, tab5, "Open Dark Fog Communicator", 16, "button-open-df-communicator", () =>
{
if (!(GameMain.data?.gameDesc.isCombatMode ?? false)) return;
var uiGame = UIRoot.instance.uiGame;

View File

@@ -72,8 +72,8 @@ public class UXAssist : BaseUnityPlugin
"Quick build and dismantle stacking labs");
FactoryPatch.ProtectVeinsFromExhaustionEnabled = Config.Bind("Factory", "ProtectVeinsFromExhaustion", false,
"Protect veins from exhaustion");
FactoryPatch.ProtectVeinsFromExhaustion.KeepVeinAmount = Config.Bind("Factory", "KeepVeinAmount", 100, new ConfigDescription("Keep veins amount (0 to disable)", new AcceptableValueRange<int>(0, 1000))).Value;
FactoryPatch.ProtectVeinsFromExhaustion.KeepOilSpeed = Config.Bind("Factory", "KeepOilSpeed", 1.0f, new ConfigDescription("Keep minimal oil speed (< 0.1 to disable)", new AcceptableValueRange<float>(0.0f, 1.0f))).Value;
FactoryPatch.ProtectVeinsFromExhaustion.KeepVeinAmount = Config.Bind("Factory", "KeepVeinAmount", 1000, new ConfigDescription("Keep veins amount (0 to disable)", new AcceptableValueRange<int>(0, 10000))).Value;
FactoryPatch.ProtectVeinsFromExhaustion.KeepOilSpeed = Config.Bind("Factory", "KeepOilSpeed", 1.0f, new ConfigDescription("Keep minimal oil speed (< 0.1 to disable)", new AcceptableValueRange<float>(0.0f, 10.0f))).Value;
FactoryPatch.DoNotRenderEntitiesEnabled = Config.Bind("Factory", "DoNotRenderEntities", false,
"Do not render factory entities");
FactoryPatch.DragBuildPowerPolesEnabled = Config.Bind("Factory", "DragBuildPowerPoles", false,
@@ -92,6 +92,8 @@ public class UXAssist : BaseUnityPlugin
PlayerPatch.AutoBoostEnabled = Config.Bind("Player", "AutoBoost", false,
"Auto boost speed with auto-cruise enabled");
PlayerPatch.DistanceToWarp = Config.Bind("Player", "DistanceToWarp", 5.0, "Distance to warp (in AU)");
TechPatch.SorterCargoStackingEnabled = Config.Bind("Tech", "SorterCargoStacking", false,
"Restore upgrades of `Sorter Cargo Stacking` on panel");
DysonSpherePatch.StopEjectOnNodeCompleteEnabled = Config.Bind("DysonSphere", "StopEjectOnNodeComplete", false,
"Stop ejectors when available nodes are all filled up");
DysonSpherePatch.OnlyConstructNodesEnabled = Config.Bind("DysonSphere", "OnlyConstructNodes", false,
@@ -111,6 +113,7 @@ public class UXAssist : BaseUnityPlugin
FactoryPatch.Init();
PlanetPatch.Init();
PlayerPatch.Init();
TechPatch.Init();
DysonSpherePatch.Init();
I18N.Apply();
@@ -119,6 +122,7 @@ public class UXAssist : BaseUnityPlugin
private void OnDestroy()
{
DysonSpherePatch.Uninit();
TechPatch.Uninit();
PlayerPatch.Uninit();
PlanetPatch.Uninit();
FactoryPatch.Uninit();

View File

@@ -4,7 +4,7 @@
<TargetFramework>net472</TargetFramework>
<BepInExPluginGuid>org.soardev.uxassist</BepInExPluginGuid>
<Description>DSP MOD - UXAssist</Description>
<Version>1.0.25</Version>
<Version>1.0.26</Version>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>latest</LangVersion>
<PackageId>UXAssist</PackageId>

View File

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