Browse Source

remove some contraints that were not necessary

tags/Rel25b
sebas77 6 years ago
parent
commit
b5121de872
7 changed files with 25 additions and 24 deletions
  1. +8
    -7
      Svelto.ECS/EnginesRoot.Entities.cs
  2. +5
    -5
      Svelto.ECS/EnginesRoot.GenericEntityFactory.cs
  3. +4
    -4
      Svelto.ECS/EntityDescriptor.cs
  4. +1
    -1
      Svelto.ECS/EntityViewsDB.cs
  5. +1
    -1
      Svelto.ECS/Extensions/Unity/GenericEntityDescriptorHolder.cs
  6. +1
    -1
      Svelto.ECS/IEntityDescriptorHolder.cs
  7. +5
    -5
      Svelto.ECS/IEntityFactory.cs

+ 8
- 7
Svelto.ECS/EnginesRoot.Entities.cs View File

@@ -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)];



+ 5
- 5
Svelto.ECS/EnginesRoot.GenericEntityFactory.cs View File

@@ -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);
}


+ 4
- 4
Svelto.ECS/EntityDescriptor.cs View File

@@ -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;
}


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

@@ -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


+ 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 EntityDescriptorInfo RetrieveDescriptorInfo()
public EntityDescriptorInfo<T> RetrieveDescriptorInfo<T>()
{
return EntityDescriptorTemplate<T>.Info;
}


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

@@ -2,6 +2,6 @@ namespace Svelto.ECS
{
public interface IEntityDescriptorHolder
{
EntityDescriptorInfo RetrieveDescriptorInfo();
EntityDescriptorInfo<T> RetrieveDescriptorInfo<T>() where T : IEntityDescriptor;
}
}

+ 5
- 5
Svelto.ECS/IEntityFactory.cs View File

@@ -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>


Loading…
Cancel
Save