mirror of
https://github.com/DCFApixels/DragonECS.git
synced 2025-09-17 17:34:36 +08:00
fix
This commit is contained in:
parent
fa2eaf8a07
commit
a46581f895
@ -2,6 +2,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
namespace DCFApixels.DragonECS.Core
|
namespace DCFApixels.DragonECS.Core
|
||||||
@ -27,6 +28,7 @@ namespace DCFApixels.DragonECS.Core
|
|||||||
{
|
{
|
||||||
return ref _layerInfos._items[(int)layerID];
|
return ref _layerInfos._items[(int)layerID];
|
||||||
}
|
}
|
||||||
|
[DebuggerDisplay("{name}")]
|
||||||
private struct LayerInfo
|
private struct LayerInfo
|
||||||
{
|
{
|
||||||
public string name;
|
public string name;
|
||||||
@ -339,14 +341,17 @@ namespace DCFApixels.DragonECS.Core
|
|||||||
|
|
||||||
if (_basicLayerID != LayerID.NULL)
|
if (_basicLayerID != LayerID.NULL)
|
||||||
{
|
{
|
||||||
int ind = _dependencies.Count;
|
|
||||||
var basicLayerAdjacencyList = adjacency[(int)_basicLayerID];
|
var basicLayerAdjacencyList = adjacency[(int)_basicLayerID];
|
||||||
|
int inserIndex = basicLayerAdjacencyList.Count;
|
||||||
|
//for (int i = _layerInfos.Count - 1; i >= 0; i--)
|
||||||
for (int i = 0; i < _layerInfos.Count; i++)
|
for (int i = 0; i < _layerInfos.Count; i++)
|
||||||
{
|
{
|
||||||
|
var id = (LayerID)i;
|
||||||
ref var toInfo = ref _layerInfos._items[i];
|
ref var toInfo = ref _layerInfos._items[i];
|
||||||
if(toInfo.isContained && toInfo.hasAnyDependency == false)
|
if(toInfo.isContained && toInfo.hasAnyDependency == false)
|
||||||
{
|
{
|
||||||
basicLayerAdjacencyList.Add(((LayerID)i, ind++));
|
toInfo.insertionIndex = -toInfo.insertionIndex;
|
||||||
|
basicLayerAdjacencyList.Insert(inserIndex, (id, toInfo.insertionIndex));
|
||||||
toInfo.inDegree += 1;
|
toInfo.inDegree += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -362,10 +367,15 @@ namespace DCFApixels.DragonECS.Core
|
|||||||
{
|
{
|
||||||
var current = zeroInDegree[0];
|
var current = zeroInDegree[0];
|
||||||
zeroInDegree.RemoveAt(0);
|
zeroInDegree.RemoveAt(0);
|
||||||
|
|
||||||
result.Add(GetLayerInfo(current).name);
|
result.Add(GetLayerInfo(current).name);
|
||||||
|
|
||||||
foreach (var (neighbor, _) in adjacency[(int)current])
|
|
||||||
|
var adjacencyList = adjacency[(int)current];
|
||||||
|
//for (int i = adjacencyList.Count - 1; i >= 0; i--)
|
||||||
|
for (int i = 0; i < adjacencyList.Count; i++)
|
||||||
{
|
{
|
||||||
|
var (neighbor, _) = adjacencyList[i];
|
||||||
ref var neighborInfo = ref GetLayerInfo(neighbor);
|
ref var neighborInfo = ref GetLayerInfo(neighbor);
|
||||||
neighborInfo.inDegree--;
|
neighborInfo.inDegree--;
|
||||||
if (neighborInfo.inDegree == 0)
|
if (neighborInfo.inDegree == 0)
|
||||||
@ -374,6 +384,9 @@ namespace DCFApixels.DragonECS.Core
|
|||||||
int insertIndex = zeroInDegree.FindIndex(id => GetLayerInfo(id).insertionIndex < neighborInsertionIndex);
|
int insertIndex = zeroInDegree.FindIndex(id => GetLayerInfo(id).insertionIndex < neighborInsertionIndex);
|
||||||
insertIndex = insertIndex < 0 ? 0 : insertIndex;
|
insertIndex = insertIndex < 0 ? 0 : insertIndex;
|
||||||
zeroInDegree.Insert(insertIndex, neighbor);
|
zeroInDegree.Insert(insertIndex, neighbor);
|
||||||
|
|
||||||
|
//zeroInDegree.Add(neighbor);
|
||||||
|
//zeroInDegree = zeroInDegree.OrderBy(id => GetLayerInfo(id).insertionIndex).ToList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user