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

UXAssist: some fixes

This commit is contained in:
2026-03-07 19:42:29 +08:00
parent 5e501ea649
commit ad99b49bad
3 changed files with 12 additions and 33 deletions

View File

@@ -14,33 +14,11 @@ public static class TechFunctions
I18N.Add("Batch buyout tech", "Batch buyout tech", "批量买断科技"); I18N.Add("Batch buyout tech", "Batch buyout tech", "批量买断科技");
} }
public static void GenerateTechListWithPrerequisites(GameHistoryData history, int techId, List<int> techIdList) private static void CheckTechUnlockProperties(GameHistoryData history, TechProto techProto, SortedList<int, int> properties, List<Tuple<TechProto, int, int>> techList, int maxLevel = 10000, bool withPrerequisites = true, HashSet<int> seenTechs = null)
{ {
var techProto = LDB.techs.Select(techId);
if (techProto == null || !techProto.Published) return;
var flag = true;
for (var i = 0; i < 2; i++)
{
foreach (var preTechId in (i == 1 ? techProto.PreTechsImplicit : techProto.PreTechs))
{
if (!history.techStates.ContainsKey(preTechId) || history.techStates[preTechId].unlocked) continue;
if (history.techStates[preTechId].maxLevel > history.techStates[preTechId].curLevel)
{
flag = false;
}
GenerateTechListWithPrerequisites(history, preTechId, techIdList);
}
}
if (history.techStates.ContainsKey(techId) && !history.techStates[techId].unlocked && flag)
{
techIdList.Add(techId);
}
}
private static void CheckTechUnlockProperties(GameHistoryData history, TechProto techProto, SortedList<int, int> properties, List<Tuple<TechProto, int, int>> techList, int maxLevel = 10000, bool withPrerequisites = true)
{
var techStates = history.techStates;
var techID = techProto.ID; var techID = techProto.ID;
if (seenTechs!.Contains(techID)) return;
var techStates = history.techStates;
if (techStates == null || !techStates.TryGetValue(techID, out var value)) return; if (techStates == null || !techStates.TryGetValue(techID, out var value)) return;
if (value.unlocked) return; if (value.unlocked) return;
@@ -51,18 +29,19 @@ public static class TechFunctions
{ {
var preProto = LDB.techs.Select(preid); var preProto = LDB.techs.Select(preid);
if (preProto != null) if (preProto != null)
CheckTechUnlockProperties(history, preProto, properties, techList, techProto.PreTechsMax ? 10000 : preProto.Level, true); CheckTechUnlockProperties(history, preProto, properties, techList, techProto.PreTechsMax ? 10000 : preProto.Level, true, seenTechs);
} }
foreach (var preid in techProto.PreTechsImplicit) foreach (var preid in techProto.PreTechsImplicit)
{ {
var preProto = LDB.techs.Select(preid); var preProto = LDB.techs.Select(preid);
if (preProto != null) if (preProto != null)
CheckTechUnlockProperties(history, preProto, properties, techList, techProto.PreTechsMax ? 10000 : preProto.Level, true); CheckTechUnlockProperties(history, preProto, properties, techList, techProto.PreTechsMax ? 10000 : preProto.Level, true, seenTechs);
} }
} }
if (value.curLevel < techProto.Level) value.curLevel = techProto.Level; if (value.curLevel < techProto.Level) value.curLevel = techProto.Level;
techList.Add(new Tuple<TechProto, int, int>(techProto, value.curLevel, techProto.Level)); techList.Add(new Tuple<TechProto, int, int>(techProto, value.curLevel, techProto.Level));
seenTechs!.Add(techID);
while (value.curLevel <= maxLvl) while (value.curLevel <= maxLvl)
{ {
if (techProto.PropertyOverrideItemArray != null) if (techProto.PropertyOverrideItemArray != null)
@@ -184,7 +163,7 @@ public static class TechFunctions
techProtos.Add(techProto); techProtos.Add(techProto);
} }
} }
UnlockProtoWithMetadataAndPrompt([.. techProtos], 16, false); UnlockProtoWithMetadataAndPrompt([.. techProtos], 16, true);
} }
public static void UnlockProtoWithMetadataAndPrompt(TechProto[] techProtos, int toLevel, bool withPrerequisites = true) public static void UnlockProtoWithMetadataAndPrompt(TechProto[] techProtos, int toLevel, bool withPrerequisites = true)
@@ -192,9 +171,10 @@ public static class TechFunctions
var techList = new List<Tuple<TechProto, int, int>>(); var techList = new List<Tuple<TechProto, int, int>>();
var properties = new SortedList<int, int>(); var properties = new SortedList<int, int>();
var history = GameMain.history; var history = GameMain.history;
var seenTechs = new HashSet<int>();
foreach (var techProto in techProtos) foreach (var techProto in techProtos)
{ {
CheckTechUnlockProperties(history, techProto, properties, techList, toLevel, withPrerequisites); CheckTechUnlockProperties(history, techProto, properties, techList, toLevel, withPrerequisites, seenTechs);
} }
var propertySystem = DSPGame.propertySystem; var propertySystem = DSPGame.propertySystem;
var clusterSeedKey = history.gameData.GetClusterSeedKey(); var clusterSeedKey = history.gameData.GetClusterSeedKey();

View File

@@ -2579,10 +2579,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);
if (added > 0) if (added > 0) UIItemup.Up(kvp.Key, added);
{
UIItemup.Up(kvp.Key, added);
}
} }
} }
} }

View File

@@ -134,6 +134,7 @@ public static class TechPatch
_protoPatched = false; _protoPatched = false;
} }
LDB.techs.Signature = ProtoSignature_0_10_30_3100.CalculateSignature(LDB.techs);
var techTree = UIRoot.instance?.uiGame?.techTree; var techTree = UIRoot.instance?.uiGame?.techTree;
if (techTree != null && techTree.isActiveAndEnabled) if (techTree != null && techTree.isActiveAndEnabled)
techTree.OnPageChanged(); techTree.OnPageChanged();
@@ -268,6 +269,7 @@ public static class TechPatch
_originTechPosts.Clear(); _originTechPosts.Clear();
_protoPatched = false; _protoPatched = false;
} }
LDB.techs.Signature = ProtoSignature_0_10_30_3100.CalculateSignature(LDB.techs);
var nodes = UIRoot.instance.uiGame.techTree.nodes; var nodes = UIRoot.instance.uiGame.techTree.nodes;
var history = GameMain.history; var history = GameMain.history;
foreach (var item in nodes) foreach (var item in nodes)