Browse Source

improving class names

tags/Rel25b
sebas77 6 years ago
parent
commit
42328fe278
12 changed files with 86 additions and 80 deletions
  1. +2
    -2
      Svelto.ECS/DataStructures/TypeSafeDictionary.cs
  2. +2
    -2
      Svelto.ECS/EnginesRoot.Engines.cs
  3. +1
    -1
      Svelto.ECS/EnginesRoot.Entities.cs
  4. +2
    -2
      Svelto.ECS/EntityDb.cs
  5. +9
    -0
      Svelto.ECS/EntityInfoView.cs
  6. +52
    -0
      Svelto.ECS/EntityView.cs
  7. +0
    -0
      Svelto.ECS/IEntityBuilder.cs
  8. +1
    -1
      Svelto.ECS/IEntityDB.cs
  9. +8
    -0
      Svelto.ECS/IEntityStruct.cs
  10. +0
    -63
      Svelto.ECS/IEntityViewStruct.cs
  11. +1
    -1
      Svelto.ECS/IQueryingEntityViewEngine.cs
  12. +8
    -8
      Svelto.ECS/StaticEntityDescriptorInfo.cs

+ 2
- 2
Svelto.ECS/DataStructures/TypeSafeDictionary.cs View File

@@ -1,8 +1,8 @@
using System;
using System.Collections.Generic;
using Svelto.DataStructures;
using Svelto.DataStructures.Experimental;
using Svelto.Utilities;
using Svelto.DataStructures.Experimental;
using Svelto.Utilities;

namespace Svelto.ECS.Internal
{


+ 2
- 2
Svelto.ECS/EnginesRoot.Engines.cs View File

@@ -43,7 +43,7 @@ namespace Svelto.ECS
_groupedEntityToAdd = new DoubleBufferedEntityViews<Dictionary<int, Dictionary<Type, ITypeSafeDictionary>>>();

_DB = new EntityViewsDB(_groupEntityDB);
_DB = new EntityDb(_groupEntityDB);

_scheduler = entityViewScheduler;
_scheduler.Schedule(new WeakAction(SubmitEntityViews));
@@ -64,7 +64,7 @@ namespace Svelto.ECS
var queryableEntityViewEngine = engine as IQueryingEntityViewEngine;
if (queryableEntityViewEngine != null)
{
queryableEntityViewEngine.entityViewsDB = _DB;
queryableEntityViewEngine.EntityDb = _DB;
queryableEntityViewEngine.Ready();
}
}


+ 1
- 1
Svelto.ECS/EnginesRoot.Entities.cs View File

@@ -195,7 +195,7 @@ namespace Svelto.ECS
return new EGID(firstID, toGroupId);
}

readonly EntityViewsDB _DB;
readonly EntityDb _DB;
//grouped set of entity views, this is the standard way to handle entity views
readonly Dictionary<int, Dictionary<Type, ITypeSafeDictionary>> _groupEntityDB;


Svelto.ECS/EntityViewsDB.cs → Svelto.ECS/EntityDb.cs View File

@@ -5,9 +5,9 @@ using Svelto.Utilities;

