1
0
mirror of https://github.com/soarqin/DSP_Mods.git synced 2026-03-22 11:53:25 +08:00

UXAssist: bug fix

This commit is contained in:
2026-02-13 23:29:22 +08:00
parent 3e24461ef0
commit 2e13206346
5 changed files with 97 additions and 63 deletions

View File

@@ -3,6 +3,10 @@
## Changlog ## Changlog
* 1.5.4
* `Auto-contruct`:
* Add a UI option to hide it completely.
* Fix an issue that may cause circling.
* 1.5.3 * 1.5.3
* New feature: `Auto-contruct` * New feature: `Auto-contruct`
* Fly to buildings to be contructed automatically. * Fly to buildings to be contructed automatically.
@@ -377,6 +381,10 @@
## 更新日志 ## 更新日志
* 1.5.4
* `自动建造`
* 增加了一个 UI 选项,可完全隐藏该功能。
* 修复了可能导致盘旋的问题。
* 1.5.3 * 1.5.3
* 新功能:`自动建造` * 新功能:`自动建造`
* 自动飞行到待建造的建筑处进行建造。 * 自动飞行到待建造的建筑处进行建造。

View File

@@ -271,7 +271,7 @@ public static class UIFunctions
{ {
if (ToggleAutoConstruct == null) return; if (ToggleAutoConstruct == null) return;
var localPlanet = GameMain.localPlanet; var localPlanet = GameMain.localPlanet;
var active = localPlanet != null && localPlanet.factoryLoaded && localPlanet.factory.prebuildCount > 0; var active = localPlanet != null && localPlanet.factoryLoaded && localPlanet.factory.prebuildCount > 0 && Patches.FactoryPatch.AutoConstructButtonEnabled.Value;
ToggleAutoConstruct.gameObject.SetActive(active); ToggleAutoConstruct.gameObject.SetActive(active);
ConstructCountPanel.gameObject.SetActive(active); ConstructCountPanel.gameObject.SetActive(active);
} }

View File

