add support for engines with EntityView, EntityStruct and EntityViewStructtags/Rel25a
@@ -60,7 +60,7 @@ namespace Svelto.ECS.Internal | |||
return entityView; | |||
} | |||
public bool EntityExists<T>(EGID entityGID) where T : IEntityData | |||
public bool Exists<T>(EGID entityGID) where T : IEntityData | |||
{ | |||
var type = typeof(T); | |||
@@ -83,13 +83,23 @@ namespace Svelto.ECS.Internal | |||
return false; | |||
} | |||
public bool TryQueryEntityView<T>(EGID entityegid, out T entityView) where T : class, IEntityData | |||
public void Fetch<T>(out T entity) where T : IEntityData | |||
{ | |||
entity = QueryEntities<T>()[0]; | |||
} | |||
public bool Has<T>() where T : IEntityData | |||
{ | |||
return QueryEntities<T>().Count > 0; | |||
} | |||
public bool TryQueryEntityView<T>(EGID entityegid, out T entityView) where T : IEntityData | |||
{ | |||
return TryQueryEntityViewInGroup(entityegid, out entityView); | |||
} | |||
bool TryQueryEntityViewInGroup<T>(EGID entityGID, out T entityView) where T:class, IEntityData | |||
bool TryQueryEntityViewInGroup<T>(EGID entityGID, out T entityView) where T:IEntityData | |||
{ | |||
var type = typeof(T); | |||
@@ -13,9 +13,11 @@ namespace Svelto.ECS | |||
T[] QueryEntitiesCacheFriendly<T>(int group, out int count) where T : struct, IEntityData; | |||
//to use with EntityViews | |||
bool TryQueryEntityView<T>(EGID ID, out T entityView) where T : class, IEntityData; | |||
T QueryEntityView<T>(EGID entityGID) where T : class, IEntityData; | |||
bool TryQueryEntityView<T>(EGID egid, out T entityView) where T : IEntityData; | |||
T QueryEntityView<T>(EGID egid) where T : class, IEntityData; | |||
bool EntityExists<T>(EGID ID) where T : IEntityData; | |||
bool Exists<T>(EGID egid) where T : IEntityData; | |||
void Fetch<T>(out T entity) where T:IEntityData; | |||
bool Has<T>() where T:IEntityData; | |||
} | |||
} |
@@ -1,7 +1,7 @@ | |||
namespace Svelto.ECS | |||
{ | |||
public abstract class MultiEntitiesEngine<T, U> : SingleEntitiesEngine<T>, IHandleEntityStructEngine<U> | |||
where U : struct, IEntityData where T : struct, IEntityData | |||
public abstract class MultiEntitiesEngine<T, U> : SingleEntityEngine<T>, IHandleEntityStructEngine<U> | |||
where U : IEntityData where T : IEntityData | |||
{ | |||
public void AddInternal(ref U entityView) | |||
{ Add(ref entityView); } | |||
@@ -13,7 +13,7 @@ namespace Svelto.ECS | |||
} | |||
public abstract class MultiEntitiesEngine<T, U, V> : MultiEntitiesEngine<T, U>, IHandleEntityStructEngine<V> | |||
where V : struct, IEntityData where U : struct, IEntityData where T : struct, IEntityData | |||
where V : IEntityData where U : IEntityData where T : IEntityData | |||
{ | |||
public void AddInternal(ref V entityView) | |||
{ Add(ref entityView); } | |||
@@ -30,7 +30,7 @@ namespace Svelto.ECS | |||
/// already too many responsabilities. | |||
/// </summary> | |||
public abstract class MultiEntitiesEngine<T, U, V, W> : MultiEntitiesEngine<T, U, V>, IHandleEntityStructEngine<W> | |||
where W : struct, IEntityData where V : struct, IEntityData where U : struct, IEntityData where T : struct, IEntityData | |||
where W : IEntityData where V : IEntityData where U : IEntityData where T : IEntityData | |||
{ | |||
public void AddInternal(ref W entityView) | |||
{ Add(ref entityView); } | |||
@@ -1,43 +0,0 @@ | |||
namespace Svelto.ECS | |||
{ | |||
public abstract class MultiEntityStructsEngine<T, U> : SingleEntityStructEngine<T>, IHandleEntityStructEngine<U> | |||
where U : struct, IEntityData where T : struct, IEntityData | |||
{ | |||
public void AddInternal(ref U entityView) | |||
{ Add(ref entityView); } | |||
public void RemoveInternal(ref U entityView) | |||
{ Remove(ref entityView); } | |||
protected abstract void Add(ref U entityView); | |||
protected abstract void Remove(ref U entityView); | |||
} | |||
public abstract class MultiEntityStructsEngine<T, U, V> : MultiEntityViewsEngine<T, U>, IHandleEntityStructEngine<V> | |||
where V : struct, IEntityData where U : struct, IEntityData where T : struct, IEntityData | |||
{ | |||
public void AddInternal(ref V entityView) | |||
{ Add(ref entityView); } | |||
public void RemoveInternal(ref V entityView) | |||
{ Remove(ref entityView); } | |||
protected abstract void Add(ref V entityView); | |||
protected abstract void Remove(ref V entityView); | |||
} | |||
/// <summary> | |||
/// Please do not add more MultiEntityViewsEngine | |||
/// if you use more than 4 nodes, your engine has | |||
/// already too many responsabilities. | |||
/// </summary> | |||
public abstract class MultiEntityStructsEngine<T, U, V, W> : MultiEntityViewsEngine<T, U, V>, IHandleEntityStructEngine<W> | |||
where W : struct, IEntityData where V : struct, IEntityData where U : struct, IEntityData where T : struct, IEntityData | |||
{ | |||
public void AddInternal(ref W entityView) | |||
{ Add(ref entityView); } | |||
public void RemoveInternal(ref W entityView) | |||
{ Remove(ref entityView); } | |||
protected abstract void Add(ref W entityView); | |||
protected abstract void Remove(ref W entityView); | |||
} | |||
} |
@@ -1,43 +0,0 @@ | |||
namespace Svelto.ECS | |||
{ | |||
public abstract class MultiEntityStructsEngine<T, U> : SingleEntityViewEngine<T>, IHandleEntityStructEngine<U> | |||
where U : IEntityData where T : IEntityData | |||
{ | |||
public void AddInternal(ref U entityView) | |||
{ Add(ref entityView); } | |||
public void RemoveInternal(ref U entityView) | |||
{ Remove(ref entityView); } | |||
protected abstract void Add(ref U entityView); | |||
protected abstract void Remove(ref U entityView); | |||
} | |||
public abstract class MultiEntityStructsEngine<T, U, V> : MultiEntityViewsEngine<T, U>, IHandleEntityStructEngine<V> | |||
where V : IEntityData where U : IEntityData where T : IEntityData | |||
{ | |||
public void AddInternal(ref V entityView) | |||
{ Add(ref entityView); } | |||
public void RemoveInternal(ref V entityView) | |||
{ Remove(ref entityView); } | |||
protected abstract void Add(ref V entityView); | |||
protected abstract void Remove(ref V entityView); | |||
} | |||
/// <summary> | |||
/// Please do not add more MultiEntityViewsEngine | |||
/// if you use more than 4 nodes, your engine has | |||
/// already too many responsabilities. | |||
/// </summary> | |||
public abstract class MultiEntityStructsEngine<T, U, V, W> : MultiEntityViewsEngine<T, U, V>, IHandleEntityStructEngine<W> | |||
where W : IEntityData where V : IEntityData where U : IEntityData where T : IEntityData | |||
{ | |||
public void AddInternal(ref W entityView) | |||
{ Add(ref entityView); } | |||
public void RemoveInternal(ref W entityView) | |||
{ Remove(ref entityView); } | |||
protected abstract void Add(ref W entityView); | |||
protected abstract void Remove(ref W entityView); | |||
} | |||
} |
@@ -1,6 +1,6 @@ | |||
namespace Svelto.ECS | |||
{ | |||
public abstract class SingleEntitiesEngine<T> : IHandleEntityStructEngine<T> where T : struct, IEntityData | |||
public abstract class SingleEntityEngine<T> : IHandleEntityStructEngine<T> where T : IEntityData | |||
{ | |||
public void AddInternal(ref T entityView) | |||
{ Add(ref entityView); } |