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

Compare commits

7 Commits

Author SHA1 Message Date
1467a6010d work in progress 2025-11-13 22:16:28 +08:00
6f5b779d58 work in progress 2025-11-12 02:43:26 +08:00
d8fa46d495 priority fix 2025-11-11 23:18:26 +08:00
af3b46be11 minor check 2025-11-11 01:41:06 +08:00
96f160926c work in progress 2025-11-10 22:39:58 +08:00
ee812bbc79 work in progress 2025-11-10 01:41:55 +08:00
052c23d3b7 ready for UXAssist 1.4.4 release 2025-11-06 00:45:40 +08:00
12 changed files with 364 additions and 36 deletions

View File

@@ -134,12 +134,12 @@ public class DysonSpherePatch : PatchImpl<DysonSpherePatch>
{
UpdateSailLifeTime();
UpdateSailsCacheForThisGame();
GameLogicProc.OnGameBegin += GameMain_Begin_Postfix;
GameLogicProc.OnGameBegin += OnGameBegin;
}
protected override void OnDisable()
{
GameLogicProc.OnGameBegin -= GameMain_Begin_Postfix;
GameLogicProc.OnGameBegin -= OnGameBegin;
}
private static void UpdateSailLifeTime()
@@ -172,7 +172,7 @@ public class DysonSpherePatch : PatchImpl<DysonSpherePatch>
_sailsCacheCapacity[index] = capacity;
}
private static void GameMain_Begin_Postfix()
private static void OnGameBegin()
{
UpdateSailsCacheForThisGame();
UpdateSailLifeTime();

View File

@@ -94,14 +94,14 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
ControlPanelRemoteLogistics.Enable(ControlPanelRemoteLogisticsEnabled.Value);
Enable(true);
CargoTrafficPatch.Enable(true);
GameLogicProc.OnGameBegin += GameMain_Begin_Postfix_For_ImmBuild;
GameLogicProc.OnGameBegin += OnGameBegin_For_ImmBuild;
GameLogicProc.OnDataLoaded += OnDataLoaded;
}
public static void Uninit()
{
GameLogicProc.OnDataLoaded -= OnDataLoaded;
GameLogicProc.OnGameBegin -= GameMain_Begin_Postfix_For_ImmBuild;
GameLogicProc.OnGameBegin -= OnGameBegin_For_ImmBuild;
CargoTrafficPatch.Enable(false);
Enable(false);
ImmediateBuild.Enable(false);
@@ -292,7 +292,7 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
}
}
private static void GameMain_Begin_Postfix_For_ImmBuild()
private static void OnGameBegin_For_ImmBuild()
{
if (DSPGame.IsMenuDemo) return;
var factory = GameMain.mainPlayer?.factory;
@@ -629,12 +629,12 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
protected override void OnEnable()
{
InitSignalBelts();
GameLogicProc.OnGameBegin += GameMain_Begin_Postfix;
GameLogicProc.OnGameBegin += OnGameBegin;
}
protected override void OnDisable()
{
GameLogicProc.OnGameBegin -= GameMain_Begin_Postfix;
GameLogicProc.OnGameBegin -= OnGameBegin;
_initialized = false;
_signalBelts = null;
_signalBeltsCapacity = 0;
@@ -865,7 +865,7 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
set.Remove(v);
}
private static void GameMain_Begin_Postfix()
private static void OnGameBegin()
{
if (DSPGame.IsMenuDemo) return;
if (BeltSignalGeneratorEnabled.Value) InitSignalBelts();

View File

@@ -3,6 +3,10 @@
## Changlog
* 1.4.4
* `Remember window position and size on last exit`: Fix compatiblity for game patch 0.10.33
* `Real-time logistic stations info panel`: Try to fix a display issue.
* Patch [CommonAPI](https://thunderstore.io/c/dyson-sphere-program/p/CommonAPI/CommonAPI/) temporarily to fix a known issue that shortcut key settings are not saved to config, while its [PR](https://github.com/limoka/CommonAPI/pull/14) is not merged yet.
* 1.4.3
* `Build Tesla Tower and Wireless Power Tower alternately`:
* Fix wrong implementation for latest game patch.
@@ -346,6 +350,10 @@
## 更新日志
* 1.4.4
* `记住上次退出时的窗口位置和大小`修复对游戏补丁0.10.33的兼容性
* `物流站实时信息面板`:尝试修复一个显示问题
* 对[CommonAPI](https://thunderstore.io/c/dyson-sphere-program/p/CommonAPI/CommonAPI/)临时打补丁,修复快捷键设置未能保存到配置文件的已知问题(其[PR](https://github.com/limoka/CommonAPI/pull/14)仍未合并)
* 1.4.3
* `交替建造电力感应塔和无线输电塔`:
* 修复了在最新游戏补丁中的错误实现

View File

@@ -24,6 +24,13 @@ public static class FactoryFunctions
cargoTraffic.AlterBeltConnections(beltId, 0, i0, i1, i2);
}
public static bool ObjectIsBeltOrInserter(PlanetFactory factory, int objId)
{
if (objId == 0) return false;
ItemProto proto = LDB.items.Select(objId > 0 ? factory.entityPool[objId].protoId : factory.prebuildPool[-objId].protoId);
return proto != null && (proto.prefabDesc.isBelt || proto.prefabDesc.isInserter);
}
public static void DismantleBlueprintSelectedBuildings()
{
var player = GameMain.mainPlayer;
@@ -50,7 +57,7 @@ public static class FactoryFunctions
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;
if (connObjId == 0 || ObjectIsBeltOrInserter(factory, connObjId)) continue;
needCheck = true;
break;
}
@@ -59,7 +66,7 @@ public static class FactoryFunctions
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)))
if (connObjId != 0 && (index = buildPreviewsToRemove.BinarySearch(connObjId)) < 0 && ObjectIsBeltOrInserter(factory, connObjId))
buildPreviewsToRemove.Insert(~index, connObjId);
}
}
@@ -70,7 +77,7 @@ public static class FactoryFunctions
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;
if (connObjId2 == 0 || (index = buildPreviewsToRemove.BinarySearch(connObjId2)) >= 0 || ObjectIsBeltOrInserter(factory, connObjId2)) continue;
buildPreviewsToRemove.Insert(~index, connObjId);
break;
}
@@ -81,7 +88,7 @@ public static class FactoryFunctions
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)))
if (connObjId != 0 && (index = buildPreviewsToRemove.BinarySearch(connObjId)) < 0 && ObjectIsBeltOrInserter(factory, connObjId))
buildPreviewsToRemove.Insert(~index, connObjId);
}
}

