wip
This commit is contained in:
+19
-2
@@ -123,6 +123,7 @@ namespace AnotherReplayReader.Utils
|
||||
ImmutableArray<string> Tags,
|
||||
ImmutableArray<SpecialPowerInfo> SpecialPowers,
|
||||
ImmutableArray<string> ProducedBy,
|
||||
ImmutableArray<string> Aliases,
|
||||
string Text)
|
||||
{
|
||||
public bool IsBuilding => HasTag(KnowledgeTag.Structure);
|
||||
@@ -243,6 +244,15 @@ namespace AnotherReplayReader.Utils
|
||||
.OrderBy(e => e.Faction, StringComparer.OrdinalIgnoreCase)
|
||||
.ThenBy(e => e.AssetName, StringComparer.OrdinalIgnoreCase)
|
||||
.ToImmutableArray();
|
||||
var byAsset = new Dictionary<string, EntityKnowledge>(StringComparer.OrdinalIgnoreCase);
|
||||
foreach (var entity in allEntities)
|
||||
{
|
||||
byAsset[entity.AssetName] = entity;
|
||||
foreach (var alias in entity.Aliases)
|
||||
{
|
||||
byAsset[alias] = entity;
|
||||
}
|
||||
}
|
||||
var byFaction = builtin.ToImmutableDictionary(
|
||||
kv => kv.Key,
|
||||
kv => kv.Value.Values.OrderBy(e => e.AssetName, StringComparer.OrdinalIgnoreCase).ToImmutableArray(),
|
||||
@@ -255,7 +265,7 @@ namespace AnotherReplayReader.Utils
|
||||
}
|
||||
|
||||
return new StructuredKnowledge(
|
||||
allEntities.ToImmutableDictionary(e => e.AssetName, e => e, StringComparer.OrdinalIgnoreCase),
|
||||
byAsset.ToImmutableDictionary(StringComparer.OrdinalIgnoreCase),
|
||||
allEntities,
|
||||
byFaction,
|
||||
unknownTagsArray);
|
||||
@@ -306,6 +316,12 @@ namespace AnotherReplayReader.Utils
|
||||
unknownTagsLocal.Add(tag);
|
||||
}
|
||||
}
|
||||
var producedBy = GetStringArray(el, "producedBy");
|
||||
var alsoProducedBy = GetStringArray(el, "alsoProducedBy");
|
||||
var combinedProducedBy = producedBy
|
||||
.Concat(alsoProducedBy)
|
||||
.Distinct(StringComparer.OrdinalIgnoreCase)
|
||||
.ToImmutableArray();
|
||||
var ek = new EntityKnowledge(
|
||||
assetName,
|
||||
GetString(el, "displayName") ?? "",
|
||||
@@ -313,7 +329,8 @@ namespace AnotherReplayReader.Utils
|
||||
isBuilding ? null : GetString(el, "tier"),
|
||||
tags,
|
||||
ParseSpecialPowers(el),
|
||||
isBuilding ? ImmutableArray<string>.Empty : GetStringArray(el, "producedBy"),
|
||||
isBuilding ? ImmutableArray<string>.Empty : combinedProducedBy,
|
||||
GetStringArray(el, "aliases"),
|
||||
GetString(el, "text") ?? "");
|
||||
entries[assetName] = ek;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user