From 3c8f258a1be2331c8ec68e9e40fa065cf5f17a45 Mon Sep 17 00:00:00 2001 From: Soar Qin Date: Sat, 19 Apr 2025 22:39:47 +0800 Subject: [PATCH] UXAssist: new feature for 1.2.20 --- UXAssist/CHANGELOG.md | 10 ++++ UXAssist/Functions/FactoryFunctions.cs | 74 ++++++++++++++++++++++++++ UXAssist/Patches/FactoryPatch.cs | 17 +++++- UXAssist/README.md | 6 +++ UXAssist/UIConfigWindow.cs | 4 ++ UXAssist/UXAssist.cs | 2 + UXAssist/UXAssist.csproj | 2 +- UXAssist/package/manifest.json | 2 +- 8 files changed, 113 insertions(+), 4 deletions(-) diff --git a/UXAssist/CHANGELOG.md b/UXAssist/CHANGELOG.md index df30d8a..433f6d5 100644 --- a/UXAssist/CHANGELOG.md +++ b/UXAssist/CHANGELOG.md @@ -1,5 +1,10 @@ ## Changlog +* 1.2.20 + + New feature: `Dismantle blueprint selected buildings` + - Press shortcut key in blueprint copy mode to dismantle selected buildings. + - The default shortcut key is Ctrl+X, you can set it in system options panel. + + `Night Sunlight`: Fix bugs that sunlight angle is not updated as expected again. * 1.2.19 + New feature: `Tweak building buffer` - Factory recipe buffer formula: take the larger value between `Assembler buffer time multiplier(in seconds) * items needed per second` and `Assembler buffer minimum multiplier * items needed per recipe` @@ -265,6 +270,11 @@ ## 更新日志 +* 1.2.20 + + 新功能:`拆除蓝图选中的建筑` + - 在蓝图复制模式下按快捷键拆除选中的建筑 + - 默认快捷键是Ctrl+X,可以在系统选项面板中设置 + + `夜间日光灯`:再次修复了光照角度未正确更新的问题 * 1.2.19 + 新功能:`调整建筑输入缓冲` - 工厂配方计算公式,在`工厂配方缓冲时间倍率秒数x每秒需要的原料数量`和`工厂配方缓冲最小倍率x每生产一次配方需要的原料数量`中取更大的那个值 diff --git a/UXAssist/Functions/FactoryFunctions.cs b/UXAssist/Functions/FactoryFunctions.cs index c4f7806..ca18aec 100644 --- a/UXAssist/Functions/FactoryFunctions.cs +++ b/UXAssist/Functions/FactoryFunctions.cs @@ -1,3 +1,5 @@ +using System.Collections.Generic; + namespace UXAssist.Functions; public static class FactoryFunctions @@ -19,4 +21,76 @@ public static class FactoryFunctions cargoTraffic._arrInputs(ref i0, ref i1, ref i2); cargoTraffic.AlterBeltConnections(beltId, 0, i0, i1, i2); } + + public static void DismantleBlueprintSelectedBuildings() + { + var player = GameMain.mainPlayer; + var build = player?.controller?.actionBuild; + if (build == null) return; + var blueprintCopyTool = build.blueprintCopyTool; + if (blueprintCopyTool == null || !blueprintCopyTool.active) return; + var factory = build.factory; + List buildPreviewsToRemove = []; + foreach (var buildPreview in blueprintCopyTool.bpPool) + { + if (buildPreview?.item == null || buildPreview.objId <= 0) continue; + int index; + if ((index = buildPreviewsToRemove.BinarySearch(buildPreview.objId)) < 0) + buildPreviewsToRemove.Insert(~index, buildPreview.objId); + var isBelt = buildPreview.desc.isBelt; + var isInserter = buildPreview.desc.isInserter; + if (isInserter) continue; + var objId = buildPreview.objId; + if (isBelt) + { + var needCheck = false; + for (var j = 0; j < 2; j++) + { + factory.ReadObjectConn(objId, j, out _, out var connObjId, out _); + if (connObjId == 0 || factory.ObjectIsBelt(connObjId) || blueprintCopyTool.ObjectIsInserter(connObjId)) continue; + needCheck = true; + break; + } + if (needCheck) + { + for (var k = 0; k < 16; k++) + { + factory.ReadObjectConn(objId, k, out _, out var connObjId, out _); + if (connObjId != 0 && (index = buildPreviewsToRemove.BinarySearch(connObjId)) < 0 && (factory.ObjectIsBelt(connObjId) || blueprintCopyTool.ObjectIsInserter(connObjId))) + buildPreviewsToRemove.Insert(~index, connObjId); + } + } + for (var m = 0; m < 4; m++) + { + factory.ReadObjectConn(objId, m, out _, out var connObjId, out _); + if (connObjId == 0 || !factory.ObjectIsBelt(connObjId) || buildPreviewsToRemove.BinarySearch(connObjId) >= 0) continue; + for (var j = 0; j < 2; j++) + { + factory.ReadObjectConn(connObjId, j, out _, out var connObjId2, out _); + if (connObjId2 == 0 || (index = buildPreviewsToRemove.BinarySearch(connObjId2)) >= 0 || factory.ObjectIsBelt(connObjId2) || blueprintCopyTool.ObjectIsInserter(connObjId2)) continue; + buildPreviewsToRemove.Insert(~index, connObjId2); + break; + } + } + continue; + } + if (buildPreview.desc.addonType == EAddonType.Belt) continue; + for (var j = 0; j < 16; j++) + { + factory.ReadObjectConn(objId, j, out _, out var connObjId, out _); + if (connObjId != 0 && (index = buildPreviewsToRemove.BinarySearch(connObjId)) < 0 && (factory.ObjectIsBelt(connObjId) || blueprintCopyTool.ObjectIsInserter(connObjId))) + buildPreviewsToRemove.Insert(~index, connObjId); + } + } + foreach (var objId in buildPreviewsToRemove) + { + build.DoDismantleObject(objId); + } + buildPreviewsToRemove = null; + blueprintCopyTool.ClearSelection(); + blueprintCopyTool.ClearPreSelection(); + blueprintCopyTool.ResetBlueprint(); + blueprintCopyTool.ResetBuildPreviews(); + blueprintCopyTool.RefreshBlueprintData(); + } } diff --git a/UXAssist/Patches/FactoryPatch.cs b/UXAssist/Patches/FactoryPatch.cs index 87042e8..66e5bf1 100644 --- a/UXAssist/Patches/FactoryPatch.cs +++ b/UXAssist/Patches/FactoryPatch.cs @@ -41,10 +41,12 @@ public class FactoryPatch : PatchImpl public static ConfigEntry LabBufferExtraCountForAdvancedAssemble; public static ConfigEntry LabBufferMaxCountForResearch; public static ConfigEntry ReceiverBufferCount; + public static ConfigEntry DismantleBlueprintSelectionEnabled; private static PressKeyBind _doNotRenderEntitiesKey; private static PressKeyBind _offgridfForPathsKey; private static PressKeyBind _cutConveyorBeltKey; + private static PressKeyBind _dismantleBlueprintSelectionKey; private static int _tankFastFillInAndTakeOutMultiplierRealValue = 2; @@ -53,7 +55,7 @@ public class FactoryPatch : PatchImpl _doNotRenderEntitiesKey = KeyBindings.RegisterKeyBinding(new BuiltinKey { key = new CombineKey(0, 0, ECombineKeyAction.OnceClick, true), - conflictGroup = KeyBindConflict.MOVEMENT | KeyBindConflict.FLYING | KeyBindConflict.SAILING | KeyBindConflict.BUILD_MODE_1 | KeyBindConflict.KEYBOARD_KEYBIND, + conflictGroup = KeyBindConflict.MOVEMENT | KeyBindConflict.FLYING | KeyBindConflict.BUILD_MODE_1 | KeyBindConflict.KEYBOARD_KEYBIND, name = "ToggleDoNotRenderEntities", canOverride = true } @@ -62,7 +64,7 @@ public class FactoryPatch : PatchImpl _offgridfForPathsKey = KeyBindings.RegisterKeyBinding(new BuiltinKey { key = new CombineKey(0, 0, ECombineKeyAction.OnceClick, true), - conflictGroup = KeyBindConflict.MOVEMENT | KeyBindConflict.UI | KeyBindConflict.FLYING | KeyBindConflict.SAILING | KeyBindConflict.BUILD_MODE_1 | KeyBindConflict.KEYBOARD_KEYBIND, + conflictGroup = KeyBindConflict.MOVEMENT | KeyBindConflict.UI | KeyBindConflict.FLYING | KeyBindConflict.BUILD_MODE_1 | KeyBindConflict.KEYBOARD_KEYBIND, name = "OffgridForPaths", canOverride = true } @@ -77,6 +79,15 @@ public class FactoryPatch : PatchImpl } ); I18N.Add("KEYCutConveyorBelt", "Cut conveyor belt", "切割传送带"); + _dismantleBlueprintSelectionKey = KeyBindings.RegisterKeyBinding(new BuiltinKey + { + key = new CombineKey((int)KeyCode.X, CombineKey.CTRL_COMB, ECombineKeyAction.OnceClick, false), + conflictGroup = KeyBindConflict.KEYBOARD_KEYBIND, + name = "DismantleBlueprintSelection", + canOverride = true + } + ); + I18N.Add("KEYDismantleBlueprintSelection", "Dismantle blueprint selected buildings", "拆除蓝图选中的建筑"); BeltSignalsForBuyOut.InitPersist(); ProtectVeinsFromExhaustion.InitConfig(); @@ -164,6 +175,8 @@ public class FactoryPatch : PatchImpl { if (_doNotRenderEntitiesKey.keyValue) DoNotRenderEntitiesEnabled.Value = !DoNotRenderEntitiesEnabled.Value; + if (DismantleBlueprintSelectionEnabled.Value && _dismantleBlueprintSelectionKey.keyValue) + Functions.FactoryFunctions.DismantleBlueprintSelectedBuildings(); } public static void Export(BinaryWriter w) diff --git a/UXAssist/README.md b/UXAssist/README.md index 7db0497..36c5391 100644 --- a/UXAssist/README.md +++ b/UXAssist/README.md @@ -73,6 +73,9 @@ - Auto apply filter with item under mouse cursor while opening the panel - Quick-set item filter while right-clicking item icons in storage list on the panel - Real-time logistic stations info panel + - Dismantle blueprint selected buildings + - Press shortcut key in blueprint copy mode to dismantle selected buildings. + - The default shortcut key is Ctrl+X, you can set it in system options panel. - Re-intialize planet (without reseting veins) - Quick dismantle all buildings (without drops) - Quick build Orbital Collectors @@ -208,6 +211,9 @@ - 在控制面板物流塔列表中右键点击物品图标快速设置为筛选条件 - 物流运输站实时信息面板 - 注意:如果你启用了`Auxilaryfunction`中的`展示物流站信息`,此功能将被隐藏 + - 拆除蓝图选中的建筑 + - 在蓝图复制模式下按快捷键拆除选中的建筑 + - 默认快捷键是Ctrl+X,可以在系统选项面板中设置 - 初始化本行星(不重置矿脉) - 快速拆除所有建筑(不掉落) - 快速建造轨道采集器 diff --git a/UXAssist/UIConfigWindow.cs b/UXAssist/UIConfigWindow.cs index e01a741..f00bb41 100644 --- a/UXAssist/UIConfigWindow.cs +++ b/UXAssist/UIConfigWindow.cs @@ -97,6 +97,7 @@ public static class UIConfigWindow I18N.Add("Extra buffer count for Self-evolution Labs", "Extra buffer count for Self-evolution Labs", "自演化研究站矩阵额外缓冲数量"); I18N.Add("Buffer count for researching in labs", "Buffer count for researching in labs", "研究站科研模式缓存数量"); I18N.Add("Ray Receiver Graviton Lens buffer count", "Ray Receiver Graviton Lens buffer count", "射线接收器透镜缓冲数量"); + I18N.Add("Dismantle blueprint selected buildings", "Dismantle blueprint selected buildings", "拆除蓝图选中的建筑"); I18N.Add("Shortcut keys for showing stars' name", "Shortcut keys for showing stars' name", "启用显示所有星系名称的快捷键"); I18N.Add("Auto navigation on sailings", "Auto navigation on sailings", "宇宙航行时自动导航"); I18N.Add("Enable auto-cruise", "Enable auto-cruise", "启用自动巡航"); @@ -313,6 +314,9 @@ public static class UIConfigWindow x = 400f; y += 18f; + y += 36f; + wnd.AddCheckBox(x, y, tab2, FactoryPatch.DismantleBlueprintSelectionEnabled, "Dismantle blueprint selected buildings"); + { y += 36f; wnd.AddCheckBox(x, y, tab2, FactoryPatch.DragBuildPowerPolesEnabled, "Drag building power poles in maximum connection range"); diff --git a/UXAssist/UXAssist.cs b/UXAssist/UXAssist.cs index 1695970..23792bf 100644 --- a/UXAssist/UXAssist.cs +++ b/UXAssist/UXAssist.cs @@ -146,6 +146,8 @@ public class UXAssist : BaseUnityPlugin, IModCanSave FactoryPatch.LabBufferExtraCountForAdvancedAssemble = Config.Bind("Factory", "LabBufferExtraCountForAdvancedAssemble", 3, new ConfigDescription("Extra buffer count for Self-evolution Labs", new AcceptableValueRange(1, 10))); FactoryPatch.LabBufferMaxCountForResearch = Config.Bind("Factory", "LabBufferMaxCountForResearch", 10, new ConfigDescription("Buffer count for researching in labs", new AcceptableValueRange(2, 20))); FactoryPatch.ReceiverBufferCount = Config.Bind("Factory", "ReceiverBufferCount", 1, new ConfigDescription("Ray Receiver Graviton Lens buffer count", new AcceptableValueRange(1, 20))); + FactoryPatch.DismantleBlueprintSelectionEnabled = Config.Bind("Factory", "DismantleBlueprintSelection", false, + "Dismantle blueprint selected buildings"); LogisticsPatch.LogisticsCapacityTweaksEnabled = Config.Bind("Factory", "LogisticsCapacityTweaks", true, "Logistics capacity related tweaks"); LogisticsPatch.AllowOverflowInLogisticsEnabled = Config.Bind("Factory", "AllowOverflowInLogistics", false, diff --git a/UXAssist/UXAssist.csproj b/UXAssist/UXAssist.csproj index 28bf070..19cffb2 100644 --- a/UXAssist/UXAssist.csproj +++ b/UXAssist/UXAssist.csproj @@ -4,7 +4,7 @@ net472 org.soardev.uxassist DSP MOD - UXAssist - 1.2.19 + 1.2.20 true latest UXAssist diff --git a/UXAssist/package/manifest.json b/UXAssist/package/manifest.json index d034344..db54ad8 100644 --- a/UXAssist/package/manifest.json +++ b/UXAssist/package/manifest.json @@ -1,6 +1,6 @@ { "name": "UXAssist", - "version_number": "1.2.19", + "version_number": "1.2.20", "website_url": "https://github.com/soarqin/DSP_Mods/tree/master/UXAssist", "description": "Some functions and patches for better user experience / 一些提升用户体验的功能和补丁", "dependencies": [