mirror of
https://github.com/soarqin/DSP_Mods.git
synced 2025-12-08 18:53:29 +08:00
minor fixes
This commit is contained in:
@@ -675,11 +675,12 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
|
||||
|
||||
private static void InitSignalBelts()
|
||||
{
|
||||
if (!GameMain.isRunning) return;
|
||||
if (DSPGame.IsMenuDemo) return;
|
||||
InitItemSources();
|
||||
_signalBelts = new Dictionary<int, BeltSignal>[64];
|
||||
_signalBeltsCapacity = 64;
|
||||
_portalFrom = new Dictionary<long, int>();
|
||||
_portalTo = new Dictionary<int, HashSet<long>>();
|
||||
_portalFrom = [];
|
||||
_portalTo = [];
|
||||
|
||||
var factories = GameMain.data?.factories;
|
||||
if (factories == null) return;
|
||||
@@ -735,7 +736,7 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
|
||||
if (obj != null) return obj;
|
||||
}
|
||||
|
||||
obj = new Dictionary<int, BeltSignal>();
|
||||
obj = [];
|
||||
_signalBelts[index] = obj;
|
||||
return obj;
|
||||
}
|
||||
@@ -869,7 +870,6 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
|
||||
{
|
||||
if (DSPGame.IsMenuDemo) return;
|
||||
if (BeltSignalGeneratorEnabled.Value) InitSignalBelts();
|
||||
InitItemSources();
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
@@ -1171,7 +1171,7 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
|
||||
for (var i = 0; i < len; i++)
|
||||
{
|
||||
if (ItemSources.ContainsKey(res[i])) continue;
|
||||
var rs = new ItemSource { Count = rescnt[i], From = new Dictionary<int, float>() };
|
||||
var rs = new ItemSource { Count = rescnt[i], From = [] };
|
||||
var it = recipe.Items;
|
||||
var itcnt = recipe.ItemCounts;
|
||||
var len2 = it.Length;
|
||||
@@ -1182,7 +1182,7 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
|
||||
|
||||
if (len > 1)
|
||||
{
|
||||
rs.Extra = new Dictionary<int, float>();
|
||||
rs.Extra = [];
|
||||
for (var k = 0; k < len; k++)
|
||||
{
|
||||
if (i != k)
|
||||
@@ -1258,7 +1258,38 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
|
||||
if (itemSource.From == null) return;
|
||||
foreach (var p in itemSource.From)
|
||||
{
|
||||
CalculateAllProductions(result, extra, p.Key, times * p.Value);
|
||||
var value = p.Value * times;
|
||||
if (extra.TryGetValue(p.Key, out var rcount))
|
||||
{
|
||||
if (value <= rcount)
|
||||
{
|
||||
if (value == rcount)
|
||||
{
|
||||
extra.Remove(p.Key);
|
||||
}
|
||||
else
|
||||
{
|
||||
extra[p.Key] = rcount - value;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
extra.Remove(p.Key);
|
||||
value -= rcount;
|
||||
}
|
||||
if (result.TryGetValue(p.Key, out rcount))
|
||||
{
|
||||
rcount -= value;
|
||||
if (rcount <= 0)
|
||||
{
|
||||
result.Remove(p.Key);
|
||||
}
|
||||
else
|
||||
{
|
||||
result[p.Key] = rcount;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
CalculateAllProductions(result, extra, p.Key, value);
|
||||
}
|
||||
}
|
||||
/* END: Item sources calculation */
|
||||
|
||||
@@ -48,7 +48,7 @@ public static class GamePatch
|
||||
p.Value.OnUnregEvent();
|
||||
}
|
||||
|
||||
abnormalLogic.determinators = new Dictionary<int, AbnormalityDeterminator>();
|
||||
abnormalLogic.determinators = [];
|
||||
}
|
||||
|
||||
protected override void OnDisable()
|
||||
@@ -81,7 +81,7 @@ public static class GamePatch
|
||||
{
|
||||
_savedDeterminators = __instance.determinators;
|
||||
if (!AbnormalDisablerEnabled.Value) return;
|
||||
__instance.determinators = new Dictionary<int, AbnormalityDeterminator>();
|
||||
__instance.determinators = [];
|
||||
foreach (var p in _savedDeterminators)
|
||||
{
|
||||
p.Value.OnUnregEvent();
|
||||
|
||||
@@ -342,7 +342,7 @@ public class LogisticMiner : BaseUnityPlugin
|
||||
public float FrameNext;
|
||||
|
||||
/* stores list of indices to veinData, with an extra INT which indicates cout of veinGroups at last */
|
||||
private Dictionary<int, List<int>> _veins = new();
|
||||
private Dictionary<int, List<int>> _veins = [];
|
||||
private int _mineIndex = -1;
|
||||
|
||||
public bool HasVein(int productId)
|
||||
|
||||
@@ -1747,7 +1747,7 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
|
||||
if (obj != null) return obj;
|
||||
}
|
||||
|
||||
obj = new Dictionary<int, uint>();
|
||||
obj = [];
|
||||
_signalBelts[index] = obj;
|
||||
return obj;
|
||||
}
|
||||
|
||||
@@ -1222,7 +1222,7 @@ public static class LogisticsPatch
|
||||
private float _pixelPerItem;
|
||||
|
||||
private StorageItemData[] _storageItems;
|
||||
private static readonly Dictionary<int, Sprite> ItemSprites = new();
|
||||
private static readonly Dictionary<int, Sprite> ItemSprites = [];
|
||||
private static readonly Color[] StateColor = [Color.gray, SupplyColor, DemandColor];
|
||||
|
||||
private struct StorageItemData
|
||||
|
||||
Reference in New Issue
Block a user