@@ -32,6 +32,7 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
public static ConfigEntry<bool> DoNotRenderEntitiesEnabled; public static ConfigEntry<bool> DoNotRenderEntitiesEnabled;
public static ConfigEntry<bool> DragBuildPowerPolesEnabled; public static ConfigEntry<bool> DragBuildPowerPolesEnabled;
public static ConfigEntry<bool> DragBuildPowerPolesAlternatelyEnabled; public static ConfigEntry<bool> DragBuildPowerPolesAlternatelyEnabled;
public static ConfigEntry<bool> AutoConstructButtonEnabled;
public static ConfigEntry<bool> AutoConstructEnabled; public static ConfigEntry<bool> AutoConstructEnabled;
public static ConfigEntry<bool> BeltSignalsForBuyOutEnabled; public static ConfigEntry<bool> BeltSignalsForBuyOutEnabled;
public static ConfigEntry<bool> TankFastFillInAndTakeOutEnabled; public static ConfigEntry<bool> TankFastFillInAndTakeOutEnabled;
@@ -124,6 +125,7 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
DoNotRenderEntitiesEnabled.SettingChanged += (_, _) => DoNotRenderEntities.Enable(DoNotRenderEntitiesEnabled.Value); DoNotRenderEntitiesEnabled.SettingChanged += (_, _) => DoNotRenderEntities.Enable(DoNotRenderEntitiesEnabled.Value);
DragBuildPowerPolesEnabled.SettingChanged += (_, _) => DragBuildPowerPoles.Enable(DragBuildPowerPolesEnabled.Value); DragBuildPowerPolesEnabled.SettingChanged += (_, _) => DragBuildPowerPoles.Enable(DragBuildPowerPolesEnabled.Value);
DragBuildPowerPolesAlternatelyEnabled.SettingChanged += (_, _) => DragBuildPowerPoles.AlternatelyChanged(); DragBuildPowerPolesAlternatelyEnabled.SettingChanged += (_, _) => DragBuildPowerPoles.AlternatelyChanged();
AutoConstructButtonEnabled.SettingChanged += (_, _) => AutoConstructButton.Enable(AutoConstructButtonEnabled.Value);
AutoConstructEnabled.SettingChanged += (_, _) => Functions.UIFunctions.UpdateToggleAutoConstructCheckButtonVisiblility(); AutoConstructEnabled.SettingChanged += (_, _) => Functions.UIFunctions.UpdateToggleAutoConstructCheckButtonVisiblility();
BeltSignalsForBuyOutEnabled.SettingChanged += (_, _) => BeltSignalsForBuyOut.Enable(BeltSignalsForBuyOutEnabled.Value); BeltSignalsForBuyOutEnabled.SettingChanged += (_, _) => BeltSignalsForBuyOut.Enable(BeltSignalsForBuyOutEnabled.Value);
TankFastFillInAndTakeOutEnabled.SettingChanged += (_, _) => TankFastFillInAndTakeOut.Enable(TankFastFillInAndTakeOutEnabled.Value); TankFastFillInAndTakeOutEnabled.SettingChanged += (_, _) => TankFastFillInAndTakeOut.Enable(TankFastFillInAndTakeOutEnabled.Value);
@@ -154,6 +156,7 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
ProtectVeinsFromExhaustion.Enable(ProtectVeinsFromExhaustionEnabled.Value); ProtectVeinsFromExhaustion.Enable(ProtectVeinsFromExhaustionEnabled.Value);
DoNotRenderEntities.Enable(DoNotRenderEntitiesEnabled.Value); DoNotRenderEntities.Enable(DoNotRenderEntitiesEnabled.Value);
DragBuildPowerPoles.Enable(DragBuildPowerPolesEnabled.Value); DragBuildPowerPoles.Enable(DragBuildPowerPolesEnabled.Value);
AutoConstructButton.Enable(AutoConstructButtonEnabled.Value);
BeltSignalsForBuyOut.Enable(BeltSignalsForBuyOutEnabled.Value); BeltSignalsForBuyOut.Enable(BeltSignalsForBuyOutEnabled.Value);
TankFastFillInAndTakeOut.Enable(TankFastFillInAndTakeOutEnabled.Value); TankFastFillInAndTakeOut.Enable(TankFastFillInAndTakeOutEnabled.Value);
TweakBuildingBuffer.Enable(TweakBuildingBufferEnabled.Value); TweakBuildingBuffer.Enable(TweakBuildingBufferEnabled.Value);
@@ -171,6 +174,7 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
TweakBuildingBuffer.Enable(false); TweakBuildingBuffer.Enable(false);
TankFastFillInAndTakeOut.Enable(false); TankFastFillInAndTakeOut.Enable(false);
BeltSignalsForBuyOut.Enable(false); BeltSignalsForBuyOut.Enable(false);
AutoConstructButton.Enable(false);
DragBuildPowerPoles.Enable(false); DragBuildPowerPoles.Enable(false);
DoNotRenderEntities.Enable(false); DoNotRenderEntities.Enable(false);
ProtectVeinsFromExhaustion.Enable(false); ProtectVeinsFromExhaustion.Enable(false);
@@ -276,9 +280,21 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
return matcher.InstructionEnumeration(); return matcher.InstructionEnumeration();
} }
#region Auto Construct public class AutoConstructButton : PatchImpl<AutoConstructButton>
{
private static int _lastPrebuildCount = -1; private static int _lastPrebuildCount = -1;
protected override void OnEnable()
{
Functions.UIFunctions.UpdateToggleAutoConstructCheckButtonVisiblility();
}
protected override void OnDisable()
{
Functions.UIFunctions.UpdateToggleAutoConstructCheckButtonVisiblility();
_lastPrebuildCount = -1;
}
[HarmonyPostfix] [HarmonyPostfix]
[HarmonyPatch(typeof(PlanetData), nameof(PlanetData.NotifyFactoryLoaded))] [HarmonyPatch(typeof(PlanetData), nameof(PlanetData.NotifyFactoryLoaded))]
private static void PlanetData_NotifyFactoryLoaded_Postfix() private static void PlanetData_NotifyFactoryLoaded_Postfix()
@@ -318,6 +334,10 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
var player = __instance.player; var player = __instance.player;
if (prebuildCount <= player.mecha.constructionModule.buildTargetTotalCount) return; if (prebuildCount <= player.mecha.constructionModule.buildTargetTotalCount) return;
if (player.orders.orderCount > 0) return; if (player.orders.orderCount > 0) return;
if (player.controller.horzVelocity.sqrMagnitude > 0.01f)
{
return;
}
var prebuilds = factory.prebuildPool; var prebuilds = factory.prebuildPool;
var minDist = float.MaxValue; var minDist = float.MaxValue;
var minIndex = 0; var minIndex = 0;
@@ -345,9 +365,9 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
player.controller.actionWalk.SwitchToFly(); player.controller.actionWalk.SwitchToFly();
return; return;
} }
player.Order(OrderNode.MoveTo(prebuilds[minIndex].pos + diff.normalized * 4f), false); player.Order(OrderNode.MoveTo(prebuilds[minIndex].pos + diff.normalized * 6f), false);
}
} }
#endregion
public class NightLight : PatchImpl<NightLight> public class NightLight : PatchImpl<NightLight>
{ {

View File

@@ -71,6 +71,7 @@ public static class UIConfigWindow
I18N.Add("Do not render factory entities", "Do not render factory entities (except belts and sorters)", "不渲染工厂建筑实体(除了传送带和分拣器)"); I18N.Add("Do not render factory entities", "Do not render factory entities (except belts and sorters)", "不渲染工厂建筑实体(除了传送带和分拣器)");
I18N.Add("Drag building power poles in maximum connection range", "Drag building power poles in maximum connection range", "拖动建造电线杆时自动使用最大连接距离间隔"); I18N.Add("Drag building power poles in maximum connection range", "Drag building power poles in maximum connection range", "拖动建造电线杆时自动使用最大连接距离间隔");
I18N.Add("Build Tesla Tower and Wireless Power Tower alternately", "Build Tesla Tower and Wireless Power Tower alternately", "交替建造电力感应塔和无线输电塔"); I18N.Add("Build Tesla Tower and Wireless Power Tower alternately", "Build Tesla Tower and Wireless Power Tower alternately", "交替建造电力感应塔和无线输电塔");
I18N.Add("Auto-construct button", "Auto-construct button", "自动建造按钮");
I18N.Add("Belt signals for buy out dark fog items automatically", "Belt signals for buy out dark fog items automatically", "用于自动购买黑雾物品的传送带信号"); I18N.Add("Belt signals for buy out dark fog items automatically", "Belt signals for buy out dark fog items automatically", "用于自动购买黑雾物品的传送带信号");
I18N.Add("Ctrl+Shift+Click to pick items from whole belts", "Ctrl+Shift+Click to pick items from whole belts", "按住Ctrl+Shift点击从整条传送带抓取物品"); I18N.Add("Ctrl+Shift+Click to pick items from whole belts", "Ctrl+Shift+Click to pick items from whole belts", "按住Ctrl+Shift点击从整条传送带抓取物品");
I18N.Add("Include branches of belts", "Include branches of belts", "包含传送带分支"); I18N.Add("Include branches of belts", "Include branches of belts", "包含传送带分支");
@@ -411,6 +412,9 @@ public static class UIConfigWindow
} }
} }
y += 36f;
wnd.AddCheckBox(x, y, tab2, FactoryPatch.AutoConstructButtonEnabled, "Auto-construct button");
{ {
y += 36f; y += 36f;
wnd.AddCheckBox(x, y, tab2, FactoryPatch.PressShiftToTakeWholeBeltItemsEnabled, "Ctrl+Shift+Click to pick items from whole belts"); wnd.AddCheckBox(x, y, tab2, FactoryPatch.PressShiftToTakeWholeBeltItemsEnabled, "Ctrl+Shift+Click to pick items from whole belts");

View File

@@ -130,6 +130,8 @@ public class UXAssist : BaseUnityPlugin, IModCanSave
"Drag building power poles in maximum connection range"); "Drag building power poles in maximum connection range");
FactoryPatch.DragBuildPowerPolesAlternatelyEnabled = Config.Bind("Factory", "DragBuildPowerPolesAlternately", true, FactoryPatch.DragBuildPowerPolesAlternatelyEnabled = Config.Bind("Factory", "DragBuildPowerPolesAlternately", true,
"Build Tesla Tower and Wireless Power Tower alternately"); "Build Tesla Tower and Wireless Power Tower alternately");
FactoryPatch.AutoConstructButtonEnabled = Config.Bind("Factory", "AutoConstructButton", false,
"Enable auto-construct button");
FactoryPatch.AutoConstructEnabled = Config.Bind("Factory", "AutoConstruct", false, FactoryPatch.AutoConstructEnabled = Config.Bind("Factory", "AutoConstruct", false,
"Fly toward the building to be constructed automatically"); "Fly toward the building to be constructed automatically");
FactoryPatch.BeltSignalsForBuyOutEnabled = Config.Bind("Factory", "BeltSignalsForBuyOut", false, FactoryPatch.BeltSignalsForBuyOutEnabled = Config.Bind("Factory", "BeltSignalsForBuyOut", false,