iterate indexable set backwards in case of destruction
parent
ad4dfd9249
commit
47758f20d1
|
@ -66,7 +66,7 @@ namespace MoonTools.ECS
|
|||
|
||||
public IEnumerator<T> GetEnumerator()
|
||||
{
|
||||
for (var i = 0; i < Count; i += 1)
|
||||
for (var i = Count - 1; i >= 0; i -= 1)
|
||||
{
|
||||
yield return array[i];
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ namespace MoonTools.ECS
|
|||
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
{
|
||||
for (var i = 0; i < Count; i += 1)
|
||||
for (var i = Count - 1; i >= 0; i -= 1)
|
||||
{
|
||||
yield return array[i];
|
||||
}
|
||||
|
|
|
@ -78,6 +78,7 @@ namespace MoonTools.ECS
|
|||
RelationDepot.Remove<TRelationKind>(new Relation(entityA, entityB));
|
||||
}
|
||||
|
||||
// FIXME: this is insanely inefficient
|
||||
protected void Destroy(in Entity entity)
|
||||
{
|
||||
ComponentDepot.OnEntityDestroy(entity.ID);
|
||||
|
|
Loading…
Reference in New Issue