mirror of
https://github.com/DCFApixels/DragonECS-Graphs.git
synced 2025-09-18 03:34:35 +08:00
renaming
This commit is contained in:
parent
6dcc8ccf38
commit
cc23ba0b8a
@ -236,10 +236,10 @@ namespace DCFApixels.DragonECS
|
|||||||
#region Callbacks
|
#region Callbacks
|
||||||
public void OnReleaseDelEntityBuffer(ReadOnlySpan<int> delEntities)
|
public void OnReleaseDelEntityBuffer(ReadOnlySpan<int> delEntities)
|
||||||
{
|
{
|
||||||
EcsSubGraph subGraph;
|
SubGraphMap subGraph;
|
||||||
EcsWorld graphWorld = _graph._graphWorld;
|
EcsWorld graphWorld = _graph._graphWorld;
|
||||||
|
|
||||||
subGraph = graphWorld.JoinGraph(EcsSubGraphMode.All);
|
subGraph = graphWorld.JoinGraph(JoinMode.All);
|
||||||
foreach (var sourceE in delEntities)
|
foreach (var sourceE in delEntities)
|
||||||
{
|
{
|
||||||
var relEs = subGraph.GetRelations(sourceE);
|
var relEs = subGraph.GetRelations(sourceE);
|
||||||
|
@ -6,7 +6,7 @@ namespace DCFApixels.DragonECS
|
|||||||
public static class GraphQueriesExtensions
|
public static class GraphQueriesExtensions
|
||||||
{
|
{
|
||||||
#region JoinToGraph Empty
|
#region JoinToGraph Empty
|
||||||
public static EcsSubGraph JoinGraph(this EcsWorld entities, EcsSubGraphMode mode = EcsSubGraphMode.StartToEnd)
|
public static SubGraphMap JoinGraph(this EcsWorld entities, JoinMode mode = JoinMode.StartToEnd)
|
||||||
{
|
{
|
||||||
entities.GetQueryCache(out JoinToSubGraphExecutor executor, out EmptyAspect _);
|
entities.GetQueryCache(out JoinToSubGraphExecutor executor, out EmptyAspect _);
|
||||||
return executor.Execute(mode);
|
return executor.Execute(mode);
|
||||||
@ -14,7 +14,7 @@ namespace DCFApixels.DragonECS
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region JoinToGraph Mask
|
#region JoinToGraph Mask
|
||||||
public static EcsSubGraph JoinSubGraph<TCollection>(this TCollection entities, IComponentMask mask, EcsSubGraphMode mode = EcsSubGraphMode.StartToEnd)
|
public static SubGraphMap JoinSubGraph<TCollection>(this TCollection entities, IComponentMask mask, JoinMode mode = JoinMode.StartToEnd)
|
||||||
where TCollection : IEntityStorage
|
where TCollection : IEntityStorage
|
||||||
{
|
{
|
||||||
if (ReferenceEquals(entities, entities.World))
|
if (ReferenceEquals(entities, entities.World))
|
||||||
@ -24,11 +24,11 @@ namespace DCFApixels.DragonECS
|
|||||||
}
|
}
|
||||||
return entities.ToSpan().JoinSubGraph(mask, mode);
|
return entities.ToSpan().JoinSubGraph(mask, mode);
|
||||||
}
|
}
|
||||||
public static EcsSubGraph JoinSubGraph(this EcsReadonlyGroup group, IComponentMask mask, EcsSubGraphMode mode = EcsSubGraphMode.StartToEnd)
|
public static SubGraphMap JoinSubGraph(this EcsReadonlyGroup group, IComponentMask mask, JoinMode mode = JoinMode.StartToEnd)
|
||||||
{
|
{
|
||||||
return group.ToSpan().JoinSubGraph(mask, mode);
|
return group.ToSpan().JoinSubGraph(mask, mode);
|
||||||
}
|
}
|
||||||
public static EcsSubGraph JoinSubGraph(this EcsSpan span, IComponentMask mask, EcsSubGraphMode mode = EcsSubGraphMode.StartToEnd)
|
public static SubGraphMap JoinSubGraph(this EcsSpan span, IComponentMask mask, JoinMode mode = JoinMode.StartToEnd)
|
||||||
{
|
{
|
||||||
var executor = span.World.GetExecutorForMask<JoinToSubGraphExecutor>(mask);
|
var executor = span.World.GetExecutorForMask<JoinToSubGraphExecutor>(mask);
|
||||||
return executor.ExecuteFor(span, mode);
|
return executor.ExecuteFor(span, mode);
|
||||||
@ -36,7 +36,7 @@ namespace DCFApixels.DragonECS
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region JoinToGraph
|
#region JoinToGraph
|
||||||
public static EcsSubGraph JoinSubGraph<TCollection, TAspect>(this TCollection entities, out TAspect aspect, EcsSubGraphMode mode = EcsSubGraphMode.StartToEnd)
|
public static SubGraphMap JoinSubGraph<TCollection, TAspect>(this TCollection entities, out TAspect aspect, JoinMode mode = JoinMode.StartToEnd)
|
||||||
where TAspect : EcsAspect, new()
|
where TAspect : EcsAspect, new()
|
||||||
where TCollection : IEntityStorage
|
where TCollection : IEntityStorage
|
||||||
{
|
{
|
||||||
@ -47,12 +47,12 @@ namespace DCFApixels.DragonECS
|
|||||||
}
|
}
|
||||||
return entities.ToSpan().JoinSubGraph(out aspect, mode);
|
return entities.ToSpan().JoinSubGraph(out aspect, mode);
|
||||||
}
|
}
|
||||||
public static EcsSubGraph JoinSubGraph<TAspect>(this EcsReadonlyGroup group, out TAspect aspect, EcsSubGraphMode mode = EcsSubGraphMode.StartToEnd)
|
public static SubGraphMap JoinSubGraph<TAspect>(this EcsReadonlyGroup group, out TAspect aspect, JoinMode mode = JoinMode.StartToEnd)
|
||||||
where TAspect : EcsAspect, new()
|
where TAspect : EcsAspect, new()
|
||||||
{
|
{
|
||||||
return group.ToSpan().JoinSubGraph(out aspect, mode);
|
return group.ToSpan().JoinSubGraph(out aspect, mode);
|
||||||
}
|
}
|
||||||
public static EcsSubGraph JoinSubGraph<TAspect>(this EcsSpan span, out TAspect aspect, EcsSubGraphMode mode = EcsSubGraphMode.StartToEnd)
|
public static SubGraphMap JoinSubGraph<TAspect>(this EcsSpan span, out TAspect aspect, JoinMode mode = JoinMode.StartToEnd)
|
||||||
where TAspect : EcsAspect, new()
|
where TAspect : EcsAspect, new()
|
||||||
{
|
{
|
||||||
span.World.GetQueryCache(out JoinToSubGraphExecutor executor, out aspect);
|
span.World.GetQueryCache(out JoinToSubGraphExecutor executor, out aspect);
|
||||||
|
@ -81,7 +81,7 @@ namespace DCFApixels.DragonECS.Graphs.Internal
|
|||||||
|
|
||||||
#region Execute
|
#region Execute
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
private EcsSubGraph Execute_Internal(EcsSubGraphMode mode)
|
private SubGraphMap Execute_Internal(JoinMode mode)
|
||||||
{
|
{
|
||||||
//_executeMarker.Begin();
|
//_executeMarker.Begin();
|
||||||
|
|
||||||
@ -121,14 +121,14 @@ namespace DCFApixels.DragonECS.Graphs.Internal
|
|||||||
_linkedList.Clear();
|
_linkedList.Clear();
|
||||||
|
|
||||||
//Заполнение массивов
|
//Заполнение массивов
|
||||||
if ((mode & EcsSubGraphMode.StartToEnd) != 0)
|
if ((mode & JoinMode.StartToEnd) != 0)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < _filteredAllEntitiesCount; i++)
|
for (int i = 0; i < _filteredAllEntitiesCount; i++)
|
||||||
{
|
{
|
||||||
AddStart(_filteredAllEntities[i]);
|
AddStart(_filteredAllEntities[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((mode & EcsSubGraphMode.EndToStart) != 0)
|
if ((mode & JoinMode.EndToStart) != 0)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < _filteredAllEntitiesCount; i++)
|
for (int i = 0; i < _filteredAllEntitiesCount; i++)
|
||||||
{
|
{
|
||||||
@ -140,10 +140,10 @@ namespace DCFApixels.DragonECS.Graphs.Internal
|
|||||||
_version++;
|
_version++;
|
||||||
|
|
||||||
//_executeMarker.End();
|
//_executeMarker.End();
|
||||||
return new EcsSubGraph(this);
|
return new SubGraphMap(this);
|
||||||
}
|
}
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
private EcsSubGraph ExecuteFor_Internal(EcsSpan span, EcsSubGraphMode mode)
|
private SubGraphMap ExecuteFor_Internal(EcsSpan span, JoinMode mode)
|
||||||
{
|
{
|
||||||
//_executeMarker.Begin();
|
//_executeMarker.Begin();
|
||||||
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
|
||||||
@ -184,14 +184,14 @@ namespace DCFApixels.DragonECS.Graphs.Internal
|
|||||||
_linkedList.Clear();
|
_linkedList.Clear();
|
||||||
|
|
||||||
//Заполнение массивов
|
//Заполнение массивов
|
||||||
if ((mode & EcsSubGraphMode.StartToEnd) != 0)
|
if ((mode & JoinMode.StartToEnd) != 0)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < _filteredEntitiesCount; i++)
|
for (int i = 0; i < _filteredEntitiesCount; i++)
|
||||||
{
|
{
|
||||||
AddStart(_filteredEntities[i]);
|
AddStart(_filteredEntities[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((mode & EcsSubGraphMode.EndToStart) != 0)
|
if ((mode & JoinMode.EndToStart) != 0)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < _filteredEntitiesCount; i++)
|
for (int i = 0; i < _filteredEntitiesCount; i++)
|
||||||
{
|
{
|
||||||
@ -201,14 +201,14 @@ namespace DCFApixels.DragonECS.Graphs.Internal
|
|||||||
|
|
||||||
|
|
||||||
//_executeMarker.End();
|
//_executeMarker.End();
|
||||||
return new EcsSubGraph(this);
|
return new SubGraphMap(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public EcsSubGraph Execute(EcsSubGraphMode mode = EcsSubGraphMode.StartToEnd)
|
public SubGraphMap Execute(JoinMode mode = JoinMode.StartToEnd)
|
||||||
{
|
{
|
||||||
return Execute_Internal(mode);
|
return Execute_Internal(mode);
|
||||||
}
|
}
|
||||||
public EcsSubGraph ExecuteFor(EcsSpan span, EcsSubGraphMode mode = EcsSubGraphMode.StartToEnd)
|
public SubGraphMap ExecuteFor(EcsSpan span, JoinMode mode = JoinMode.StartToEnd)
|
||||||
{
|
{
|
||||||
return ExecuteFor_Internal(span, mode);
|
return ExecuteFor_Internal(span, mode);
|
||||||
}
|
}
|
||||||
@ -246,10 +246,10 @@ namespace DCFApixels.DragonECS.Graphs.Internal
|
|||||||
|
|
||||||
#region Internal result methods
|
#region Internal result methods
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
internal EcsSubGraphSpan GetRelations_Internal(int sourceEntityID)
|
internal SubGraphMap.Node GetRelations_Internal(int sourceEntityID)
|
||||||
{
|
{
|
||||||
LinkedListHead basket = _linkedListSourceHeads[sourceEntityID];
|
LinkedListHead basket = _linkedListSourceHeads[sourceEntityID];
|
||||||
return new EcsSubGraphSpan(_linkedList._nodes, basket.head, basket.count);
|
return new SubGraphMap.Node(_linkedList._nodes, basket.head, basket.count);
|
||||||
}
|
}
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
internal int GetRelation_Internal(int sourceEntityID)
|
internal int GetRelation_Internal(int sourceEntityID)
|
||||||
@ -305,7 +305,7 @@ namespace DCFApixels.DragonECS.Graphs.Internal
|
|||||||
|
|
||||||
namespace DCFApixels.DragonECS
|
namespace DCFApixels.DragonECS
|
||||||
{
|
{
|
||||||
public enum EcsSubGraphMode : byte
|
public enum JoinMode : byte
|
||||||
{
|
{
|
||||||
NONE = 0,
|
NONE = 0,
|
||||||
StartToEnd = 1 << 0,
|
StartToEnd = 1 << 0,
|
||||||
@ -313,15 +313,15 @@ namespace DCFApixels.DragonECS
|
|||||||
All = StartToEnd | EndToStart,
|
All = StartToEnd | EndToStart,
|
||||||
}
|
}
|
||||||
|
|
||||||
#region EcsSubGraphSpan/EcsSubGraph
|
#region SubGraphMap/SubGraphMapNode
|
||||||
public readonly ref struct EcsSubGraph
|
public readonly ref struct SubGraphMap
|
||||||
{
|
{
|
||||||
private readonly JoinToSubGraphExecutor _executer;
|
private readonly JoinToSubGraphExecutor _executer;
|
||||||
public EntityGraph Graph
|
public EntityGraph Graph
|
||||||
{
|
{
|
||||||
get { return _executer.Graph; }
|
get { return _executer.Graph; }
|
||||||
}
|
}
|
||||||
internal EcsSubGraph(JoinToSubGraphExecutor executer)
|
internal SubGraphMap(JoinToSubGraphExecutor executer)
|
||||||
{
|
{
|
||||||
_executer = executer;
|
_executer = executer;
|
||||||
}
|
}
|
||||||
@ -333,7 +333,7 @@ namespace DCFApixels.DragonECS
|
|||||||
{
|
{
|
||||||
return _executer.GetRelEntities();
|
return _executer.GetRelEntities();
|
||||||
}
|
}
|
||||||
public EcsSubGraphSpan GetRelations(int startEntityID)
|
public Node GetRelations(int startEntityID)
|
||||||
{
|
{
|
||||||
return _executer.GetRelations_Internal(startEntityID);
|
return _executer.GetRelations_Internal(startEntityID);
|
||||||
}
|
}
|
||||||
@ -345,74 +345,74 @@ namespace DCFApixels.DragonECS
|
|||||||
{
|
{
|
||||||
return _executer.GetRelationsCount_Internal(startEntityID);
|
return _executer.GetRelationsCount_Internal(startEntityID);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public readonly ref struct EcsSubGraphSpan
|
public readonly ref struct Node
|
||||||
{
|
|
||||||
public static EcsSubGraphSpan Empty
|
|
||||||
{
|
{
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
public static Node Empty
|
||||||
get { return new EcsSubGraphSpan(null, 0, 0); }
|
|
||||||
}
|
|
||||||
|
|
||||||
private readonly LinkedList.Node[] _nodes;
|
|
||||||
private readonly LinkedList.NodeIndex _startNodeIndex;
|
|
||||||
private readonly int _count;
|
|
||||||
public int Count
|
|
||||||
{
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
get { return _count; }
|
|
||||||
}
|
|
||||||
private IEnumerable<int> E
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
List<int> result = new List<int>();
|
|
||||||
foreach (var item in this)
|
|
||||||
{
|
|
||||||
result.Add(item);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
internal EcsSubGraphSpan(LinkedList.Node[] nodes, LinkedList.NodeIndex startNodeIndex, int count)
|
|
||||||
{
|
|
||||||
_nodes = nodes;
|
|
||||||
_startNodeIndex = startNodeIndex;
|
|
||||||
_count = count;
|
|
||||||
}
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
public Enumerator GetEnumerator()
|
|
||||||
{
|
|
||||||
return new Enumerator(_nodes, _startNodeIndex, _count);
|
|
||||||
}
|
|
||||||
public ref struct Enumerator
|
|
||||||
{
|
|
||||||
private readonly LinkedList.Node[] _nodes;
|
|
||||||
private int _index;
|
|
||||||
private int _count;
|
|
||||||
private int _next;
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
internal Enumerator(LinkedList.Node[] nodes, LinkedList.NodeIndex startIndex, int count)
|
|
||||||
{
|
|
||||||
_nodes = nodes;
|
|
||||||
_index = -1;
|
|
||||||
_count = count;
|
|
||||||
_next = (int)startIndex;
|
|
||||||
}
|
|
||||||
public int Current
|
|
||||||
{
|
{
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
get { return _nodes[_index].entityID; }
|
get { return new Node(null, 0, 0); }
|
||||||
|
}
|
||||||
|
|
||||||
|
private readonly LinkedList.Node[] _nodes;
|
||||||
|
private readonly LinkedList.NodeIndex _startNodeIndex;
|
||||||
|
private readonly int _count;
|
||||||
|
public int Count
|
||||||
|
{
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
get { return _count; }
|
||||||
|
}
|
||||||
|
private IEnumerable<int> E
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
List<int> result = new List<int>();
|
||||||
|
foreach (var item in this)
|
||||||
|
{
|
||||||
|
result.Add(item);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public bool MoveNext()
|
internal Node(LinkedList.Node[] nodes, LinkedList.NodeIndex startNodeIndex, int count)
|
||||||
{
|
{
|
||||||
_index = _next;
|
_nodes = nodes;
|
||||||
_next = (int)_nodes[_next].next;
|
_startNodeIndex = startNodeIndex;
|
||||||
return _index > 0 && _count-- > 0;
|
_count = count;
|
||||||
//return _count-- > 0;
|
}
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
public Enumerator GetEnumerator()
|
||||||
|
{
|
||||||
|
return new Enumerator(_nodes, _startNodeIndex, _count);
|
||||||
|
}
|
||||||
|
public ref struct Enumerator
|
||||||
|
{
|
||||||
|
private readonly LinkedList.Node[] _nodes;
|
||||||
|
private int _index;
|
||||||
|
private int _count;
|
||||||
|
private int _next;
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
internal Enumerator(LinkedList.Node[] nodes, LinkedList.NodeIndex startIndex, int count)
|
||||||
|
{
|
||||||
|
_nodes = nodes;
|
||||||
|
_index = -1;
|
||||||
|
_count = count;
|
||||||
|
_next = (int)startIndex;
|
||||||
|
}
|
||||||
|
public int Current
|
||||||
|
{
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
get { return _nodes[_index].entityID; }
|
||||||
|
}
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
public bool MoveNext()
|
||||||
|
{
|
||||||
|
_index = _next;
|
||||||
|
_next = (int)_nodes[_next].next;
|
||||||
|
return _index > 0 && _count-- > 0;
|
||||||
|
//return _count-- > 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user