View File

@@ -0,0 +1,81 @@
using HarmonyLib;
using System.Collections.Generic;
using System.Reflection;
using UXAssist.Functions;
namespace UXAssist.ModsCompat;
class BlueprintTweaks
{
public const string BlueprintTweaksGuid = "org.kremnev8.plugin.BlueprintTweaks";
private static FieldInfo selectObjIdsField;
public static bool Run(Harmony harmony)
{
if (!BepInEx.Bootstrap.Chainloader.PluginInfos.TryGetValue(BlueprintTweaksGuid, out var pluginInfo)) return false;
var assembly = pluginInfo.Instance.GetType().Assembly;
var classType = assembly.GetType("BlueprintTweaks.DragRemoveBuildTool");
if (classType == null) return false;
if (AccessTools.Method(classType, "DetermineMorePreviews") != null) return true;
selectObjIdsField = AccessTools.Field(classType, "selectObjIds");
harmony.Patch(AccessTools.Method(classType, "DeterminePreviews"),
new HarmonyMethod(AccessTools.Method(typeof(BlueprintTweaks), nameof(PatchDeterminePreviews))));
return true;
}
public static void PatchDeterminePreviews(object __instance)
{
var selectObjIds = (HashSet<int>)selectObjIdsField.GetValue(__instance);
var buildTool = (BuildTool)__instance;
var factory = buildTool.factory;
HashSet<int> extraObjIds = [];
foreach (var objId in selectObjIds)
{
var desc = buildTool.GetPrefabDesc(objId);
var isBelt = desc.isBelt;
var isInserter = desc.isInserter;
if (isInserter) continue;
if (isBelt)
{
var needCheck = false;
for (var j = 0; j < 2; j++)
{
factory.ReadObjectConn(objId, j, out _, out var connObjId, out _);
if (connObjId == 0 || FactoryFunctions.ObjectIsBeltOrInserter(factory, 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 && !selectObjIds.Contains(connObjId) && !extraObjIds.Contains(connObjId) && FactoryFunctions.ObjectIsBeltOrInserter(factory, connObjId))
extraObjIds.Add(connObjId);
}
}
for (var m = 0; m < 4; m++)
{
factory.ReadObjectConn(objId, m, out _, out var connObjId, out _);
if (connObjId == 0 || !factory.ObjectIsBelt(connObjId) || selectObjIds.Contains(connObjId) || extraObjIds.Contains(connObjId)) continue;
for (var j = 0; j < 2; j++)
{
factory.ReadObjectConn(connObjId, j, out _, out var connObjId2, out _);
if (connObjId2 == 0 || selectObjIds.Contains(connObjId2) || extraObjIds.Contains(connObjId2) || FactoryFunctions.ObjectIsBeltOrInserter(factory, connObjId2)) continue;
extraObjIds.Add(connObjId);
break;
}
}
continue;
}
if (desc.addonType == EAddonType.Belt) continue;
for (var j = 0; j < 16; j++)
{
factory.ReadObjectConn(objId, j, out _, out var connObjId, out _);
if (connObjId != 0 && !selectObjIds.Contains(connObjId) && !extraObjIds.Contains(connObjId) && FactoryFunctions.ObjectIsBeltOrInserter(factory, connObjId))
extraObjIds.Add(connObjId);
}
}
selectObjIds.UnionWith(extraObjIds);
}
}

