This commit is contained in:
DCFApixels 2024-11-17 21:44:02 +08:00
parent 2154afbe6d
commit d292b1a2b9
3 changed files with 13 additions and 82 deletions

View File

@ -280,7 +280,6 @@ namespace DCFApixels.DragonECS
EcsSubGraph subGraph; EcsSubGraph subGraph;
EcsWorld graphWorld = _graph._graphWorld; EcsWorld graphWorld = _graph._graphWorld;
//subGraph = graphWorld.JoinToSubGraph(EcsSubGraphMode.StartToEnd);
subGraph = graphWorld.JoinToSubGraph(EcsSubGraphMode.All); subGraph = graphWorld.JoinToSubGraph(EcsSubGraphMode.All);
foreach (var sourceE in delEntities) foreach (var sourceE in delEntities)
{ {
@ -292,17 +291,6 @@ namespace DCFApixels.DragonECS
} }
} }
//subGraph = graphWorld.JoinToSubGraph(EcsSubGraphMode.EndToStart);
//foreach (var sourceE in delEntities)
//{
// var relEs = subGraph.GetRelations(sourceE);
// foreach (var relE in relEs)
// {
// //int missingE = graphWorld.NewEntity();
// _graph.DelRelation(relE);
// }
//}
graphWorld.ReleaseDelEntityBufferAll(); graphWorld.ReleaseDelEntityBufferAll();
} }
public void OnWorldDestroy() { } public void OnWorldDestroy() { }

View File

@ -5,11 +5,23 @@ namespace DCFApixels.DragonECS
public static class GraphQueries public static class GraphQueries
{ {
#region JoinToGraph Empty #region JoinToGraph Empty
public static EcsSubGraph JoinToSubGraph(this EcsWorld entities, EcsSubGraphMode mode = EcsSubGraphMode.StartToEnd)
{
entities.GetQueryCache(out JoinToSubGraphExecutor executor, out EmptyAspect _);
return executor.Execute(mode);
}
//public static EcsSubGraph JoinToSubGraph<TCollection>(this TCollection entities, EcsSubGraphMode mode = EcsSubGraphMode.StartToEnd) //public static EcsSubGraph JoinToSubGraph<TCollection>(this TCollection entities, EcsSubGraphMode mode = EcsSubGraphMode.StartToEnd)
// where TCollection : IEntityStorage // where TCollection : IEntityStorage
//{ //{
// return entities.ToSpan().JoinToSubGraph(mode); // if (ReferenceEquals(entities, entities.World))
// {
// entities.World.GetQueryCache(out JoinToSubGraphExecutor executor, out EmptyAspect _);
// return executor.Execute(mode);
// } // }
// return entities.ToSpan().JoinToSubGraph(out EmptyAspect _, mode);
//}
//public static EcsSubGraph JoinToSubGraph(this EcsReadonlyGroup group, EcsSubGraphMode mode = EcsSubGraphMode.StartToEnd) //public static EcsSubGraph JoinToSubGraph(this EcsReadonlyGroup group, EcsSubGraphMode mode = EcsSubGraphMode.StartToEnd)
//{ //{
// return group.ToSpan().JoinToSubGraph(mode); // return group.ToSpan().JoinToSubGraph(mode);
@ -27,17 +39,6 @@ namespace DCFApixels.DragonECS
#endregion #endregion
#region JoinToGraph #region JoinToGraph
public static EcsSubGraph JoinToSubGraph<TCollection>(this TCollection entities, EcsSubGraphMode mode = EcsSubGraphMode.StartToEnd)
where TCollection : IEntityStorage
{
if (ReferenceEquals(entities, entities.World))
{
entities.World.GetQueryCache(out JoinToSubGraphExecutor executor, out EmptyAspect _);
return executor.Execute(mode);
}
return entities.ToSpan().JoinToSubGraph(out EmptyAspect _, mode);
}
public static EcsSubGraph JoinToSubGraph<TCollection, TAspect>(this TCollection entities, out TAspect aspect, EcsSubGraphMode mode = EcsSubGraphMode.StartToEnd) public static EcsSubGraph JoinToSubGraph<TCollection, TAspect>(this TCollection entities, out TAspect aspect, EcsSubGraphMode mode = EcsSubGraphMode.StartToEnd)
where TAspect : EcsAspect, new() where TAspect : EcsAspect, new()
where TCollection : IEntityStorage where TCollection : IEntityStorage

View File

@ -70,64 +70,6 @@ namespace DCFApixels.DragonECS.Graphs.Internal
} }
#endregion #endregion
#region TMP
//[MethodImpl(MethodImplOptions.AggressiveInlining)]
//public void Resize(int newCapacity)
//{
// Array.Resize(ref _nodes, newCapacity * 2 + 10);
//}
//[MethodImpl(MethodImplOptions.AggressiveInlining)]
//public void Set(HeadIndex nodeIndex, int entityID)
//{
// _nodes[(int)nodeIndex].entityID = entityID;
//}
///// <returns> new node index</returns>
//[MethodImpl(MethodImplOptions.AggressiveInlining)]
//public NodeID InsertBefore(NodeID nodeIndex, int entityID)
//{
// NodeID newNode = (NodeID)(++_count);
// _nodes[(int)newNode] = _nodes[(int)nodeIndex];
// _nodes[(int)newNode].Set(entityID, nodeIndex);
// return newNode;
//}
///// <returns> new node index</returns>
//[MethodImpl(MethodImplOptions.AggressiveInlining)]
//public NodeID InsertAfter(NodeID nodeIndex, int entityID)
//{
// NodeID newNode = (NodeID)(++_count);
// _nodes[(int)nodeIndex].next = newNode;
// _nodes[(int)newNode].Set(entityID, _nodes[(int)nodeIndex].next);
// _lastNodeIndex = newNode;
// return newNode;
//
// //_nodes[++_count].Set(entityID, _nodes[(int)nodeIndex].next);
// //_nodes[(int)nodeIndex].next = (NodeID)_count;
// //_lastNodeIndex = (NodeID)((int)nodeIndex + 1);
// //return (NodeID)_count;
//}
/// <returns> new node index</returns>
//[MethodImpl(MethodImplOptions.AggressiveInlining)]
//public NodeID Add(int entityID)
//{
// var result = InsertAfter(_lastNodeIndex, entityID);
// _lastNodeIndex = (NodeID)_count;
// return result;
//}
//[MethodImpl(MethodImplOptions.AggressiveInlining)]
//public EcsJoinedSpan GetSpan(int startNodeIndex, int count)
//{
// return new EcsJoinedSpan(_nodes, startNodeIndex, count);
//}
//[MethodImpl(MethodImplOptions.AggressiveInlining)]
//public EcsJoinedSpan GetEmptySpan()
//{
// return new EcsJoinedSpan(_nodes, 0, 0);
//}
#endregion
#region Utils #region Utils
public enum NodeIndex : int { } public enum NodeIndex : int { }