diff --git a/Svelto.ECS/DataStructures/TypeSafeDictionary.cs b/Svelto.ECS/DataStructures/TypeSafeDictionary.cs
index 540d77f..2efc925 100644
--- a/Svelto.ECS/DataStructures/TypeSafeDictionary.cs
+++ b/Svelto.ECS/DataStructures/TypeSafeDictionary.cs
@@ -2,17 +2,9 @@
using System.Collections.Generic;
using Svelto.DataStructures;
using Svelto.DataStructures.Experimental;
-using Svelto.Utilities;
namespace Svelto.ECS.Internal
{
- ///
- /// This is just a place holder at the moment
- /// I always wanted to create my own Dictionary
- /// data structure as excercise, but never had the
- /// time to. At the moment I need the custom interface
- /// wrapped though.
- ///
public interface ITypeSafeDictionary
{
ITypeSafeDictionary Create();
@@ -20,12 +12,11 @@ namespace Svelto.ECS.Internal
void RemoveEntitiesFromEngines(Dictionary>
entityViewEnginesDB);
- void MoveEntityFromDictionaryAndEngines(EGID fromEntityGid, int toGroupID,
- ITypeSafeDictionary toGroup,
+ void MoveEntityFromDictionaryAndEngines(EGID fromEntityGid, int toGroupID, ITypeSafeDictionary toGroup,
Dictionary>
entityViewEnginesDB);
- void FillWithIndexedEntities(ITypeSafeDictionary entities);
+ void FillWithIndexedEntities(ITypeSafeDictionary entities);
void AddEntitiesToEngines(Dictionary> entityViewEnginesDB);
void AddCapacity(int size);
@@ -48,7 +39,7 @@ namespace Svelto.ECS.Internal
public void FillWithIndexedEntities(ITypeSafeDictionary entities)
{
int count;
- var buffer = (entities as TypeSafeDictionary).GetFasterValuesBuffer(out count);
+ var buffer = (entities as TypeSafeDictionary).GetValuesArray(out count);
try
{
@@ -63,10 +54,11 @@ namespace Svelto.ECS.Internal
}
}
- public void AddEntitiesToEngines(Dictionary> entityViewEnginesDB)
+ public void AddEntitiesToEngines(
+ Dictionary> entityViewEnginesDB)
{
int count;
- TValue[] values = GetFasterValuesBuffer(out count);
+ TValue[] values = GetValuesArray(out count);
for (int i = 0; i < count; i++)
{
@@ -83,10 +75,11 @@ namespace Svelto.ECS.Internal
public int GetFirstID()
{
- return FasterValues[0].ID.entityID;
+ return Values[0].ID.entityID;
}
- void AddEntityViewToEngines(Dictionary> entityViewEnginesDB, ref TValue entity)
+ void AddEntityViewToEngines(Dictionary> entityViewEnginesDB,
+ ref TValue entity)
{
FasterList entityViewsEngines;
//get all the engines linked to TValue
@@ -100,7 +93,7 @@ namespace Svelto.ECS.Internal
entityViewEnginesDB)
{
int count;
- var fasterValuesBuffer = GetFasterValuesBuffer(out count);
+ var fasterValuesBuffer = GetValuesArray(out count);
var valueIndex = GetValueIndex(fromEntityGid.entityID);
if (entityViewEnginesDB != null)
@@ -113,7 +106,7 @@ namespace Svelto.ECS.Internal
toGroupCasted.Add(fromEntityGid.entityID, ref fasterValuesBuffer[valueIndex]);
if (entityViewEnginesDB != null)
- AddEntityViewToEngines(entityViewEnginesDB, ref toGroupCasted.GetFasterValuesBuffer(out count)[toGroupCasted.GetValueIndex(fromEntityGid.entityID)]);
+ AddEntityViewToEngines(entityViewEnginesDB, ref toGroupCasted.GetValuesArray(out count)[toGroupCasted.GetValueIndex(fromEntityGid.entityID)]);
}
Remove(fromEntityGid.entityID);
@@ -131,7 +124,7 @@ namespace Svelto.ECS.Internal
public void RemoveEntitiesFromEngines(Dictionary> entityViewEnginesDB)
{
int count;
- TValue[] values = GetFasterValuesBuffer(out count);
+ TValue[] values = GetValuesArray(out count);
for (int i = 0; i < count; i++)
{
diff --git a/Svelto.ECS/EGIDMapper.cs b/Svelto.ECS/EGIDMapper.cs
index f9057fd..5220b51 100644
--- a/Svelto.ECS/EGIDMapper.cs
+++ b/Svelto.ECS/EGIDMapper.cs
@@ -10,7 +10,7 @@ namespace Svelto.ECS
{
int count;
index = map.FindElementIndex(id.entityID);
- return map.GetFasterValuesBuffer(out count);
+ return map.GetValuesArray(out count);
}
}
}
\ No newline at end of file
diff --git a/Svelto.ECS/EnginesRoot.DoubleBufferedEntityViews.cs b/Svelto.ECS/EnginesRoot.DoubleBufferedEntityViews.cs
index 285ec57..f4e97fe 100644
--- a/Svelto.ECS/EnginesRoot.DoubleBufferedEntityViews.cs
+++ b/Svelto.ECS/EnginesRoot.DoubleBufferedEntityViews.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
+using Svelto.DataStructures.Experimental;
using Svelto.ECS.Internal;
#if ENGINE_PROFILER_ENABLED && UNITY_EDITOR
@@ -11,7 +12,7 @@ namespace Svelto.ECS
{
public partial class EnginesRoot
{
- class DoubleBufferedEntitiesToAdd where T : Dictionary>, new()
+ class DoubleBufferedEntitiesToAdd where T : FasterDictionary>, new()
{
readonly T _entityViewsToAddBufferA = new T();
readonly T _entityViewsToAddBufferB = new T();
diff --git a/Svelto.ECS/EnginesRoot.Engines.cs b/Svelto.ECS/EnginesRoot.Engines.cs
index 36fe83d..dc0adab 100644
--- a/Svelto.ECS/EnginesRoot.Engines.cs
+++ b/Svelto.ECS/EnginesRoot.Engines.cs
@@ -36,12 +36,13 @@ namespace Svelto.ECS
///
public EnginesRoot(EntitySubmissionScheduler entityViewScheduler)
{
+ _entitiesOperations = new FasterList();
_entityEngines = new Dictionary>();
_otherEngines = new FasterList();
- _groupEntityDB = new Dictionary>();
+ _groupEntityDB = new FasterDictionary>();
_groupedGroups = new Dictionary>();
- _groupedEntityToAdd = new DoubleBufferedEntitiesToAdd>>();
+ _groupedEntityToAdd = new DoubleBufferedEntitiesToAdd>>();
_DB = new EntitiesDB(_groupEntityDB, _groupedGroups);
diff --git a/Svelto.ECS/EnginesRoot.Entities.cs b/Svelto.ECS/EnginesRoot.Entities.cs
index 381074a..6ab2db9 100644
--- a/Svelto.ECS/EnginesRoot.Entities.cs
+++ b/Svelto.ECS/EnginesRoot.Entities.cs
@@ -132,9 +132,8 @@ namespace Svelto.ECS
///--------------------------------------------
///
- void MoveEntity(EGID entityGID, int toGroupID = -1, Dictionary toGroup = null) where T:IEntityDescriptor, new ()
+ void MoveEntity(IEntityBuilder[] entityBuilders, EGID entityGID, int toGroupID = -1, Dictionary toGroup = null)
{
- var entityBuilders = EntityDescriptorTemplate.descriptor.entitiesToBuild;
var entityBuildersCount = entityBuilders.Length;
//for each entity view generated by the entity descriptor
@@ -189,33 +188,26 @@ namespace Svelto.ECS
///--------------------------------------------
- EGID SwapEntityGroup(int entityID, int fromGroupID, int toGroupID) where T:IEntityDescriptor, new ()
+ void SwapEntityGroup(IEntityBuilder[] builders, int entityID, int fromGroupID, int toGroupID)
{
- DBC.ECS.Check.Require(fromGroupID != toGroupID,
- "the entity is already in this group");
+ DBC.ECS.Check.Require(fromGroupID != toGroupID, "the entity is already in this group");
Dictionary toGroup;
if (_groupEntityDB.TryGetValue(toGroupID, out toGroup) == false)
toGroup = _groupEntityDB[toGroupID] = new Dictionary();
- MoveEntity(new EGID(entityID, fromGroupID), toGroupID, toGroup);
-
- return new EGID(entityID, toGroupID);
+ MoveEntity(builders, new EGID(entityID, fromGroupID), toGroupID, toGroup);
}
- EGID SwapFirstEntityInGroup(int fromGroupID, int toGroupId) where T:IEntityDescriptor, new()
+ void SwapFirstEntityInGroup(IEntityBuilder[] builders, int fromGroupID, int toGroupId)
{
- var firstID = _groupEntityDB[fromGroupID][EntityDescriptorTemplate.descriptor.entitiesToBuild[0]
- .GetEntityType()].GetFirstID();
-
- SwapEntityGroup(firstID, fromGroupID, toGroupId);
+ var firstID = _groupEntityDB[fromGroupID][builders[0].GetEntityType()].GetFirstID();
- return new EGID(firstID, toGroupId);
+ SwapEntityGroup(builders, firstID, fromGroupID, toGroupId);
}
readonly EntitiesDB _DB;
-
int _newEntitiesBuiltToProcess;
}
@@ -234,7 +226,7 @@ namespace Svelto.ECS
initializer.ID = _id;
int count;
- typeSafeDictionary.GetFasterValuesBuffer(out count)[typeSafeDictionary.FindElementIndex(_id.entityID)] = initializer;
+ typeSafeDictionary.GetValuesArray(out count)[typeSafeDictionary.FindElementIndex(_id.entityID)] = initializer;
}
readonly Dictionary _current;
diff --git a/Svelto.ECS/EnginesRoot.GenericEntityFunctions.cs b/Svelto.ECS/EnginesRoot.GenericEntityFunctions.cs
index f689306..3631613 100644
--- a/Svelto.ECS/EnginesRoot.GenericEntityFunctions.cs
+++ b/Svelto.ECS/EnginesRoot.GenericEntityFunctions.cs
@@ -19,58 +19,73 @@ namespace Svelto.ECS
public void RemoveEntity(int entityID, int groupID) where T : IEntityDescriptor, new()
{
- _weakReference.Target.MoveEntity(new EGID(entityID, groupID));
+ _weakReference.Target.QueueEntitySubmitOperation(new EntitySubmitOperation(EntitySubmitOperationType.Remove, entityID, groupID, -1, EntityDescriptorTemplate.descriptor.entitiesToBuild));
}
public void RemoveEntity(int entityID, ExclusiveGroup groupID) where T : IEntityDescriptor, new()
{
- _weakReference.Target.MoveEntity(new EGID(entityID, (int) groupID));
+ _weakReference.Target.QueueEntitySubmitOperation(
+ new EntitySubmitOperation(EntitySubmitOperationType.Remove, entityID, (int)groupID, -1, EntityDescriptorTemplate.descriptor.entitiesToBuild));
}
public void RemoveEntity(EGID entityEGID) where T : IEntityDescriptor, new()
{
- _weakReference.Target.MoveEntity(entityEGID);
+ _weakReference.Target.QueueEntitySubmitOperation(
+ new EntitySubmitOperation(EntitySubmitOperationType.Remove, entityEGID.entityID, entityEGID.groupID, -1, EntityDescriptorTemplate.descriptor.entitiesToBuild));
}
public void RemoveGroupAndEntities(int groupID)
{
- _weakReference.Target.RemoveGroupAndEntitiesFromDB(groupID);
+ _weakReference.Target.QueueEntitySubmitOperation(
+ new EntitySubmitOperation(EntitySubmitOperationType.RemoveGroup, -1, groupID, -1, null));
}
public void RemoveGroupAndEntities(ExclusiveGroup groupID)
{
- _weakReference.Target.RemoveGroupAndEntitiesFromDB((int) groupID);
+ _weakReference.Target.QueueEntitySubmitOperation(
+ new EntitySubmitOperation(EntitySubmitOperationType.RemoveGroup, -1, (int)groupID, -1, null));
}
- public EGID SwapEntityGroup(int entityID, int fromGroupID, int toGroupID) where T : IEntityDescriptor, new()
+ public void SwapEntityGroup(int entityID, int fromGroupID, int toGroupID) where T : IEntityDescriptor, new()
{
- return _weakReference.Target.SwapEntityGroup(entityID, fromGroupID, toGroupID);
+ _weakReference.Target.QueueEntitySubmitOperation(
+ new EntitySubmitOperation(EntitySubmitOperationType.Swap, entityID, fromGroupID, toGroupID, EntityDescriptorTemplate.descriptor.entitiesToBuild));
}
- public EGID SwapEntityGroup(int entityID, ExclusiveGroup fromGroupID, ExclusiveGroup toGroupID) where T : IEntityDescriptor, new()
+ public void SwapEntityGroup(int entityID, ExclusiveGroup fromGroupID, ExclusiveGroup toGroupID) where T : IEntityDescriptor, new()
{
- return _weakReference.Target.SwapEntityGroup(entityID, (int) fromGroupID, (int) toGroupID);
+ _weakReference.Target.QueueEntitySubmitOperation(
+ new EntitySubmitOperation(EntitySubmitOperationType.Swap, entityID, (int) fromGroupID, (int) toGroupID, EntityDescriptorTemplate.descriptor.entitiesToBuild));
}
- public EGID SwapEntityGroup(EGID id, int toGroupID) where T : IEntityDescriptor, new()
+ public void SwapEntityGroup(EGID id, int toGroupID) where T : IEntityDescriptor, new()
{
- return _weakReference.Target.SwapEntityGroup(id.entityID, id.groupID, toGroupID);
+ _weakReference.Target.QueueEntitySubmitOperation(
+ new EntitySubmitOperation(EntitySubmitOperationType.Swap, id.entityID, id.groupID, toGroupID, EntityDescriptorTemplate.descriptor.entitiesToBuild));
}
- public EGID SwapEntityGroup(EGID id, ExclusiveGroup toGroupID) where T : IEntityDescriptor, new()
+ public void SwapEntityGroup(EGID id, ExclusiveGroup toGroupID) where T : IEntityDescriptor, new()
{
- return _weakReference.Target.SwapEntityGroup(id.entityID, id.groupID, (int) toGroupID);
+ _weakReference.Target.QueueEntitySubmitOperation(
+ new EntitySubmitOperation(EntitySubmitOperationType.Swap, id.entityID, id.groupID, (int)toGroupID, EntityDescriptorTemplate.descriptor.entitiesToBuild));
}
-
- public EGID SwapFirstEntityGroup(int fromGroupID, int toGroupID) where T : IEntityDescriptor, new()
+
+ public void SwapFirstEntityGroup(int fromGroupID, int toGroupID) where T : IEntityDescriptor, new()
{
- return _weakReference.Target.SwapFirstEntityInGroup( fromGroupID, toGroupID);
+ _weakReference.Target.QueueEntitySubmitOperation(
+ new EntitySubmitOperation(EntitySubmitOperationType.FirstSwap, -1, fromGroupID, toGroupID, EntityDescriptorTemplate.descriptor.entitiesToBuild));
}
- public EGID SwapFirstEntityGroup(ExclusiveGroup fromGroupID, ExclusiveGroup toGroupID) where T : IEntityDescriptor, new()
+ public void SwapFirstEntityGroup(ExclusiveGroup fromGroupID, ExclusiveGroup toGroupID) where T : IEntityDescriptor, new()
{
- return _weakReference.Target.SwapFirstEntityInGroup( (int) fromGroupID, (int) toGroupID);
+ _weakReference.Target.QueueEntitySubmitOperation(
+ new EntitySubmitOperation(EntitySubmitOperationType.FirstSwap, -1, (int)fromGroupID, (int)toGroupID, EntityDescriptorTemplate.descriptor.entitiesToBuild));
}
}
+
+ void QueueEntitySubmitOperation(EntitySubmitOperation entitySubmitOperation)
+ {
+ _entitiesOperations.AddRef(ref entitySubmitOperation);
+ }
}
}
\ No newline at end of file
diff --git a/Svelto.ECS/EnginesRoot.Submission.cs b/Svelto.ECS/EnginesRoot.Submission.cs
index 7d103f2..f91a5a8 100644
--- a/Svelto.ECS/EnginesRoot.Submission.cs
+++ b/Svelto.ECS/EnginesRoot.Submission.cs
@@ -1,6 +1,8 @@
using System;
-using System.Collections.Generic;
-using Svelto.DataStructures.Experimental;
+ using System.Collections;
+ using System.Collections.Generic;
+ using Svelto.DataStructures;
+ using Svelto.DataStructures.Experimental;
using Svelto.ECS.Internal;
using Svelto.ECS.Schedulers;
@@ -14,6 +16,28 @@ namespace Svelto.ECS
{
void SubmitEntityViews()
{
+ var entitiesOperations = _entitiesOperations.ToArrayFast();
+ for (int i = 0; i < _entitiesOperations.Count; i++)
+ {
+ switch (entitiesOperations[i].type)
+ {
+ case EntitySubmitOperationType.Swap:
+ SwapEntityGroup(entitiesOperations[i].builders, entitiesOperations[i].id, entitiesOperations[i].fromGroupID, entitiesOperations[i].toGroupID);
+ break;
+ case EntitySubmitOperationType.Remove:
+ MoveEntity(entitiesOperations[i].builders, new EGID(entitiesOperations[i].id, entitiesOperations[i].fromGroupID));
+ break;
+ case EntitySubmitOperationType.FirstSwap:
+ SwapFirstEntityInGroup(entitiesOperations[i].builders, entitiesOperations[i].fromGroupID, entitiesOperations[i].toGroupID);
+ break;
+ case EntitySubmitOperationType.RemoveGroup:
+ RemoveGroupAndEntitiesFromDB(entitiesOperations[i].fromGroupID);
+ break;
+ }
+ }
+
+ _entitiesOperations.FastClear();
+
int numberOfReenteringLoops = 0;
//are there new entities built to process?
@@ -44,7 +68,7 @@ namespace Svelto.ECS
}
//todo: groupsToSubmit can be simplified as data structure?
- void AddEntityViewsToTheDBAndSuitableEngines(Dictionary> groupsOfEntitiesToSubmit)
+ void AddEntityViewsToTheDBAndSuitableEngines(FasterDictionary> groupsOfEntitiesToSubmit)
{
//each group is indexed by entity view type. for each type there is a dictionary indexed by entityID
foreach (var groupOfEntitiesToSubmit in groupsOfEntitiesToSubmit)
@@ -90,9 +114,10 @@ namespace Svelto.ECS
//to the FasterDictionary capabilities OR it's possible to get a specific entityView indexed by
//ID. This ID doesn't need to be the EGID, it can be just the entityID
- readonly Dictionary> _groupEntityDB;
+ readonly FasterDictionary> _groupEntityDB;
readonly Dictionary> _groupedGroups; //yes I am being sarcastic
- readonly DoubleBufferedEntitiesToAdd>> _groupedEntityToAdd;
+ readonly DoubleBufferedEntitiesToAdd>> _groupedEntityToAdd;
readonly EntitySubmissionScheduler _scheduler;
+ readonly FasterList _entitiesOperations;
}
}
\ No newline at end of file
diff --git a/Svelto.ECS/EntitiesDB.cs b/Svelto.ECS/EntitiesDB.cs
index 42431a5..0cc5657 100644
--- a/Svelto.ECS/EntitiesDB.cs
+++ b/Svelto.ECS/EntitiesDB.cs
@@ -7,7 +7,7 @@ namespace Svelto.ECS.Internal
{
partial class EntitiesDB : IEntitiesDB
{
- internal EntitiesDB(Dictionary> groupEntityViewsDB,
+ internal EntitiesDB(FasterDictionary> groupEntityViewsDB,
Dictionary> groupedGroups)
{
_groupEntityViewsDB = groupEntityViewsDB;
@@ -19,7 +19,7 @@ namespace Svelto.ECS.Internal
TypeSafeDictionary typeSafeDictionary;
if (QueryEntitySafeDictionary(@group, out typeSafeDictionary) == false) return RetrieveEmptyEntityViewList();
- return typeSafeDictionary.FasterValues;
+ return typeSafeDictionary.Values;
}
public T[] QueryEntities(int @group, out int count) where T : IEntityStruct
@@ -28,7 +28,7 @@ namespace Svelto.ECS.Internal
count = 0;
if (QueryEntitySafeDictionary(@group, out typeSafeDictionary) == false) return RetrieveEmptyEntityViewArray();
- return typeSafeDictionary.GetFasterValuesBuffer(out count);
+ return typeSafeDictionary.GetValuesArray(out count);
}
public T[] QueryEntities(ExclusiveGroup @group, out int targetsCount) where T : IEntityStruct
@@ -47,7 +47,7 @@ namespace Svelto.ECS.Internal
mapper.map = typeSafeDictionary;
int count;
- typeSafeDictionary.GetFasterValuesBuffer(out count);
+ typeSafeDictionary.GetValuesArray(out count);
return mapper;
}
@@ -121,14 +121,15 @@ namespace Svelto.ECS.Internal
T[] QueryEntitiesAndIndexInternal(EGID entityGID, out uint index) where T : IEntityStruct
{
TypeSafeDictionary safeDictionary;
+ index = 0;
if (QueryEntitySafeDictionary(entityGID.groupID, out safeDictionary) == false)
- throw new EntitiesDBException("Entity not found, type: ".FastConcat(typeof(T)).FastConcat(" groupID: ").FastConcat(entityGID.entityID));
+ return null;
if (safeDictionary.TryFindElementIndex(entityGID.entityID, out index) == false)
- throw new EntitiesDBException("Entity not found, type: ".FastConcat(typeof(T)).FastConcat(" groupID: ").FastConcat(entityGID.entityID));
+ return null;
int count;
- return safeDictionary.GetFasterValuesBuffer(out count);
+ return safeDictionary.GetValuesArray(out count);
}
bool QueryEntitySafeDictionary(int @group, out TypeSafeDictionary typeSafeDictionary) where T : IEntityStruct
@@ -170,7 +171,11 @@ namespace Svelto.ECS.Internal
}
//grouped set of entity views, this is the standard way to handle entity views
- readonly Dictionary> _groupEntityViewsDB;
+ //entity views are grouped per group, then indexable per type, then indexable per EGID.
+ //however the TypeSafeDictionary can return an array of values directly, that can be
+ //iterated over, so that is possible to iterate over all the entity views of
+ //a specific type inside a specific group.
+ readonly FasterDictionary> _groupEntityViewsDB;
//needed to be able to iterate over all the entities of the same type regardless the group
//may change in future
readonly Dictionary> _groupedGroups;
diff --git a/Svelto.ECS/EntityFactory.cs b/Svelto.ECS/EntityFactory.cs
index 89eed13..838e9d3 100644
--- a/Svelto.ECS/EntityFactory.cs
+++ b/Svelto.ECS/EntityFactory.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using Svelto.DataStructures.Experimental;
namespace Svelto.ECS.Internal
{
@@ -7,7 +8,7 @@ namespace Svelto.ECS.Internal
{
internal static Dictionary
BuildGroupedEntityViews(EGID egid,
- Dictionary> groupEntityViewsByType,
+ FasterDictionary> groupEntityViewsByType,
IEntityBuilder[] entityToBuild,
object[] implementors)
{
@@ -19,7 +20,7 @@ namespace Svelto.ECS.Internal
}
static Dictionary FetchEntityViewGroup(int groupID,
- Dictionary> groupEntityViewsByType)
+ FasterDictionary> groupEntityViewsByType)
{
Dictionary group;
@@ -53,13 +54,11 @@ namespace Svelto.ECS.Internal
{
ITypeSafeDictionary safeDictionary;
- var entityViewsPoolWillBeCreated =
- @group.TryGetValue(entityViewType, out safeDictionary) == false;
+ var entityViewsPoolWillBeCreated = @group.TryGetValue(entityViewType, out safeDictionary) == false;
//passing the undefined entityViewsByType inside the entityViewBuilder will allow
//it to be created with the correct type and casted back to the undefined list.
//that's how the list will be eventually of the target type.
-
entityBuilder.BuildEntityViewAndAddToList(ref safeDictionary, entityID, implementors);
if (entityViewsPoolWillBeCreated)
diff --git a/Svelto.ECS/EntitySubmitOperation.cs b/Svelto.ECS/EntitySubmitOperation.cs
index 0f0e220..2ba472b 100644
--- a/Svelto.ECS/EntitySubmitOperation.cs
+++ b/Svelto.ECS/EntitySubmitOperation.cs
@@ -2,5 +2,27 @@
{
struct EntitySubmitOperation
{
+ public readonly EntitySubmitOperationType type;
+ public readonly IEntityBuilder[] builders;
+ public readonly int id;
+ public readonly int toGroupID;
+ public readonly int fromGroupID;
+
+ public EntitySubmitOperation(EntitySubmitOperationType operation, int entityId, int fromGroupId, int toGroupId, IEntityBuilder[] builders)
+ {
+ type = operation;
+ this.builders = builders;
+ id = entityId;
+ toGroupID = toGroupId;
+ fromGroupID = fromGroupId;
+ }
+ }
+
+ enum EntitySubmitOperationType
+ {
+ Swap,
+ Remove,
+ FirstSwap,
+ RemoveGroup
}
}
\ No newline at end of file
diff --git a/Svelto.ECS/ExecuteOnEntitiesDB.cs b/Svelto.ECS/ExecuteOnEntitiesDB.cs
index aa37e15..7cad7ae 100644
--- a/Svelto.ECS/ExecuteOnEntitiesDB.cs
+++ b/Svelto.ECS/ExecuteOnEntitiesDB.cs
@@ -63,7 +63,7 @@ namespace Svelto.ECS.Internal
TypeSafeDictionary typeSafeDictionary;
if (QueryEntitySafeDictionary(@groupID, out typeSafeDictionary) == false) return;
- var entities = typeSafeDictionary.GetFasterValuesBuffer(out count);
+ var entities = typeSafeDictionary.GetValuesArray(out count);
for (var i = 0; i < count; i++)
action(ref entities[i], this, i);
@@ -82,7 +82,7 @@ namespace Svelto.ECS.Internal
TypeSafeDictionary typeSafeDictionary;
if (QueryEntitySafeDictionary(@groupID, out typeSafeDictionary) == false) return;
- var entities = typeSafeDictionary.GetFasterValuesBuffer(out count);
+ var entities = typeSafeDictionary.GetValuesArray(out count);
for (var i = 0; i < count; i++)
action(ref entities[i], ref value, this, i);
@@ -105,7 +105,7 @@ namespace Svelto.ECS.Internal
if (_groupedGroups.TryGetValue(type, out dic))
{
int count;
- var typeSafeDictionaries = dic.GetFasterValuesBuffer(out count);
+ var typeSafeDictionaries = dic.GetValuesArray(out count);
for (int j = 0; j < count; j++)
{
@@ -113,7 +113,7 @@ namespace Svelto.ECS.Internal
var typeSafeDictionary = typeSafeDictionaries[j];
var casted = typeSafeDictionary as TypeSafeDictionary;
- var entities = casted.GetFasterValuesBuffer(out innerCount);
+ var entities = casted.GetValuesArray(out innerCount);
for (int i = 0; i < innerCount; i++)
action(ref entities[i], this);
@@ -131,7 +131,7 @@ namespace Svelto.ECS.Internal
if (_groupedGroups.TryGetValue(type, out dic))
{
int count;
- var typeSafeDictionaries = dic.GetFasterValuesBuffer(out count);
+ var typeSafeDictionaries = dic.GetValuesArray(out count);
for (int j = 0; j < count; j++)
{
@@ -139,7 +139,7 @@ namespace Svelto.ECS.Internal
var typeSafeDictionary = typeSafeDictionaries[j];
var casted = typeSafeDictionary as TypeSafeDictionary;
- var entities = casted.GetFasterValuesBuffer(out innerCount);
+ var entities = casted.GetValuesArray(out innerCount);
for (int i = 0; i < innerCount; i++)
action(ref entities[i], ref value, this);
diff --git a/Svelto.ECS/IEntityFunctions.cs b/Svelto.ECS/IEntityFunctions.cs
index 434fbc2..9de15e6 100644
--- a/Svelto.ECS/IEntityFunctions.cs
+++ b/Svelto.ECS/IEntityFunctions.cs
@@ -14,11 +14,11 @@ namespace Svelto.ECS
void RemoveGroupAndEntities(int groupID);
void RemoveGroupAndEntities(ExclusiveGroup groupID);
- EGID SwapEntityGroup(int entityID, int fromGroupID, int toGroupID) where T : IEntityDescriptor, new();
- EGID SwapEntityGroup(int entityID, ExclusiveGroup fromGroupID, ExclusiveGroup toGroupID) where T : IEntityDescriptor, new();
- EGID SwapEntityGroup(EGID id, int toGroupID) where T : IEntityDescriptor, new();
- EGID SwapEntityGroup(EGID id, ExclusiveGroup toGroupID) where T : IEntityDescriptor, new();
- EGID SwapFirstEntityGroup(int fromGroupID, int toGroupID) where T : IEntityDescriptor, new();
- EGID SwapFirstEntityGroup(ExclusiveGroup fromGroupID, ExclusiveGroup toGroupID) where T : IEntityDescriptor, new();
+ void SwapEntityGroup(int entityID, int fromGroupID, int toGroupID) where T : IEntityDescriptor, new();
+ void SwapEntityGroup(int entityID, ExclusiveGroup fromGroupID, ExclusiveGroup toGroupID) where T : IEntityDescriptor, new();
+ void SwapEntityGroup(EGID id, int toGroupID) where T : IEntityDescriptor, new();
+ void SwapEntityGroup(EGID id, ExclusiveGroup toGroupID) where T : IEntityDescriptor, new();
+ void SwapFirstEntityGroup(int fromGroupID, int toGroupID) where T : IEntityDescriptor, new();
+ void SwapFirstEntityGroup(ExclusiveGroup fromGroupID, ExclusiveGroup toGroupID) where T : IEntityDescriptor, new();
}
}
\ No newline at end of file