View File

@@ -0,0 +1,20 @@
using BepInEx.Bootstrap;
using CommonAPI;
using HarmonyLib;
namespace UXAssist.ModsCompat;
public static class CommonAPIWrapper
{
public static void Run(Harmony harmony)
{
if (!Chainloader.PluginInfos.TryGetValue(CommonAPIPlugin.GUID, out var commonAPIPlugin) ||
commonAPIPlugin.Metadata.Version > new System.Version(1, 6, 7, 0)) return;
harmony.Patch(AccessTools.Method(typeof(GameOption), nameof(GameOption.InitKeys)), new HarmonyMethod(AccessTools.Method(typeof(CommonAPIWrapper), nameof(PatchInitKeys)), Priority.First));
}
public static bool PatchInitKeys(GameOption __instance)
{
return __instance.overrideKeys == null;
}
}

View File

@@ -269,14 +269,14 @@ public class DysonSpherePatch : PatchImpl<DysonSpherePatch>
protected override void OnEnable()
{
InitNodeForAbsorb();
GameLogicProc.OnGameBegin += GameMain_Begin_Postfix;
GameLogicProc.OnGameEnd += GameMain_End_Postfix;
GameLogicProc.OnGameBegin += OnGameBegin;
GameLogicProc.OnGameEnd += OnGameEnd;
}
protected override void OnDisable()
{
GameLogicProc.OnGameEnd -= GameMain_End_Postfix;
GameLogicProc.OnGameBegin -= GameMain_Begin_Postfix;
GameLogicProc.OnGameEnd -= OnGameEnd;
GameLogicProc.OnGameBegin -= OnGameBegin;
_initialized = false;
_nodeForAbsorb = null;
}
@@ -347,12 +347,12 @@ public class DysonSpherePatch : PatchImpl<DysonSpherePatch>
return comp is { Count: > 0 };
}
private static void GameMain_Begin_Postfix()
private static void OnGameBegin()
{
InitNodeForAbsorb();
}
private static void GameMain_End_Postfix()
private static void OnGameEnd()
{
_initialized = false;
_nodeForAbsorb = null;

View File

@@ -45,6 +45,9 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
public static ConfigEntry<int> EjectorBufferCount;
public static ConfigEntry<int> SiloBufferCount;
public static ConfigEntry<bool> ShortcutKeysForBlueprintCopyEnabled;
public static ConfigEntry<bool> PressShiftToTakeWholeBeltItemsEnabled;
public static ConfigEntry<bool> PressShiftToTakeWholeBeltItemsIncludeBranches;
public static ConfigEntry<bool> PressShiftToTakeWholeBeltItemsIncludeInserters;
private static PressKeyBind _doNotRenderEntitiesKey;
private static PressKeyBind _offgridfForPathsKey;
@@ -131,6 +134,7 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
ReceiverBufferCount.SettingChanged += (_, _) => TweakBuildingBuffer.RefreshReceiverBufferCount();
EjectorBufferCount.SettingChanged += (_, _) => TweakBuildingBuffer.RefreshEjectorBufferCount();
SiloBufferCount.SettingChanged += (_, _) => TweakBuildingBuffer.RefreshSiloBufferCount();
PressShiftToTakeWholeBeltItemsEnabled.SettingChanged += (_, _) => PressShiftToTakeWholeBeltItems.Enable(PressShiftToTakeWholeBeltItemsEnabled.Value);
}
public static void Start()
@@ -150,6 +154,7 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
BeltSignalsForBuyOut.Enable(BeltSignalsForBuyOutEnabled.Value);
TankFastFillInAndTakeOut.Enable(TankFastFillInAndTakeOutEnabled.Value);
TweakBuildingBuffer.Enable(TweakBuildingBufferEnabled.Value);
PressShiftToTakeWholeBeltItems.Enable(PressShiftToTakeWholeBeltItemsEnabled.Value);
Enable(true);
UpdateTankFastFillInAndTakeOutMultiplierRealValue();
@@ -159,6 +164,7 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
{
Enable(false);
PressShiftToTakeWholeBeltItems.Enable(false);
TweakBuildingBuffer.Enable(false);
TankFastFillInAndTakeOut.Enable(false);
BeltSignalsForBuyOut.Enable(false);
@@ -276,12 +282,12 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
protected override void OnEnable()
{
GameLogicProc.OnGameEnd += GameMain_End_Postfix;
GameLogicProc.OnGameEnd += OnGameEnd;
}
protected override void OnDisable()
{
GameLogicProc.OnGameEnd -= GameMain_End_Postfix;
GameLogicProc.OnGameEnd -= OnGameEnd;
if (_sunlight)
{
_sunlight.transform.localEulerAngles = new Vector3(0f, 180f);
@@ -292,7 +298,7 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
_nightlightInitialized = false;
}
private static void GameMain_End_Postfix()
private static void OnGameEnd()
{
if (_sunlight)
{
@@ -1405,16 +1411,16 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
protected override void OnEnable()
{
GameLogicProc.OnGameBegin += GameMain_Begin_Postfix;
GameLogicProc.OnGameEnd += GameMain_End_Postfix;
GameLogicProc.OnGameBegin += OnGameBegin;
GameLogicProc.OnGameEnd += OnGameEnd;
FixProto();
}
protected override void OnDisable()
{
UnfixProto();
GameLogicProc.OnGameEnd -= GameMain_End_Postfix;
GameLogicProc.OnGameBegin -= GameMain_Begin_Postfix;
GameLogicProc.OnGameEnd -= OnGameEnd;
GameLogicProc.OnGameBegin -= OnGameBegin;
}
public static void AlternatelyChanged()
@@ -1465,12 +1471,12 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
OldDragBuildDist.Clear();
}
private static void GameMain_Begin_Postfix()
private static void OnGameBegin()
{
FixProto();
}
private static void GameMain_End_Postfix()
private static void OnGameEnd()
{
UnfixProto();
}
@@ -1782,12 +1788,12 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
{
AddBeltSignalProtos();
GameLogicProc.OnDataLoaded += VFPreload_InvokeOnLoadWorkEnded_Postfix;
GameLogicProc.OnGameBegin += GameMain_Begin_Postfix;
GameLogicProc.OnGameBegin += OnGameBegin;
}
protected override void OnDisable()
{
GameLogicProc.OnGameBegin -= GameMain_Begin_Postfix;
GameLogicProc.OnGameBegin -= OnGameBegin;
GameLogicProc.OnDataLoaded -= VFPreload_InvokeOnLoadWorkEnded_Postfix;
}
@@ -1809,7 +1815,7 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
RemovePlanetSignalBelts(factory.index);
}
private static void GameMain_Begin_Postfix()
private static void OnGameBegin()
{
_clusterSeedKey = GameMain.data.GetClusterSeedKey();
InitSignalBelts();
@@ -2233,4 +2239,200 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
return matcher.InstructionEnumeration();
}
}
private class PressShiftToTakeWholeBeltItems : PatchImpl<PressShiftToTakeWholeBeltItems>
{
private static long nextTimei = 0;
protected override void OnEnable()
{
GameLogicProc.OnGameBegin += OnGameBegin;
}
protected override void OnDisable()
{
GameLogicProc.OnGameBegin -= OnGameBegin;
}
private static void OnGameBegin()
{
nextTimei = 0;
}
[HarmonyTranspiler]
[HarmonyPatch(typeof(VFInput), nameof(VFInput._fastTransferWithEntityDown), MethodType.Getter)]
[HarmonyPatch(typeof(VFInput), nameof(VFInput._fastTransferWithEntityPress), MethodType.Getter)]
private static IEnumerable<CodeInstruction> VFInput_fastTransferWithEntityDown_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.shift))),
new CodeMatch(ci => ci.opcode == OpCodes.Brtrue || ci.opcode == OpCodes.Brtrue_S)
);
var lables = matcher.Labels;
matcher.RemoveInstructions(2);
matcher.Labels.AddRange(lables);
return matcher.InstructionEnumeration();
}
[HarmonyTranspiler]
[HarmonyPatch(typeof(PlayerAction_Inspect), nameof(PlayerAction_Inspect.GameTick))]
private static IEnumerable<CodeInstruction> PlayerAction_Inspect_GameTick_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
{
var matcher = new CodeMatcher(instructions, generator);
matcher.MatchForward(false,
new CodeMatch(OpCodes.Ldc_I4_1),
new CodeMatch(OpCodes.Stfld, AccessTools.Field(typeof(PlayerAction_Inspect), nameof(PlayerAction_Inspect.fastFillIn)))
);
matcher.SetAndAdvance(OpCodes.Ldsfld, AccessTools.Field(typeof(VFInput), nameof(VFInput.shift))).Insert(
new CodeInstruction(OpCodes.Ldc_I4_0),
new CodeInstruction(OpCodes.Ceq)
);
var label0 = generator.DefineLabel();
var label1 = generator.DefineLabel();
matcher.Start().MatchForward(false,
new CodeMatch(ci => ci.IsStloc()),
new CodeMatch(OpCodes.Ldc_I4_0),
new CodeMatch(ci => ci.IsStloc()),
new CodeMatch(OpCodes.Ldloc_0),
new CodeMatch(ci => ci.IsLdloc()),
new CodeMatch(ci => ci.IsLdloc()),
new CodeMatch(ci => ci.IsLdloc()),
new CodeMatch(ci => ci.IsLdloc()),
new CodeMatch(OpCodes.Callvirt, AccessTools.Method(typeof(PlanetFactory), nameof(PlanetFactory.EntityFastTakeOut)))
).Advance(8).InsertAndAdvance(
new CodeInstruction(OpCodes.Ldsfld, AccessTools.Field(typeof(VFInput), nameof(VFInput.shift))),
new CodeInstruction(OpCodes.Brfalse_S, label0),
new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(PressShiftToTakeWholeBeltItems), nameof(EntityFastTakeOutAlt))),
new CodeInstruction(OpCodes.Br, label1)
).Labels.Add(label0);
matcher.Advance(1).Labels.Add(label1);
return matcher.InstructionEnumeration();
}
private static void EntityFastTakeOutAlt(PlanetFactory factory, int entityId, bool toPackage, out ItemBundle itemBundle, out bool full)
{
if (factory._tmp_items == null)
{
factory._tmp_items = new ItemBundle();
}
else
{
factory._tmp_items.Clear();
}
itemBundle = factory._tmp_items;
full = false;
if (entityId == 0 || factory.entityPool[entityId].id != entityId)
{
return;
}
if (GameMain.instance.timei < nextTimei) return;
nextTimei = GameMain.instance.timei + 12;
ref var entityData = ref factory.entityPool[entityId];
if (entityData.beltId <= 0) return;
var cargoTraffic = factory.cargoTraffic;
ref var belt = ref cargoTraffic.beltPool[entityData.beltId];
if (belt.id != entityData.beltId) return;
HashSet<int> pathIds = [belt.segPathId];
if (PressShiftToTakeWholeBeltItemsIncludeBranches.Value)
{
List<int> pendingPathIds = [belt.segPathId];
while (pendingPathIds.Count > 0)
{
var lastIndex = pendingPathIds.Count - 1;
var thisPathId = pendingPathIds[lastIndex];
pendingPathIds.RemoveAt(lastIndex);
var path = cargoTraffic.GetCargoPath(thisPathId);
if (path == null) continue;
foreach (var inputPathId in path.inputPaths)
{
if (pathIds.Contains(inputPathId)) continue;
pathIds.Add(inputPathId);
pendingPathIds.Add(inputPathId);
}
if (path.outputPath == null) continue;
var outputPathId = path.outputPath.id;
if (pathIds.Contains(outputPathId)) continue;
pathIds.Add(outputPathId);
pendingPathIds.Add(outputPathId);
}
}
var mainPlayer = factory.gameData.mainPlayer;
var factorySystem = factory.factorySystem;
Dictionary<int, long> takeOutItems = [];
foreach (var pathId in pathIds)
{
var cargoPath = cargoTraffic.GetCargoPath(pathId);
if (cargoPath == null) continue;
var end = cargoPath.bufferLength - 5;
var buffer = cargoPath.buffer;
if (PressShiftToTakeWholeBeltItemsIncludeInserters.Value)
{
foreach (var beltId in cargoPath.belts)
{
ref var b = ref cargoTraffic.beltPool[beltId];
if (b.id != beltId) return;
// From WriteObjectConn: Only slot 4 to 11 is used for belt <-> inserter connections (method argument slot/otherSlot is -1 there)
for (int cidx = 4; cidx < 12; cidx++)
{
factory.ReadObjectConn(b.entityId, cidx, out var isOutput, out var otherObjId, out var otherSlot);
if (otherObjId <= 0) continue;
var inserterId = factory.entityPool[otherObjId].inserterId;
if (inserterId <= 0) continue;
ref var inserter = ref factorySystem.inserterPool[inserterId];
if (inserter.id != inserterId) continue;
if (inserter.itemId > 0 && inserter.stackCount > 0)
{
takeOutItems[inserter.itemId] = (takeOutItems.TryGetValue(inserter.itemId, out var value) ? value : 0)
+ ((long)inserter.itemCount | ((long)inserter.itemInc << 32));
inserter.itemId = 0;
inserter.stackCount = 0;
inserter.itemCount = 0;
inserter.itemInc = 0;
}
}
}
}
for (var i = 0; i <= end;)
{
if (buffer[i] >= 246)
{
i += 250 - buffer[i];
var index = buffer[i + 1] - 1 + (buffer[i + 2] - 1) * 100 + (buffer[i + 3] - 1) * 10000 + (buffer[i + 4] - 1) * 1000000;
ref var cargo = ref cargoPath.cargoContainer.cargoPool[index];
var item = cargo.item;
var stack = cargo.stack;
var inc = cargo.inc;
takeOutItems[item] = (takeOutItems.TryGetValue(item, out var value) ? value : 0)
+ ((long)stack | ((long)inc << 32));
Array.Clear(buffer, i - 4, 10);
i += 6;
if (cargoPath.updateLen < i) cargoPath.updateLen = i;
i += 4;
cargoPath.cargoContainer.RemoveCargo(index);
}
else
{
i += 5;
if (i > end && i < end + 5)
{
i = end;
}
}
}
}
foreach (var kvp in takeOutItems)
{
var added = mainPlayer.TryAddItemToPackage(kvp.Key, (int)(kvp.Value & 0xFFFFFFFF), (int)(kvp.Value >> 32), true, entityId);
if (added > 0)
{
UIItemup.Up(kvp.Key, added);
}
}
}
}
}

