@@ -37,17 +37,18 @@ namespace Svelto.ECS | |||
///-------------------------------------------- | |||
EntityStructInitializer BuildEntity<T>(EGID entityID, object[] implementors) | |||
where T : class, IEntityDescriptor, new() | |||
where T : IEntityDescriptor, new() | |||
{ | |||
var dic = EntityFactory.BuildGroupedEntityViews(entityID, | |||
_groupedEntityToAdd.current, | |||
EntityDescriptorTemplate<T>.Info.entityViewsToBuild, | |||
implementors); | |||
_groupedEntityToAdd.current, | |||
EntityDescriptorTemplate<T>.Info.entityViewsToBuild, | |||
implementors); | |||
return new EntityStructInitializer(entityID, dic); | |||
} | |||
EntityStructInitializer BuildEntity(EGID entityID, IEntityViewBuilder[] entityViewsToBuild, | |||
EntityStructInitializer BuildEntity(EGID entityID, | |||
IEntityViewBuilder[] entityViewsToBuild, | |||
object[] implementors) | |||
{ | |||
var dic = EntityFactory.BuildGroupedEntityViews(entityID, | |||
@@ -60,7 +61,7 @@ namespace Svelto.ECS | |||
///-------------------------------------------- | |||
void Preallocate<T>(int groupID, int size) where T : class, IEntityDescriptor, new() | |||
void Preallocate<T>(int groupID, int size) where T : IEntityDescriptor, new() | |||
{ | |||
var entityViewsToBuild = EntityDescriptorTemplate<T>.Info.entityViewsToBuild; | |||
var count = entityViewsToBuild.Length; | |||
@@ -209,7 +210,7 @@ namespace Svelto.ECS | |||
_id = id; | |||
} | |||
public void Init<T>(ref T initializer) where T: struct, IEntityStruct | |||
public void Init<T>(T initializer) where T: struct, IEntityStruct | |||
{ | |||
var typeSafeDictionary = (TypeSafeDictionary<T>) _current[typeof(T)]; | |||
@@ -17,17 +17,17 @@ namespace Svelto.ECS | |||
_weakEngine = weakReference; | |||
} | |||
public EntityStructInitializer BuildEntity<T>(int entityID, object[] implementors) where T : class, IEntityDescriptor, new() | |||
public EntityStructInitializer BuildEntity<T>(int entityID, object[] implementors) where T : IEntityDescriptor, new() | |||
{ | |||
return _weakEngine.Target.BuildEntity<T>(new EGID(entityID), implementors); | |||
} | |||
public EntityStructInitializer BuildEntity<T>(int entityID, int groupID, object[] implementors) where T : class, IEntityDescriptor, new() | |||
public EntityStructInitializer BuildEntity<T>(int entityID, int groupID, object[] implementors) where T : IEntityDescriptor, new() | |||
{ | |||
return _weakEngine.Target.BuildEntity<T>(new EGID(entityID, groupID), implementors); | |||
} | |||
public EntityStructInitializer BuildEntity<T>(EGID egid, object[] implementors) where T : class, IEntityDescriptor, new() | |||
public EntityStructInitializer BuildEntity<T>(EGID egid, object[] implementors) where T : IEntityDescriptor, new() | |||
{ | |||
return _weakEngine.Target.BuildEntity<T>(egid, implementors); | |||
} | |||
@@ -47,12 +47,12 @@ namespace Svelto.ECS | |||
return _weakEngine.Target.BuildEntity(new EGID(entityID, groupID), entityViewsToBuild, implementors); | |||
} | |||
public void PreallocateEntitySpace<T>(int size) where T : class, IEntityDescriptor, new() | |||
public void PreallocateEntitySpace<T>(int size) where T : IEntityDescriptor, new() | |||
{ | |||
_weakEngine.Target.Preallocate<T>(ExclusiveGroups.StandardEntity, size); | |||
} | |||
public void PreallocateEntitySpace<T>(int groupID, int size) where T : class, IEntityDescriptor, new() | |||
public void PreallocateEntitySpace<T>(int groupID, int size) where T : IEntityDescriptor, new() | |||
{ | |||
_weakEngine.Target.Preallocate<T>(groupID, size); | |||
} | |||
@@ -18,9 +18,9 @@ namespace Svelto.ECS | |||
public IEntityViewBuilder[] entityViewsToBuild { get; } | |||
} | |||
public static class EntityDescriptorTemplate<TType> where TType : class, IEntityDescriptor, new() | |||
public static class EntityDescriptorTemplate<TType> where TType : IEntityDescriptor, new() | |||
{ | |||
public static readonly EntityDescriptorInfo Info = new EntityDescriptorInfo(new TType()); | |||
public static readonly EntityDescriptorInfo<TType> Info = new EntityDescriptorInfo<TType>(new TType()); | |||
} | |||
public struct DynamicEntityDescriptorInfo<TType> where TType : class, IEntityDescriptor, new() | |||
@@ -42,11 +42,11 @@ namespace Svelto.ECS | |||
} | |||
} | |||
public struct EntityDescriptorInfo | |||
public struct EntityDescriptorInfo<TType> where TType : IEntityDescriptor | |||
{ | |||
public readonly IEntityViewBuilder[] entityViewsToBuild; | |||
internal EntityDescriptorInfo(IEntityDescriptor descriptor) | |||
internal EntityDescriptorInfo(TType descriptor) | |||
{ | |||
entityViewsToBuild = descriptor.entityViewsToBuild; | |||
} | |||
@@ -71,7 +71,7 @@ namespace Svelto.ECS.Internal | |||
int count; | |||
return QueryEntities<T>(out count); | |||
return QueryEntities<T>(entityGID.groupID, out count); | |||
} | |||
public T QueryEntityView<T>(EGID entityGID) where T : class, IEntityStruct | |||
@@ -5,7 +5,7 @@ namespace Svelto.ECS | |||
UnityEngine.MonoBehaviour , IEntityDescriptorHolder | |||
where T: class, IEntityDescriptor, new() | |||
{ | |||
public EntityDescriptorInfo RetrieveDescriptorInfo() | |||
public EntityDescriptorInfo<T> RetrieveDescriptorInfo<T>() | |||
{ | |||
return EntityDescriptorTemplate<T>.Info; | |||
} | |||
@@ -2,6 +2,6 @@ namespace Svelto.ECS | |||
{ | |||
public interface IEntityDescriptorHolder | |||
{ | |||
EntityDescriptorInfo RetrieveDescriptorInfo(); | |||
EntityDescriptorInfo<T> RetrieveDescriptorInfo<T>() where T : IEntityDescriptor; | |||
} | |||
} |
@@ -16,8 +16,8 @@ namespace Svelto.ECS | |||
/// </summary> | |||
/// <typeparam name="T"></typeparam> | |||
/// <param name="size"></param> | |||
void PreallocateEntitySpace<T>(int size) where T : class, IEntityDescriptor, new(); | |||
void PreallocateEntitySpace<T>(int groupID, int size) where T : class, IEntityDescriptor, new(); | |||
void PreallocateEntitySpace<T>(int size) where T : IEntityDescriptor, new(); | |||
void PreallocateEntitySpace<T>(int groupID, int size) where T : IEntityDescriptor, new(); | |||
/// <summary> | |||
/// The EntityDescriptor doesn't need to be ever instantiated. It just describes the Entity | |||
@@ -28,7 +28,7 @@ namespace Svelto.ECS | |||
/// <typeparam name="T"></typeparam> | |||
/// <param name="entityID"></param> | |||
/// <param name="implementors"></param> | |||
EntityStructInitializer BuildEntity<T>(int entityID, object[] implementors) where T:class, IEntityDescriptor, new(); | |||
EntityStructInitializer BuildEntity<T>(int entityID, object[] implementors) where T:IEntityDescriptor, new(); | |||
/// <summary> | |||
@@ -41,8 +41,8 @@ namespace Svelto.ECS | |||
/// <param name="groupID"></param> | |||
/// <param name="ed"></param> | |||
/// <param name="implementors"></param> | |||
EntityStructInitializer BuildEntity<T>(int entityID, int groupID, object[] implementors) where T:class, IEntityDescriptor, new(); | |||
EntityStructInitializer BuildEntity<T>(EGID egid, object[] implementors) where T:class, IEntityDescriptor, new(); | |||
EntityStructInitializer BuildEntity<T>(int entityID, int groupID, object[] implementors) where T:IEntityDescriptor, new(); | |||
EntityStructInitializer BuildEntity<T>(EGID egid, object[] implementors) where T:IEntityDescriptor, new(); | |||
/// <summary> | |||