Browse Source

Try queries must not crash if the entity is not found

force to inherit from sequencer to improve readibility
tags/Rel25b
sebas77 6 years ago
parent
commit
d8140276b3
4 changed files with 8 additions and 21 deletions
  1. +6
    -3
      Svelto.ECS/DataStructures/TypeSafeDictionary.cs
  2. +1
    -3
      Svelto.ECS/EntitiesDB.cs
  3. +0
    -14
      Svelto.ECS/Extensions/Unity/GenericEntityDescriptorHolder.cs
  4. +1
    -1
      Svelto.ECS/Sequencer.cs

+ 6
- 3
Svelto.ECS/DataStructures/TypeSafeDictionary.cs View File

@@ -52,9 +52,7 @@ namespace Svelto.ECS.Internal
{
for (var i = 0; i < count; i++)
{
var entityView = buffer[i];

Add(entityView.ID.entityID, entityView);
Add(buffer[i].ID.entityID, ref buffer[i]);
}
}
catch (Exception e)
@@ -169,6 +167,11 @@ namespace Svelto.ECS.Internal
return findIndex;
}
public bool TryFindElementIndex(int entityGidEntityId, out uint index)
{
return FindIndex(entityGidEntityId, out index);
}
static readonly Type _type = typeof(TValue);
}
}

+ 1
- 3
Svelto.ECS/EntitiesDB.cs View File

@@ -64,9 +64,7 @@ namespace Svelto.ECS.Internal
return null;
}

if (casted != null)
index = casted.FindElementIndex(entityGID.entityID);
else
if (casted == null || casted.TryFindElementIndex(entityGID.entityID, out index) == false)
{
index = 0;
return null;


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

@@ -1,14 +0,0 @@
#if UNITY_5 || UNITY_5_3_OR_NEWER
namespace Svelto.ECS
{
public class GenericEntityDescriptorHolder<T>:
UnityEngine.MonoBehaviour , IEntityDescriptorHolder
where T: IEntityDescriptor, new()
{
public IEntityBuilder[] GetEntitiesToBuild()
{
return EntityDescriptorTemplate<T>.descriptor.entitiesToBuild;
}
}
}
#endif

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

@@ -47,7 +47,7 @@ namespace Svelto.ECS
void Next<T, C>(IEngine engine, ref T param, C condition) where C : struct, IConvertible;
}

public class Sequencer : ISequencer
public abstract class Sequencer : ISequencer
{
public void SetSequence(Steps steps)
{


Loading…
Cancel
Save