Browse Source

fix some errors

remove some redundant methods
tags/Rel2
sebas77 7 years ago
parent
commit
e4d3ea9e4b
6 changed files with 19 additions and 44 deletions
  1. +1
    -8
      Svelto.ECS/DataStructures/TypeSafeFasterListForECS.cs
  2. +11
    -0
      Svelto.ECS/EGID.cs
  3. +6
    -2
      Svelto.ECS/EnginesRootEntities.cs
  4. +0
    -28
      Svelto.ECS/EntityViewsDB.cs
  5. +1
    -1
      Svelto.ECS/Extensions/Unity/GenericEntityDescriptorHolder.cs
  6. +0
    -5
      Svelto.ECS/IEntityViewsDB.cs

+ 1
- 8
Svelto.ECS/DataStructures/TypeSafeFasterListForECS.cs View File

@@ -43,14 +43,7 @@ namespace Svelto.ECS.Internal

if (UnorderedRemoveAt(index))
{
try
{
_mappedIndices.Add(this[index].ID.GID, index);
}
catch (Exception e)
{
throw new TypeSafeFasterListForECSException(e);
}
_mappedIndices[this[index].ID.GID] = index;
}

return Count > 0;


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

@@ -1,4 +1,5 @@
using DBC;
using Svelto.ECS.Internal;

namespace Svelto.ECS
{
@@ -25,6 +26,11 @@ namespace Svelto.ECS
{
_GID = MAKE_GLOBAL_ID(entityID, groupID);
}
public EGID(int entityID) : this()
{
_GID = MAKE_GLOBAL_ID(entityID, ExclusiveGroups.StandardEntity);
}

int MAKE_GLOBAL_ID(int entityId, int groupId)
{
@@ -34,5 +40,10 @@ namespace Svelto.ECS
#endif
return entityId | groupId << 24;
}

public bool IsEqualTo(EGID otherGID)
{
return otherGID._GID == _GID;
}
}
}

+ 6
- 2
Svelto.ECS/EnginesRootEntities.cs View File

@@ -127,7 +127,9 @@ namespace Svelto.ECS

void RemoveEntity(EGID entityGID)
{
_DB.TryQueryEntityView<EntityInfoView>(entityGID, out var entityInfoView);
EntityInfoView entityInfoView;
_DB.TryQueryEntityView(entityGID, out entityInfoView);

var entityViewBuilders = entityInfoView.entityViews;
EGID id = entityInfoView._ID;
@@ -231,7 +233,9 @@ namespace Svelto.ECS
Check.Require(fromGroupID != toGroupID,
"can't move an entity to the same group where it already belongs to");

_DB.TryQueryEntityViewInGroup(fromGroupID, entityID, out EntityInfoView entityInfoView);
EntityInfoView entityInfoView;
_DB.TryQueryEntityView(new EGID(fromGroupID, entityID), out entityInfoView);
var entityViewBuilders = entityInfoView.entityViews;
var entityViewBuildersCount = entityViewBuilders.Length;


+ 0
- 28
Svelto.ECS/EntityViewsDB.cs View File

@@ -71,15 +71,6 @@ namespace Svelto.ECS.Internal
return FasterList<T>.NoVirt.ToArrayFast((FasterList<T>)entitiesInGroupPerType[type], out count);
}

public T QueryEntityView<T>(int entityID) where T:EntityView
{
T entityView;

TryQueryEntityViewInGroup(new EGID(entityID, ExclusiveGroups.StandardEntity), out entityView);

return entityView;
}

public T QueryEntityView<T>(EGID entityGID) where T : EntityView
{
T entityView;
@@ -89,30 +80,11 @@ namespace Svelto.ECS.Internal
return entityView;
}

public bool TryQueryEntityView<T>(int entityID, out T entityView) where T:EntityView
{
return TryQueryEntityViewInGroup(new EGID(entityID, ExclusiveGroups.StandardEntity), out entityView);
}

public bool TryQueryEntityView<T>(EGID entityegid, out T entityView) where T : EntityView
{
return TryQueryEntityViewInGroup(entityegid, out entityView);
}

public T QueryEntityViewInGroup<T>(int entityID, int groupID) where T:EntityView
{
T entityView;

TryQueryEntityViewInGroup(entityID, groupID, out entityView);

return entityView;
}

public bool TryQueryEntityViewInGroup<T>(int entityID, int groupID, out T entityView) where T : EntityView
{
return TryQueryEntityViewInGroup(new EGID(entityID, groupID), out entityView);
}

bool TryQueryEntityViewInGroup<T>(EGID entityGID, out T entityView) where T:EntityView
{
var type = typeof(T);


+ 1
- 1
Svelto.ECS/Extensions/Unity/GenericEntityDescriptorHolder.cs View File

@@ -5,7 +5,7 @@ namespace Svelto.ECS
UnityEngine.MonoBehaviour , IEntityDescriptorHolder
where T: class, IEntityDescriptor, new()
{
public IEntityDescriptorInfo RetrieveDescriptor()
public EntityDescriptorInfo RetrieveDescriptor()
{
return EntityDescriptorTemplate<T>.Default;
}


+ 0
- 5
Svelto.ECS/IEntityViewsDB.cs View File

@@ -10,12 +10,7 @@ namespace Svelto.ECS
T[] QueryEntityViewsAsArray<T>(out int count) where T : IEntityView;
T[] QueryGroupedEntityViewsAsArray<T>(int group, out int count) where T : IEntityView;

bool TryQueryEntityView<T>(int ID, out T entityView) where T : EntityView;
bool TryQueryEntityView<T>(EGID ID, out T entityView) where T : EntityView;
T QueryEntityView<T>(int ID) where T : EntityView;
T QueryEntityView<T>(EGID entityGID) where T : EntityView;

bool TryQueryEntityViewInGroup<T>(int entityID, int groupID, out T entityView) where T : EntityView;
T QueryEntityViewInGroup<T>(int entityID, int groupID) where T : EntityView;
}
}

Loading…
Cancel
Save