Browse Source

EGID are now long to avoid any limitation

tags/Rel2
sebas77 6 years ago
parent
commit
fe0a777475
6 changed files with 20 additions and 31 deletions
  1. +4
    -4
      Svelto.ECS/DataStructures/TypeSafeDictionary.cs
  2. +3
    -3
      Svelto.ECS/DataStructures/TypeSafeFasterListForECS.cs
  3. +6
    -11
      Svelto.ECS/EGID.cs
  4. +1
    -1
      Svelto.ECS/EnginesRootEngines.cs
  5. +3
    -3
      Svelto.ECS/EnginesRootEntities.cs
  6. +3
    -9
      Svelto.ECS/EntityFactory.cs

+ 4
- 4
Svelto.ECS/DataStructures/TypeSafeDictionary.cs View File

@@ -15,13 +15,13 @@ namespace Svelto.ECS.Internal
{
void FillWithIndexedEntityViews(ITypeSafeList entityViews);
bool Remove(EGID entityId);
IEntityView GetIndexedEntityView(EGID entityID);
IEntityView GetIndexedEntityView(EGID entityID);
}

class TypeSafeDictionaryForClass<TValue> : Dictionary<int, TValue>, ITypeSafeDictionary where TValue : EntityView
class TypeSafeDictionaryForClass<TValue> : Dictionary<long, TValue>, ITypeSafeDictionary where TValue : EntityView
{
internal static readonly ReadOnlyDictionary<int, TValue> Default =
new ReadOnlyDictionary<int, TValue>(new Dictionary<int, TValue>());
internal static readonly ReadOnlyDictionary<long, TValue> Default =
new ReadOnlyDictionary<long, TValue>(new Dictionary<long, TValue>());

public void FillWithIndexedEntityViews(ITypeSafeList entityViews)
{


+ 3
- 3
Svelto.ECS/DataStructures/TypeSafeFasterListForECS.cs View File

@@ -20,16 +20,16 @@ namespace Svelto.ECS.Internal

class TypeSafeFasterListForECS<T> : FasterList<T> where T : IEntityView
{
readonly Dictionary<int, int> _mappedIndices;
readonly Dictionary<long, int> _mappedIndices;

protected TypeSafeFasterListForECS()
{
_mappedIndices = new Dictionary<int, int>();
_mappedIndices = new Dictionary<long, int>();
}

protected TypeSafeFasterListForECS(int size) : base(size)
{
_mappedIndices = new Dictionary<int, int>();
_mappedIndices = new Dictionary<long, int>();
}

public bool MappedRemove(EGID entityID)


+ 6
- 11
Svelto.ECS/EGID.cs View File

@@ -1,25 +1,24 @@
using DBC;
using Svelto.ECS.Internal;

namespace Svelto.ECS
{
public struct EGID
{
int _GID;
long _GID;
public int GID
public long GID
{
get { return _GID; }
}
public int ID
{
get { return _GID & 0xFFFFFF; }
get { return (int) (_GID & 0xFFFFFFFF); }
}
public int group
{
get { return (int) ((_GID & 0xFF000000) >> 24); }
get { return (int) (_GID >> 32); }
}

public EGID(int entityID, int groupID) : this()
@@ -32,13 +31,9 @@ namespace Svelto.ECS
_GID = MAKE_GLOBAL_ID(entityID, ExclusiveGroups.StandardEntity);
}

int MAKE_GLOBAL_ID(int entityId, int groupId)
static long MAKE_GLOBAL_ID(int entityId, int groupId)
{
#if DEBUG && !PROFILER
Check.Require(entityId <= 0xFFFFFF);
Check.Require(groupId <= 0xFF);
#endif
return entityId | groupId << 24;
return entityId | (long)groupId << 32;
}

public bool IsEqualTo(EGID otherGID)


+ 1
- 1
Svelto.ECS/EnginesRootEngines.cs View File

@@ -41,7 +41,7 @@ namespace Svelto.ECS
_groupEntityViewsDB = new Dictionary<int, Dictionary<Type, ITypeSafeList>>();
_globalEntityViewsDBDic = new Dictionary<Type, ITypeSafeDictionary>();
_entityInfos = new Dictionary<int, IEntityViewBuilder[]>();
_entityInfos = new Dictionary<long, IEntityViewBuilder[]>();
_groupedEntityViewsToAdd = new DoubleBufferedEntityViews<Dictionary<int, Dictionary<Type, ITypeSafeList>>>();



+ 3
- 3
Svelto.ECS/EnginesRootEntities.cs View File

@@ -278,10 +278,10 @@ namespace Svelto.ECS
//Global pool of entity views when engines want to manage entityViews regardless
//the group
readonly Dictionary<Type, ITypeSafeList> _globalEntityViewsDB;
readonly Dictionary<Type, ITypeSafeList> _globalEntityViewsDB;
//indexable entity views when the entity ID is known. Usually useful to handle
//event based logic.
readonly Dictionary<Type, ITypeSafeDictionary> _globalEntityViewsDBDic;
Dictionary<int, IEntityViewBuilder[]> _entityInfos;
readonly Dictionary<Type, ITypeSafeDictionary> _globalEntityViewsDBDic;
readonly Dictionary<long, IEntityViewBuilder[]> _entityInfos;
}
}

+ 3
- 9
Svelto.ECS/EntityFactory.cs View File

@@ -11,20 +11,14 @@ namespace Svelto.ECS.Internal
internal static void BuildGroupedEntityViews(int entityID, int groupID,
Dictionary<int, Dictionary<Type, ITypeSafeList>> groupEntityViewsByType,
EntityDescriptorInfo entityViewsToBuildDescriptor,
Dictionary<int, IEntityViewBuilder[]> entityInfos,
Dictionary<long, IEntityViewBuilder[]> entityInfos,
object[] implementors)
{
var @group = FetchGroup(groupID, groupEntityViewsByType);

BuildEntityViewsAndAddToGroup(new EGID(entityID, groupID), group, entityViewsToBuildDescriptor, implementors);

AddEntityInfoView(new EGID(entityID, groupID), entityViewsToBuildDescriptor, entityInfos);
}

static void AddEntityInfoView(EGID entityID, EntityDescriptorInfo entityViewsToBuildDescriptor,
Dictionary<int, IEntityViewBuilder[]> entityInfos)
{
entityInfos.Add(entityID.GID, entityViewsToBuildDescriptor.entityViewsToBuild);
entityInfos.Add(new EGID(entityID, groupID).GID, entityViewsToBuildDescriptor.entityViewsToBuild);
}

static Dictionary<Type, ITypeSafeList> FetchGroup(int groupID, Dictionary<int, Dictionary<Type, ITypeSafeList>> groupEntityViewsByType)


Loading…
Cancel
Save