mirror of
https://github.com/soarqin/DSP_Mods.git
synced 2026-02-04 19:02:18 +08:00
work in progress
This commit is contained in:
@@ -2323,23 +2323,55 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
|
|||||||
}
|
}
|
||||||
itemBundle = factory._tmp_items;
|
itemBundle = factory._tmp_items;
|
||||||
full = false;
|
full = false;
|
||||||
if (GameMain.instance.timei < nextTimei) return;
|
|
||||||
nextTimei = GameMain.instance.timei + 12;
|
|
||||||
if (entityId == 0 || factory.entityPool[entityId].id != entityId)
|
if (entityId == 0 || factory.entityPool[entityId].id != entityId)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (GameMain.instance.timei < nextTimei) return;
|
||||||
|
nextTimei = GameMain.instance.timei + 12;
|
||||||
|
|
||||||
ref var entityData = ref factory.entityPool[entityId];
|
ref var entityData = ref factory.entityPool[entityId];
|
||||||
if (entityData.beltId <= 0) return;
|
if (entityData.beltId <= 0) return;
|
||||||
var cargoTraffic = factory.cargoTraffic;
|
var cargoTraffic = factory.cargoTraffic;
|
||||||
ref var belt = ref cargoTraffic.beltPool[entityData.beltId];
|
ref var belt = ref cargoTraffic.beltPool[entityData.beltId];
|
||||||
if (belt.id != entityData.beltId) return;
|
if (belt.id != entityData.beltId) return;
|
||||||
var cargoPath = cargoTraffic.GetCargoPath(belt.segPathId);
|
|
||||||
var end = cargoPath.bufferLength - 1;
|
HashSet<int> pathIds = [belt.segPathId];
|
||||||
var buffer = cargoPath.buffer;
|
if (PressShiftToTakeWholeBeltItemsIncludeBranches.Value)
|
||||||
Dictionary<int, long> takeOutItems = [];
|
{
|
||||||
|
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 mainPlayer = factory.gameData.mainPlayer;
|
||||||
var factorySystem = factory.factorySystem;
|
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)
|
foreach (var beltId in cargoPath.belts)
|
||||||
{
|
{
|
||||||
ref var b = ref cargoTraffic.beltPool[beltId];
|
ref var b = ref cargoTraffic.beltPool[beltId];
|
||||||
@@ -2364,8 +2396,8 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int i = 0;
|
}
|
||||||
while (i <= end)
|
for (var i = 0; i <= end;)
|
||||||
{
|
{
|
||||||
if (buffer[i] >= 246)
|
if (buffer[i] >= 246)
|
||||||
{
|
{
|
||||||
@@ -2378,8 +2410,9 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
|
|||||||
takeOutItems[item] = (takeOutItems.TryGetValue(item, out var value) ? value : 0)
|
takeOutItems[item] = (takeOutItems.TryGetValue(item, out var value) ? value : 0)
|
||||||
+ ((long)stack | ((long)inc << 32));
|
+ ((long)stack | ((long)inc << 32));
|
||||||
Array.Clear(buffer, i - 4, 10);
|
Array.Clear(buffer, i - 4, 10);
|
||||||
i += 10;
|
i += 6;
|
||||||
if (cargoPath.updateLen < i) cargoPath.updateLen = i;
|
if (cargoPath.updateLen < i) cargoPath.updateLen = i;
|
||||||
|
i += 4;
|
||||||
cargoPath.cargoContainer.RemoveCargo(index);
|
cargoPath.cargoContainer.RemoveCargo(index);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -2391,6 +2424,7 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
foreach (var kvp in takeOutItems)
|
foreach (var kvp in takeOutItems)
|
||||||
{
|
{
|
||||||
var added = mainPlayer.TryAddItemToPackage(kvp.Key, (int)(kvp.Value & 0xFFFFFFFF), (int)(kvp.Value >> 32), true, entityId);
|
var added = mainPlayer.TryAddItemToPackage(kvp.Key, (int)(kvp.Value & 0xFFFFFFFF), (int)(kvp.Value >> 32), true, entityId);
|
||||||
|
|||||||
Reference in New Issue
Block a user