mirror of
https://github.com/DCFApixels/DragonECS.git
synced 2025-09-19 02:24:37 +08:00
stash
This commit is contained in:
parent
19a74409ec
commit
7a7c93fe82
@ -32,9 +32,10 @@ namespace DCFApixels.DragonECS.Core
|
|||||||
private struct LayerInfo
|
private struct LayerInfo
|
||||||
{
|
{
|
||||||
public string name;
|
public string name;
|
||||||
|
public int insertionIndex;
|
||||||
public bool isLocked;
|
public bool isLocked;
|
||||||
public bool isContained;
|
public bool isContained;
|
||||||
public int insertionIndex;
|
public bool isBefore;
|
||||||
//build
|
//build
|
||||||
public int inDegree;
|
public int inDegree;
|
||||||
public bool hasAnyDependency;
|
public bool hasAnyDependency;
|
||||||
@ -51,6 +52,14 @@ namespace DCFApixels.DragonECS.Core
|
|||||||
private int _increment = 0;
|
private int _increment = 0;
|
||||||
private int _count;
|
private int _count;
|
||||||
|
|
||||||
|
public IEnumerable<(string from, string to)> Deps
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _dependencies.Select(o => (GetLayerInfo(o.From).name, GetLayerInfo(o.To).name));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#region Properties
|
#region Properties
|
||||||
public int Count
|
public int Count
|
||||||
{
|
{
|
||||||
@ -82,17 +91,17 @@ namespace DCFApixels.DragonECS.Core
|
|||||||
GetLayerID("");
|
GetLayerID("");
|
||||||
_source = source;
|
_source = source;
|
||||||
|
|
||||||
Add(preBeginlayer)
|
Add(preBeginlayer);
|
||||||
.Before(beginlayer);
|
//.Before(beginlayer);
|
||||||
Add(beginlayer)
|
Add(beginlayer)
|
||||||
.After(preBeginlayer)
|
//.Before(basicLayer)
|
||||||
.Before(basicLayer);
|
.After(preBeginlayer);
|
||||||
Add(basicLayer)
|
Add(basicLayer)
|
||||||
.After(beginlayer)
|
//.Before(endLayer)
|
||||||
.Before(endLayer);
|
.After(beginlayer);
|
||||||
Add(endLayer)
|
Add(endLayer)
|
||||||
.After(basicLayer)
|
//.Before(postEndLayer)
|
||||||
.Before(postEndLayer);
|
.After(basicLayer);
|
||||||
Add(postEndLayer)
|
Add(postEndLayer)
|
||||||
.After(endLayer);
|
.After(endLayer);
|
||||||
|
|
||||||
@ -136,17 +145,22 @@ namespace DCFApixels.DragonECS.Core
|
|||||||
private void AddDependency_Internal(LayerID from, LayerID to, bool isBefore = false)
|
private void AddDependency_Internal(LayerID from, LayerID to, bool isBefore = false)
|
||||||
{
|
{
|
||||||
GetLayerInfo(from).hasAnyDependency = true;
|
GetLayerInfo(from).hasAnyDependency = true;
|
||||||
|
|
||||||
GetLayerInfo(to).hasAnyDependency = true;
|
GetLayerInfo(to).hasAnyDependency = true;
|
||||||
|
|
||||||
if (isBefore)
|
if (isBefore)
|
||||||
{
|
{
|
||||||
GetLayerInfo(from).insertionIndex = int.MaxValue - (_increment++);
|
//GetLayerInfo(from).insertionIndex = 1000 - (_increment++);
|
||||||
|
GetLayerInfo(from).isBefore = true;
|
||||||
|
//_dependencies.Insert(0, (from, to));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
//GetLayerInfo(from).insertionIndex = _increment++;
|
||||||
|
GetLayerInfo(from).isBefore = false;
|
||||||
|
//_dependencies.Add((from, to));
|
||||||
}
|
}
|
||||||
_dependencies.Add((from, to));
|
|
||||||
//_dependencies.Insert(0, (from, to));
|
//_dependencies.Insert(0, (from, to));
|
||||||
|
_dependencies.Add((from, to));
|
||||||
}
|
}
|
||||||
private void AddDependency_Internal(LayerID from, string to, bool isBefore = false)
|
private void AddDependency_Internal(LayerID from, string to, bool isBefore = false)
|
||||||
{
|
{
|
||||||
@ -353,23 +367,24 @@ namespace DCFApixels.DragonECS.Core
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_basicLayerID != LayerID.NULL)
|
//// добавление зависимостей для нод без зависимостей.
|
||||||
{
|
//if (_basicLayerID != LayerID.NULL)
|
||||||
var basicLayerAdjacencyList = adjacency[(int)_basicLayerID];
|
//{
|
||||||
int inserIndex = basicLayerAdjacencyList.Count;
|
// var basicLayerAdjacencyList = adjacency[(int)_basicLayerID];
|
||||||
//for (int i = _layerInfos.Count - 1; i >= 0; i--)
|
// int inserIndex = basicLayerAdjacencyList.Count;
|
||||||
for (int i = 0; i < _layerInfos.Count; i++)
|
// //for (int i = _layerInfos.Count - 1; i >= 0; i--)
|
||||||
{
|
// for (int i = 0; i < _layerInfos.Count; i++)
|
||||||
var id = (LayerID)i;
|
// {
|
||||||
ref var toInfo = ref _layerInfos._items[i];
|
// var id = (LayerID)i;
|
||||||
if(toInfo.isContained && toInfo.hasAnyDependency == false)
|
// ref var toInfo = ref _layerInfos._items[i];
|
||||||
{
|
// if(toInfo.isContained && toInfo.hasAnyDependency == false)
|
||||||
//toInfo.insertionIndex = -toInfo.insertionIndex;
|
// {
|
||||||
basicLayerAdjacencyList.Insert(inserIndex, (id, toInfo.insertionIndex));
|
// //toInfo.insertionIndex = -toInfo.insertionIndex;
|
||||||
toInfo.inDegree += 1;
|
// basicLayerAdjacencyList.Insert(inserIndex, (id, toInfo.insertionIndex));
|
||||||
}
|
// toInfo.inDegree += 1;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
List<LayerID> zeroInDegree = new List<LayerID>(nodes.Length);
|
List<LayerID> zeroInDegree = new List<LayerID>(nodes.Length);
|
||||||
zeroInDegree.AddRange(nodes.Where(id => GetLayerInfo(id).inDegree == 0).OrderBy(id => GetLayerInfo(id).insertionIndex));
|
zeroInDegree.AddRange(nodes.Where(id => GetLayerInfo(id).inDegree == 0).OrderBy(id => GetLayerInfo(id).insertionIndex));
|
||||||
@ -402,6 +417,27 @@ namespace DCFApixels.DragonECS.Core
|
|||||||
//zeroInDegree = zeroInDegree.OrderBy(id => GetLayerInfo(id).insertionIndex).ToList();
|
//zeroInDegree = zeroInDegree.OrderBy(id => GetLayerInfo(id).insertionIndex).ToList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//var adjacencyList = adjacency[(int)current];
|
||||||
|
////var adjacencyListSort = adjacencyList.OrderBy(o => GetLayerInfo(o.To).insertionIndex);
|
||||||
|
//var adjacencyListSort = adjacencyList;
|
||||||
|
//foreach (var item in adjacencyListSort)
|
||||||
|
//{
|
||||||
|
// var (neighbor, _) = item;
|
||||||
|
// ref var neighborInfo = ref GetLayerInfo(neighbor);
|
||||||
|
// neighborInfo.inDegree--;
|
||||||
|
// if (neighborInfo.inDegree == 0)
|
||||||
|
// {
|
||||||
|
// //var neighborInsertionIndex = neighborInfo.insertionIndex;
|
||||||
|
// //int insertIndex = zeroInDegree.FindIndex(id => GetLayerInfo(id).insertionIndex > neighborInsertionIndex);
|
||||||
|
// //insertIndex = insertIndex < 0 ? 0 : insertIndex;
|
||||||
|
// //
|
||||||
|
// //zeroInDegree.Insert(insertIndex, neighbor);
|
||||||
|
//
|
||||||
|
// zeroInDegree.Add(neighbor);
|
||||||
|
// zeroInDegree = zeroInDegree.OrderBy(id => GetLayerInfo(id).insertionIndex).ToList();
|
||||||
|
// }
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result.Count != nodes.Length)
|
if (result.Count != nodes.Length)
|
||||||
|
Loading…
Reference in New Issue
Block a user