fix pipeline.builder merge

This commit is contained in:
Mikhail 2024-11-05 15:50:18 +08:00
parent 8c442a66c0
commit bed850eb84

View File

@ -537,30 +537,33 @@ namespace DCFApixels.DragonECS
#endregion #endregion
#region MergeWith #region MergeWith
private static bool AreMatchingOrderIdentical(IReadOnlyList<string> listA, IReadOnlyList<string> listB) private static bool AreMatchingOrderIdentical(List<string> listA, IReadOnlyList<string> listB)
{ {
int indexA = 0; int lastIndexof = 0;
for (int i = 0; i < listB.Count; i++)
{
var a = listB[i];
int indexof = listA.IndexOf(a);
foreach (string itemB in listB) if (indexof < 0) { continue; }
if (indexof < lastIndexof)
{ {
if (indexA < listA.Count && listA[indexA] == itemB) return false;
{
indexA++;
} }
lastIndexof = indexof;
} }
return indexA == listA.Count; return true;
} }
public void MergeWith(IReadOnlyList<string> other) public void MergeWith(IReadOnlyList<string> other)
{ {
List<string> listA = _layers; List<string> listA = _layers;
IReadOnlyList<string> listB = other; IReadOnlyList<string> listB = other;
//TODO все еще не работает!!!
if (AreMatchingOrderIdentical(listA, listB) == false) if (AreMatchingOrderIdentical(listA, listB) == false)
{ {
//Для слияния списков слоев, нужно чтобы названия слоев, присутствующие в обоих списках, появлялись в одном и том же порядке в обоих списках //Для слияния списков слоев, нужно чтобы в пересечении порядок записей совпадал
Throw.Exception("To merge layer lists, the names of the layers present in both lists must appear in the same order in both lists.");
//TODO все еще не работает!!!
//Throw.Exception("To merge layer lists, the names of the layers present in both lists must appear in the same order in both lists.");
} }
HashSet<string> seen = new HashSet<string>(); HashSet<string> seen = new HashSet<string>();