namespace Svelto.ECS.Internal
{
class EntityViewsDB : IEntityViewsDB
class EntityDb : IEntityDB
{
internal EntityViewsDB(Dictionary<int, Dictionary<Type, ITypeSafeDictionary>> groupEntityViewsDB)
internal EntityDb(Dictionary<int, Dictionary<Type, ITypeSafeDictionary>> groupEntityViewsDB)
{
_groupEntityViewsDB = groupEntityViewsDB;
}

+ 9
- 0
Svelto.ECS/EntityInfoView.cs View File

@@ -0,0 +1,9 @@
namespace Svelto.ECS
{
public struct EntityInfoView : IEntityStruct
{
public EGID ID { get; set; }
public IEntityBuilder[] entityToBuild;
}
}

+ 52
- 0
Svelto.ECS/EntityView.cs View File

@@ -0,0 +1,52 @@
using System;
using System.Collections.Generic;
using System.Reflection;
using Svelto.DataStructures;
using Svelto.Utilities;

namespace Svelto.ECS
{
static class EntityView<T> where T: IEntityStruct, new()
{
internal static readonly FasterList<KeyValuePair<Type, ActionCast<T>>> cachedFields;

static EntityView()
{
cachedFields = new FasterList<KeyValuePair<Type, ActionCast<T>>>();
var type = typeof(T);

var fields = type.GetFields(BindingFlags.Public |
BindingFlags.Instance);
for (int i = fields.Length - 1; i >= 0; --i)
{
var field = fields[i];

ActionCast<T> setter = FastInvoke<T>.MakeSetter(field);
cachedFields.Add(new KeyValuePair<Type, ActionCast<T>>(field.FieldType, setter));
}
}

internal static void InitCache()
{}
internal static void BuildEntityView(EGID ID, out T entityView)
{
entityView = new T { ID = ID };
}
}

///<summary>EntityViews can inherit from the EntityView class</summary>
public class EntityView : IEntityViewStruct
{
public EGID ID
{
get { return _ID; }
set { _ID = value; }
}

EGID _ID;
}
}

Svelto.ECS/IEntityViewBuilder.cs → Svelto.ECS/IEntityBuilder.cs View File


Svelto.ECS/IEntityViewsDB.cs → Svelto.ECS/IEntityDB.cs View File

@@ -3,7 +3,7 @@ using Svelto.Utilities;

namespace Svelto.ECS
{
public interface IEntityViewsDB
public interface IEntityDB
{
/// <summary>
/// All the EntityView related methods are left for back compatibility, but

+ 8
- 0
Svelto.ECS/IEntityStruct.cs View File

@@ -0,0 +1,8 @@
namespace Svelto.ECS
{
///<summary>EntityStruct MUST implement IEntiyStruct</summary>
public interface IEntityStruct
{
EGID ID { get; set; }
}
}

+ 0
- 63
Svelto.ECS/IEntityViewStruct.cs View File

@@ -1,70 +1,7 @@
using System;
using System.Collections.Generic;
using System.Reflection;
using Svelto.DataStructures;
using Svelto.Utilities;

namespace Svelto.ECS
{
///<summary>EntityStruct MUST implement IEntiyStruct</summary>
public interface IEntityStruct
{
EGID ID { get; set; }
}

///<summary>EntityViewStructs MUST implement IEntityViewStruct</summary>
public interface IEntityViewStruct:IEntityStruct
{}
///<summary>EntityViews can inherit from the EntityView class</summary>
public class EntityView : IEntityViewStruct
{
public EGID ID
{
get { return _ID; }
set { _ID = value; }
}

EGID _ID;
}

public struct EntityInfoView : IEntityStruct
{
public EGID ID { get; set; }
public IEntityBuilder[] entityToBuild;
}

public static class EntityView<T> where T: IEntityStruct, new()
{
internal static readonly FasterList<KeyValuePair<Type, ActionCast<T>>> cachedFields;

static EntityView()
{
cachedFields = new FasterList<KeyValuePair<Type, ActionCast<T>>>();
var type = typeof(T);

var fields = type.GetFields(BindingFlags.Public |
BindingFlags.Instance);
for (int i = fields.Length - 1; i >= 0; --i)
{
var field = fields[i];

ActionCast<T> setter = FastInvoke<T>.MakeSetter(field);
cachedFields.Add(new KeyValuePair<Type, ActionCast<T>>(field.FieldType, setter));
}
}

internal static void InitCache()
{}
internal static void BuildEntityView(EGID ID, out T entityView)
{
entityView = new T { ID = ID };
}
}
}


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

@@ -2,7 +2,7 @@ namespace Svelto.ECS
{
public interface IQueryingEntityViewEngine : IEngine
{
IEntityViewsDB entityViewsDB { set; }
IEntityDB EntityDb { set; }

void Ready();
}

Svelto.ECS/EntityDescriptor.cs → Svelto.ECS/StaticEntityDescriptorInfo.cs View File

@@ -15,17 +15,17 @@ namespace Svelto.ECS
this.entitiesToBuild = entityToBuild;
}

public IEntityBuilder[] entitiesToBuild { get; }
public IEntityBuilder[] entitiesToBuild { get; private set; }
}

public static class EntityDescriptorTemplate<TType> where TType : IEntityDescriptor, new()
{
public static readonly EntityDescriptor<TType> descriptor = new EntityDescriptor<TType>(new TType());
public static readonly StaticEntityDescriptorInfo<TType> descriptor = new StaticEntityDescriptorInfo<TType>(new TType());
}

public struct DynamicEntityDescriptorInfo<TType>:IEntityDescriptor where TType : IEntityDescriptor, new()
public struct DynamicEntityDescriptorInfo<TType> where TType : IEntityDescriptor, new()
{
public DynamicEntityDescriptorInfo(FasterList<IEntityBuilder> extraEntityViews)
public DynamicEntityDescriptorInfo(FasterList<IEntityBuilder> extraEntityViews) : this()
{
DBC.ECS.Check.Require(extraEntityViews.Count > 0,
"don't use a DynamicEntityDescriptorInfo if you don't need to use extra EntityViews");
@@ -39,16 +39,16 @@ namespace Svelto.ECS
Array.Copy(extraEntityViews.ToArrayFast(), 0, entitiesToBuild, length, extraEntityViews.Count);
}

public IEntityBuilder[] entitiesToBuild { get; }
public IEntityBuilder[] entitiesToBuild { get; private set; }
}

public struct EntityDescriptor<TType>:IEntityDescriptor where TType : IEntityDescriptor
public struct StaticEntityDescriptorInfo<TType> where TType : IEntityDescriptor
{
internal EntityDescriptor(TType descriptor)
internal StaticEntityDescriptorInfo(TType descriptor) : this()
{
entitiesToBuild = descriptor.entitiesToBuild;
}

public IEntityBuilder[] entitiesToBuild { get; }
public IEntityBuilder[] entitiesToBuild { get; private set; }
}
}

Loading…
Cancel
Save