View File

@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Reflection.Emit;
using HarmonyLib;
using UnityEngine;

View File

@@ -56,6 +56,8 @@ public class UXAssist : BaseUnityPlugin, IModCanSave
UXAssist()
{
ModsCompat.PlanetVeinUtilization.Run(_harmony);
ModsCompat.BlueprintTweaks.Run(_harmony);
ModsCompat.CommonAPIWrapper.Run(_harmony);
}
private void Awake()
@@ -138,6 +140,12 @@ public class UXAssist : BaseUnityPlugin, IModCanSave
FactoryPatch.SiloBufferCount = Config.Bind("Factory", "SiloBufferCount", 1, new ConfigDescription("Silo buffer count", new AcceptableValueRange<int>(1, 40)));
FactoryPatch.ShortcutKeysForBlueprintCopyEnabled = Config.Bind("Factory", "DismantleBlueprintSelection", false,
"Dismantle blueprint selected buildings");
FactoryPatch.PressShiftToTakeWholeBeltItemsEnabled = Config.Bind("Factory", "PressShiftToTakeWholeBeltItems", false,
"Press Ctrl+Shift to take items from whole belts");
FactoryPatch.PressShiftToTakeWholeBeltItemsIncludeBranches = Config.Bind("Factory", "PressShiftToTakeWholeBeltItemsIncludeBranches", true,
"Press Ctrl+Shift to take items from whole belts: Include branches");
FactoryPatch.PressShiftToTakeWholeBeltItemsIncludeInserters = Config.Bind("Factory", "PressShiftToTakeWholeBeltItemsIncludeInserters", true,
"Press Ctrl+Shift to take items from whole belts: Include inserters");
LogisticsPatch.AutoConfigLogisticsEnabled = Config.Bind("Factory", "AutoConfigLogistics", false,
"Auto-config logistic stations");
LogisticsPatch.AutoConfigLimitAutoReplenishCount = Config.Bind("Factory", "AutoConfigLimitAutoReplenishCount", false,
@@ -217,7 +225,8 @@ public class UXAssist : BaseUnityPlugin, IModCanSave
t => string.Equals(t.Namespace, "UXAssist.Patches", StringComparison.Ordinal) || string.Equals(t.Namespace, "UXAssist.Functions", StringComparison.Ordinal));
_patches?.Do(type => type.GetMethod("Init")?.Invoke(null, null));
_compats = Util.GetTypesInNamespace(Assembly.GetExecutingAssembly(), "UXAssist.ModsCompat");
_compats?.Do(type => type.GetMethod("Init")?.Invoke(null, null));
object[] parameters = [_harmony];
_compats?.Do(type => type.GetMethod("Init")?.Invoke(null, parameters));
I18N.Apply();
}

View File

@@ -4,7 +4,7 @@
<TargetFramework>net472</TargetFramework>
<BepInExPluginGuid>org.soardev.uxassist</BepInExPluginGuid>
<Description>DSP MOD - UXAssist</Description>
<Version>1.4.3</Version>
<Version>1.4.4</Version>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>latest</LangVersion>
<PackageId>UXAssist</PackageId>
@@ -17,7 +17,7 @@
<PackageReference Include="BepInEx.PluginInfoProps" Version="1.*" />
<PackageReference Include="UnityEngine.Modules" Version="2022.3.53" IncludeAssets="compile" />
<!-- <PackageReference Include="DysonSphereProgram.GameLibs" Version="0.10.32.*-r.*" /> -->
<PackageReference Include="DysonSphereProgram.Modding.CommonAPI" Version="1.6.5" />
<PackageReference Include="DysonSphereProgram.Modding.CommonAPI" Version="1.*" />
<PackageReference Include="DysonSphereProgram.Modding.DSPModSave" Version="1.*" />
</ItemGroup>

View File

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