From f7f97732ebacadd1c7f0697dcafdae92e2eb286c Mon Sep 17 00:00:00 2001 From: sebas77 Date: Sat, 3 Mar 2018 01:07:30 +0000 Subject: [PATCH] clean up and fix more bugs --- .../DataStructures/TypeSafeDictionary.cs | 31 ++- .../TypeSafeDictionaryException.cs | 5 +- .../TypeSafeFasterListForECS.cs | 77 +++--- Svelto.ECS/EnginesRootEntities.cs | 237 +++++++++--------- Svelto.ECS/EntityDescriptor.cs | 39 +-- Svelto.ECS/EntityFactory.cs | 138 +++++----- Svelto.ECS/EntityInfoImplementor.cs | 7 +- Svelto.ECS/EntitySubmissionScheduler.cs | 2 +- .../Experimental/StructNodeCollections.cs | 9 +- Svelto.ECS/IEngine.cs | 7 +- Svelto.ECS/IEntityDescriptorHolder.cs | 2 +- Svelto.ECS/IEntityViewsDB.cs | 29 ++- Svelto.ECS/MultiEntityViewsEngine.cs | 40 +-- .../EngineProfiler/EngineProfilerInspector.cs | 1 - Svelto.ECS/Profiler/EngineProfiler.cs | 13 +- Svelto.ECS/SingleEntityViewEngine.cs | 10 +- 16 files changed, 329 insertions(+), 318 deletions(-) diff --git a/Svelto.ECS/DataStructures/TypeSafeDictionary.cs b/Svelto.ECS/DataStructures/TypeSafeDictionary.cs index 0ffde6b..d1e7dcc 100644 --- a/Svelto.ECS/DataStructures/TypeSafeDictionary.cs +++ b/Svelto.ECS/DataStructures/TypeSafeDictionary.cs @@ -1,29 +1,28 @@ using System; -using Svelto.DataStructures; using System.Collections.Generic; +using Svelto.DataStructures; namespace Svelto.ECS.Internal { /// - /// This is just a place holder at the moment - /// I always wanted to create my own Dictionary - /// data structure as excercise, but never had the - /// time to. At the moment I need the custom interface - /// wrapped though. + /// This is just a place holder at the moment + /// I always wanted to create my own Dictionary + /// data structure as excercise, but never had the + /// time to. At the moment I need the custom interface + /// wrapped though. /// - public interface ITypeSafeDictionary { - void FillWithIndexedEntityViews(ITypeSafeList entityViews); - bool Remove(int entityId); - IEntityView GetIndexedEntityView(int entityID); + void FillWithIndexedEntityViews(ITypeSafeList entityViews); + bool Remove(int entityId); + IEntityView GetIndexedEntityView(int entityID); } - class TypeSafeDictionary : Dictionary, ITypeSafeDictionary where TValue:IEntityView + class TypeSafeDictionary : Dictionary, ITypeSafeDictionary where TValue : IEntityView { - internal static readonly ReadOnlyDictionary Default = + internal static readonly ReadOnlyDictionary Default = new ReadOnlyDictionary(new Dictionary()); - + public void FillWithIndexedEntityViews(ITypeSafeList entityViews) { int count; @@ -31,7 +30,7 @@ namespace Svelto.ECS.Internal try { - for (int i = 0; i < count; i++) + for (var i = 0; i < count; i++) { var entityView = buffer[i]; @@ -48,7 +47,7 @@ namespace Svelto.ECS.Internal { base.Remove(entityId); - return this.Count > 0; + return Count > 0; } public IEntityView GetIndexedEntityView(int entityID) @@ -56,4 +55,4 @@ namespace Svelto.ECS.Internal return this[entityID]; } } -} +} \ No newline at end of file diff --git a/Svelto.ECS/DataStructures/TypeSafeDictionaryException.cs b/Svelto.ECS/DataStructures/TypeSafeDictionaryException.cs index 1db957d..4f2a321 100644 --- a/Svelto.ECS/DataStructures/TypeSafeDictionaryException.cs +++ b/Svelto.ECS/DataStructures/TypeSafeDictionaryException.cs @@ -4,7 +4,8 @@ namespace Svelto.ECS { public class TypeSafeDictionaryException : Exception { - public TypeSafeDictionaryException(Exception exception):base(exception.Message, exception) - {} + public TypeSafeDictionaryException(Exception exception) : base(exception.Message, exception) + { + } } } \ No newline at end of file diff --git a/Svelto.ECS/DataStructures/TypeSafeFasterListForECS.cs b/Svelto.ECS/DataStructures/TypeSafeFasterListForECS.cs index 17235f2..8175857 100644 --- a/Svelto.ECS/DataStructures/TypeSafeFasterListForECS.cs +++ b/Svelto.ECS/DataStructures/TypeSafeFasterListForECS.cs @@ -1,61 +1,65 @@ using System; using System.Collections; using System.Collections.Generic; +using DesignByContract; using Svelto.DataStructures; namespace Svelto.ECS.Internal { - public interface ITypeSafeList: IEnumerable + public interface ITypeSafeList : IEnumerable { + bool isQueryiableEntityView { get; } void AddRange(ITypeSafeList entityViewListValue); - ITypeSafeList Create(); - bool isQueryiableEntityView { get; } - bool UnorderedRemove(int entityID); + ITypeSafeList Create(); + bool MappedRemove(int entityID); ITypeSafeDictionary CreateIndexedDictionary(); - IEntityView[] ToArrayFast(out int count); - void ReserveCapacity(int capacity); + IEntityView[] ToArrayFast(out int count); + void ReserveCapacity(int capacity); } - class TypeSafeFasterListForECS: FasterList where T:IEntityView + class TypeSafeFasterListForECS : FasterList where T : IEntityView { + readonly Dictionary _mappedIndices; + protected TypeSafeFasterListForECS() { _mappedIndices = new Dictionary(); } - protected TypeSafeFasterListForECS(int size):base(size) + protected TypeSafeFasterListForECS(int size) : base(size) { _mappedIndices = new Dictionary(); } - - public bool UnorderedRemove(int entityID) + + public bool MappedRemove(int entityID) { var index = _mappedIndices[entityID]; - DesignByContract.Check.Assert(entityID == this[index].ID, "Something went wrong with the Svelto.ECS code, please contact the author"); + Check.Assert(entityID == this[index].ID, + "Something went wrong with the Svelto.ECS code, please contact the author"); _mappedIndices.Remove(entityID); if (UnorderedRemoveAt(index)) _mappedIndices[this[index].ID] = index; - return this.Count > 0; + return Count > 0; } - + public void AddRange(ITypeSafeList entityViewListValue) { - var index = this.Count; - + var index = Count; + base.AddRange(entityViewListValue as FasterList); - - for (int i = index; i < Count; ++i) + + for (var i = index; i < Count; ++i) _mappedIndices[this[i].ID] = i; } - new public void Add(T entityView) + public new void Add(T entityView) { - var index = this.Count; + var index = Count; base.Add(entityView); @@ -64,7 +68,7 @@ namespace Svelto.ECS.Internal public void ReserveCapacity(int capacity) { - if (this.ToArrayFast().Length < capacity) + if (ToArrayFast().Length < capacity) Resize(capacity); } @@ -72,17 +76,18 @@ namespace Svelto.ECS.Internal { return _mappedIndices[entityID]; } - - readonly Dictionary _mappedIndices; } - class TypeSafeFasterListForECSForStructs : TypeSafeFasterListForECS, ITypeSafeList where T:struct, IEntityStruct + class TypeSafeFasterListForECSForStructs : TypeSafeFasterListForECS, ITypeSafeList + where T : struct, IEntityStruct { - public TypeSafeFasterListForECSForStructs(int size):base(size) - {} + public TypeSafeFasterListForECSForStructs(int size) : base(size) + { + } public TypeSafeFasterListForECSForStructs() - {} + { + } public ITypeSafeList Create() { @@ -109,14 +114,16 @@ namespace Svelto.ECS.Internal return new TypeSafeFasterListForECSForStructs(size); } } - - class TypeSafeFasterListForECSForClasses : TypeSafeFasterListForECS, ITypeSafeList where T:EntityView, new() + + class TypeSafeFasterListForECSForClasses : TypeSafeFasterListForECS, ITypeSafeList where T : EntityView, new() { - public TypeSafeFasterListForECSForClasses(int size):base(size) - {} + public TypeSafeFasterListForECSForClasses(int size) : base(size) + { + } public TypeSafeFasterListForECSForClasses() - {} + { + } public ITypeSafeList Create() { @@ -135,9 +142,9 @@ namespace Svelto.ECS.Internal public IEntityView[] ToArrayFast(out int count) { - count = this.Count; - - return this.ToArrayFast(); + count = Count; + + return ToArrayFast(); } public ITypeSafeList Create(int size) @@ -145,4 +152,4 @@ namespace Svelto.ECS.Internal return new TypeSafeFasterListForECSForClasses(size); } } -} +} \ No newline at end of file diff --git a/Svelto.ECS/EnginesRootEntities.cs b/Svelto.ECS/EnginesRootEntities.cs index 6a3adbb..0a50abf 100644 --- a/Svelto.ECS/EnginesRootEntities.cs +++ b/Svelto.ECS/EnginesRootEntities.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using DesignByContract; using Svelto.DataStructures; using Svelto.ECS.Internal; @@ -11,10 +12,24 @@ namespace Svelto.ECS { public partial class EnginesRoot : IDisposable { + public void Dispose() + { + foreach (var entity in _entityViewsDB) + if (entity.Value.isQueryiableEntityView) + foreach (var entityView in entity.Value) + RemoveEntityViewFromEngines(_entityViewEngines, entityView as EntityView, entity.Key); + + foreach (var entity in _metaEntityViewsDB) + { + foreach (var entityView in entity.Value) + RemoveEntityViewFromEngines(_entityViewEngines, entityView as EntityView, entity.Key); + } + } + /// - /// an EnginesRoot reference cannot be held by anything else than the Composition Root - /// where it has been created. IEntityFactory and IEntityFunctions allow a weakreference - /// of the EnginesRoot to be passed around. + /// an EnginesRoot reference cannot be held by anything else than the Composition Root + /// where it has been created. IEntityFactory and IEntityFunctions allow a weakreference + /// of the EnginesRoot to be passed around. /// /// public IEntityFactory GenerateEntityFactory() @@ -28,10 +43,10 @@ namespace Svelto.ECS } /// - /// The EntityDescriptor doesn't need to be ever instantiated. It just describes the Entity - /// itself in terms of EntityViews to build. The Implementors are passed to fill the - /// references of the EntityViews components. Please read the articles on my blog - /// to understand better the terminologies + /// The EntityDescriptor doesn't need to be ever instantiated. It just describes the Entity + /// itself in terms of EntityViews to build. The Implementors are passed to fill the + /// references of the EntityViews components. Please read the articles on my blog + /// to understand better the terminologies /// /// /// @@ -43,8 +58,8 @@ namespace Svelto.ECS } /// - /// When the type of the entity is not known (this is a special case!) an EntityDescriptorInfo - /// can be built in place of the generic parameter T. + /// When the type of the entity is not known (this is a special case!) an EntityDescriptorInfo + /// can be built in place of the generic parameter T. /// /// /// @@ -56,26 +71,26 @@ namespace Svelto.ECS } /// - /// A meta entity is a way to manage a set of entitites that are not easily - /// queriable otherwise. For example you may want to group existing entities - /// by size and type and then use the meta entity entityView to manage the data - /// shared among the single entities of the same type and size. This will - /// prevent the scenario where the coder is forced to parse all the entities to - /// find the ones of the same size and type. - /// Since the entities are managed through the shared entityView, the same - /// shared entityView must be found on the single entities of the same type and size. - /// The shared entityView of the meta entity is then used by engines that are meant - /// to manage a group of entities through a single entityView. - /// The same engine can manage several meta entities entityViews too. - /// The Engine manages the logic of the Meta EntityView data and other engines - /// can read back this data through the normal entity as the shared entityView - /// will be present in their descriptor too. - /// It's a way to control a group of Entities through a entityView only. - /// This set of entities can share exactly the same entityView reference if - /// built through this function. In this way, if you need to set a variable - /// on a group of entities, instead to inject N entityViews and iterate over - /// them to set the same value, you can inject just one entityView, set the value - /// and be sure that the value is shared between entities. + /// A meta entity is a way to manage a set of entitites that are not easily + /// queriable otherwise. For example you may want to group existing entities + /// by size and type and then use the meta entity entityView to manage the data + /// shared among the single entities of the same type and size. This will + /// prevent the scenario where the coder is forced to parse all the entities to + /// find the ones of the same size and type. + /// Since the entities are managed through the shared entityView, the same + /// shared entityView must be found on the single entities of the same type and size. + /// The shared entityView of the meta entity is then used by engines that are meant + /// to manage a group of entities through a single entityView. + /// The same engine can manage several meta entities entityViews too. + /// The Engine manages the logic of the Meta EntityView data and other engines + /// can read back this data through the normal entity as the shared entityView + /// will be present in their descriptor too. + /// It's a way to control a group of Entities through a entityView only. + /// This set of entities can share exactly the same entityView reference if + /// built through this function. In this way, if you need to set a variable + /// on a group of entities, instead to inject N entityViews and iterate over + /// them to set the same value, you can inject just one entityView, set the value + /// and be sure that the value is shared between entities. /// /// /// @@ -87,39 +102,43 @@ namespace Svelto.ECS } /// - /// Using this function is like building a normal entity, but the entityViews - /// are grouped by groupID to be more efficently processed inside engines and - /// improve cache locality. Either class entityViews and struct entityViews can be - /// grouped. + /// Using this function is like building a normal entity, but the entityViews + /// are grouped by groupID to be more efficently processed inside engines and + /// improve cache locality. Either class entityViews and struct entityViews can be + /// grouped. /// /// /// /// /// - void BuildEntityInGroup(int entityID, int groupID, object[] implementors = null) where T : IEntityDescriptor, new() + void BuildEntityInGroup(int entityID, int groupID, object[] implementors = null) + where T : IEntityDescriptor, new() { EntityFactory.BuildGroupedEntityViews(entityID, groupID, _groupedEntityViewsToAdd.current, + _entityViewsToAdd.current, EntityDescriptorTemplate.Default, implementors); } - void BuildEntityInGroup(int entityID, int groupID, IEntityDescriptorInfo entityDescriptor, object[] implementors = null) + void BuildEntityInGroup(int entityID, int groupID, IEntityDescriptorInfo entityDescriptor, + object[] implementors = null) { EntityFactory.BuildGroupedEntityViews(entityID, groupID, _groupedEntityViewsToAdd.current, + _entityViewsToAdd.current, entityDescriptor, implementors); } void Preallocate(int size) where T : IEntityDescriptor, new() { var entityViewsToBuild = ((EntityDescriptorInfo) EntityDescriptorTemplate.Default).entityViewsToBuild; - int count = entityViewsToBuild.Length; + var count = entityViewsToBuild.Length; - for (int index = 0; index < count; index++) + for (var index = 0; index < count; index++) { var entityViewBuilder = entityViewsToBuild[index]; - var entityViewType = entityViewBuilder.GetEntityViewType(); + var entityViewType = entityViewBuilder.GetEntityViewType(); ITypeSafeList dbList; if (_entityViewsDB.TryGetValue(entityViewType, out dbList) == false) @@ -134,28 +153,31 @@ namespace Svelto.ECS } } - void RemoveEntity(ref EntityInfoView entityInfoView, Dictionary viewsDB, Dictionary entityViewsDBDic) + void RemoveEntity(ref EntityInfoView entityInfoView, Dictionary viewsDB, + Dictionary entityViewsDBDic) { if (entityInfoView.isInAGroup) - InternalRemoveFromGroupAndDBAndEngines(entityInfoView.entityViews, entityInfoView.ID, entityInfoView.groupID, viewsDB, entityViewsDBDic); + InternalRemoveFromGroupAndDBAndEngines(entityInfoView.entityViews, entityInfoView.ID, + entityInfoView.groupID, viewsDB, entityViewsDBDic); else - InternalRemoveFromDBAndEngines(entityInfoView.entityViews, entityInfoView.ID, viewsDB, entityViewsDBDic); + InternalRemoveFromDBAndEngines(entityInfoView.entityViews, entityInfoView.ID, viewsDB, + entityViewsDBDic); } - + void RemoveEntity(int entityID) { var entityInfoView = _DB.QueryEntityView(entityID); - + RemoveEntity(ref entityInfoView, _entityViewsDB, _entityViewsDBDic); } void RemoveMetaEntity(int metaEntityID) { var entityInfoView = _DB.QueryMetaEntityView(metaEntityID); - + RemoveEntity(ref entityInfoView, _metaEntityViewsDB, _metaEntityViewsDBDic); } - + void RemoveGroupAndEntitiesFromDB(int groupID) { foreach (var group in _groupEntityViewsDB[groupID]) @@ -165,29 +187,31 @@ namespace Svelto.ECS int count; var entities = group.Value.ToArrayFast(out count); - for (int i = 0; i < count; i++) + for (var i = 0; i < count; i++) { var entityID = entities[i].ID; - InternalRemoveEntityViewFromDBAndEngines(_entityViewsDB, _entityViewsDBDic, entityViewType, entityID); + InternalRemoveEntityViewFromDBAndEngines(_entityViewsDB, _entityViewsDBDic, entityViewType, + entityID); } } - + _groupEntityViewsDB.Remove(groupID); } - - void InternalRemoveEntityViewFromDBAndEngines(Dictionary entityViewsDB, + + void InternalRemoveEntityViewFromDBAndEngines(Dictionary entityViewsDB, Dictionary entityViewsDBDic, - Type entityViewType, int entityID) + Type entityViewType, + int entityID) { var entityViews = entityViewsDB[entityViewType]; - if (entityViews.UnorderedRemove(entityID) == false) + if (entityViews.MappedRemove(entityID) == false) entityViewsDB.Remove(entityViewType); if (entityViews.isQueryiableEntityView) { var typeSafeDictionary = entityViewsDBDic[entityViewType]; - var entityView = typeSafeDictionary.GetIndexedEntityView(entityID); + var entityView = typeSafeDictionary.GetIndexedEntityView(entityID); if (typeSafeDictionary.Remove(entityID) == false) entityViewsDBDic.Remove(entityViewType); @@ -199,12 +223,13 @@ namespace Svelto.ECS void SwapEntityGroup(int entityID, int fromGroupID, int toGroupID) { - DesignByContract.Check.Require(fromGroupID != toGroupID, "can't move an entity to the same group where it already belongs to"); + Check.Require(fromGroupID != toGroupID, + "can't move an entity to the same group where it already belongs to"); - var entityViewBuilders = _DB.QueryEntityView(entityID).entityViews; - int entityViewBuildersCount = entityViewBuilders.Length; + var entityViewBuilders = _DB.QueryEntityView(entityID).entityViews; + var entityViewBuildersCount = entityViewBuilders.Length; - var dictionary = _groupEntityViewsDB[fromGroupID]; + var groupedEntities = _groupEntityViewsDB[fromGroupID]; Dictionary groupedEntityViewsTyped; if (_groupEntityViewsDB.TryGetValue(toGroupID, out groupedEntityViewsTyped) == false) @@ -214,43 +239,46 @@ namespace Svelto.ECS _groupEntityViewsDB.Add(toGroupID, groupedEntityViewsTyped); } - for (int i = 0; i < entityViewBuildersCount; i++) + for (var i = 0; i < entityViewBuildersCount; i++) { - IEntityViewBuilder entityViewBuilder = entityViewBuilders[i]; - Type entityViewType = entityViewBuilder.GetEntityViewType(); + var entityViewBuilder = entityViewBuilders[i]; + var entityViewType = entityViewBuilder.GetEntityViewType(); - ITypeSafeList fromSafeList = dictionary[entityViewType]; + var fromSafeList = groupedEntities[entityViewType]; ITypeSafeList toSafeList; if (groupedEntityViewsTyped.TryGetValue(entityViewType, out toSafeList) == false) - { - toSafeList = fromSafeList.Create(); - } + groupedEntityViewsTyped[entityViewType] = toSafeList = fromSafeList.Create(); entityViewBuilder.MoveEntityView(entityID, fromSafeList, toSafeList); - if (fromSafeList.UnorderedRemove(entityID) == false) - dictionary.Remove(entityViewType); + fromSafeList.MappedRemove(entityID); } - if (dictionary.Count == 0) _groupEntityViewsDB.Remove(fromGroupID); + var entityInfoView = _DB.QueryEntityView(entityID); + entityInfoView.groupID = toGroupID; } - void InternalRemoveFromDBAndEngines(IEntityViewBuilder[] entityViewBuilders, int entityID, - Dictionary entityViewsDB, Dictionary entityViewsDBDic) + void InternalRemoveFromDBAndEngines(IEntityViewBuilder[] entityViewBuilders, int entityID, + Dictionary entityViewsDB, + Dictionary entityViewsDBDic) { - int entityViewBuildersCount = entityViewBuilders.Length; + var entityViewBuildersCount = entityViewBuilders.Length; - for (int i = 0; i < entityViewBuildersCount; i++) + for (var i = 0; i < entityViewBuildersCount; i++) { - Type entityViewType = entityViewBuilders[i].GetEntityViewType(); + var entityViewType = entityViewBuilders[i].GetEntityViewType(); InternalRemoveEntityViewFromDBAndEngines(entityViewsDB, entityViewsDBDic, entityViewType, entityID); } + + InternalRemoveEntityViewFromDBAndEngines(entityViewsDB, entityViewsDBDic, typeof(EntityInfoView), entityID); } - void InternalRemoveFromGroupAndDBAndEngines(IEntityViewBuilder[] entityViewBuilders, int entityID, int groupID, - Dictionary entityViewsDB, Dictionary entityViewsDBDic) + void InternalRemoveFromGroupAndDBAndEngines(IEntityViewBuilder[] entityViewBuilders, + int entityID, int groupID, + Dictionary entityViewsDB, + Dictionary entityViewsDBDic) { InternalRemoveFromGroupDB(entityViewBuilders, entityID, groupID); @@ -259,20 +287,22 @@ namespace Svelto.ECS void InternalRemoveFromGroupDB(IEntityViewBuilder[] entityViewBuilders, int entityID, int groupID) { - int entityViewBuildersCount = entityViewBuilders.Length; + var entityViewBuildersCount = entityViewBuilders.Length; - Dictionary dictionary = _groupEntityViewsDB[groupID]; + var dictionary = _groupEntityViewsDB[groupID]; - for (int i = 0; i < entityViewBuildersCount; i++) + for (var i = 0; i < entityViewBuildersCount; i++) { - Type entityViewType = entityViewBuilders[i].GetEntityViewType(); + var entityViewType = entityViewBuilders[i].GetEntityViewType(); - dictionary[entityViewType].UnorderedRemove(entityID); + var typeSafeList = dictionary[entityViewType]; + typeSafeList.MappedRemove(entityID); } } static void RemoveEntityViewFromEngines(Dictionary> entityViewEngines, - IEntityView entityView, Type entityViewType) + IEntityView entityView, + Type entityViewType) { FasterList enginesForEntityView; @@ -281,7 +311,7 @@ namespace Svelto.ECS int count; var fastList = FasterList.NoVirt.ToArrayFast(enginesForEntityView, out count); - for (int j = 0; j < count; j++) + for (var j = 0; j < count; j++) { #if ENGINE_PROFILER_ENABLED && UNITY_EDITOR EngineProfiler.MonitorRemoveDuration(fastList[j], entityView); @@ -294,7 +324,7 @@ namespace Svelto.ECS class GenericEntityFactory : IEntityFactory { - DataStructures.WeakReference _weakEngine; + readonly DataStructures.WeakReference _weakEngine; public GenericEntityFactory(DataStructures.WeakReference weakReference) { @@ -316,12 +346,14 @@ namespace Svelto.ECS _weakEngine.Target.BuildMetaEntity(metaEntityID, implementors); } - public void BuildEntityInGroup(int entityID, int groupID, object[] implementors) where T : IEntityDescriptor, new() + public void BuildEntityInGroup(int entityID, int groupID, object[] implementors) + where T : IEntityDescriptor, new() { _weakEngine.Target.BuildEntityInGroup(entityID, groupID, implementors); } - public void BuildEntityInGroup(int entityID, int groupID, IEntityDescriptorInfo entityDescriptor, object[] implementors) + public void BuildEntityInGroup(int entityID, int groupID, IEntityDescriptorInfo entityDescriptor, + object[] implementors) { _weakEngine.Target.BuildEntityInGroup(entityID, groupID, entityDescriptor, implementors); } @@ -334,6 +366,8 @@ namespace Svelto.ECS class GenericEntityFunctions : IEntityFunctions { + readonly DataStructures.WeakReference _weakReference; + public GenericEntityFunctions(DataStructures.WeakReference weakReference) { _weakReference = weakReference; @@ -358,39 +392,16 @@ namespace Svelto.ECS { _weakReference.Target.SwapEntityGroup(entityID, fromGroupID, toGroupID); } - - readonly DataStructures.WeakReference _weakReference; } - public void Dispose() - { - foreach (var entity in _entityViewsDB) - { - if (entity.Value.isQueryiableEntityView == true) - { - foreach (var entityView in entity.Value) - { - RemoveEntityViewFromEngines(_entityViewEngines, entityView as EntityView, entity.Key); - } - } - } - - foreach (var entity in _metaEntityViewsDB) - { - foreach (var entityView in entity.Value) - { - RemoveEntityViewFromEngines(_entityViewEngines, entityView as EntityView, entity.Key); - } - } - } - readonly EntityViewsDB _DB; - + readonly Dictionary _entityViewsDB; - readonly Dictionary _metaEntityViewsDB; + + readonly Dictionary _entityViewsDBDic; readonly Dictionary> _groupEntityViewsDB; - - readonly Dictionary _entityViewsDBDic; - readonly Dictionary _metaEntityViewsDBDic; + readonly Dictionary _metaEntityViewsDB; + readonly Dictionary _metaEntityViewsDBDic; + } } \ No newline at end of file diff --git a/Svelto.ECS/EntityDescriptor.cs b/Svelto.ECS/EntityDescriptor.cs index 6b1bc21..9ea0385 100644 --- a/Svelto.ECS/EntityDescriptor.cs +++ b/Svelto.ECS/EntityDescriptor.cs @@ -1,6 +1,7 @@ +using System; +using DesignByContract; using Svelto.DataStructures; using Svelto.ECS.Internal; -using System; namespace Svelto.ECS { @@ -8,20 +9,21 @@ namespace Svelto.ECS { IEntityViewBuilder[] entityViewsToBuild { get; } } - - public class EntityDescriptor:IEntityDescriptor + + public class EntityDescriptor : IEntityDescriptor { protected EntityDescriptor(IEntityViewBuilder[] entityViewsToBuild) { this.entityViewsToBuild = entityViewsToBuild; } - public IEntityViewBuilder[] entityViewsToBuild { get; private set; } + public IEntityViewBuilder[] entityViewsToBuild { get; } } public interface IEntityDescriptorInfo - {} - + { + } + public static class EntityDescriptorTemplate where TType : IEntityDescriptor, new() { public static readonly IEntityDescriptorInfo Default = new EntityDescriptorInfo(new TType()); @@ -31,16 +33,17 @@ namespace Svelto.ECS { public DynamicEntityDescriptorInfo(FasterList extraEntityViews) { - DesignByContract.Check.Require(extraEntityViews.Count > 0, "don't use a DynamicEntityDescriptorInfo if you don't need to use extra EntityViews"); - + Check.Require(extraEntityViews.Count > 0, + "don't use a DynamicEntityDescriptorInfo if you don't need to use extra EntityViews"); + var descriptor = new TType(); - int length = descriptor.entityViewsToBuild.Length; - + var length = descriptor.entityViewsToBuild.Length; + entityViewsToBuild = new IEntityViewBuilder[length + extraEntityViews.Count]; - + Array.Copy(descriptor.entityViewsToBuild, 0, entityViewsToBuild, 0, length); Array.Copy(extraEntityViews.ToArrayFast(), 0, entityViewsToBuild, length, extraEntityViews.Count); - + name = descriptor.ToString(); } } @@ -48,19 +51,19 @@ namespace Svelto.ECS namespace Svelto.ECS.Internal { - public class EntityDescriptorInfo:IEntityDescriptorInfo + public class EntityDescriptorInfo : IEntityDescriptorInfo { internal IEntityViewBuilder[] entityViewsToBuild; - internal string name; + internal string name; internal EntityDescriptorInfo(IEntityDescriptor descriptor) { - name = descriptor.ToString(); + name = descriptor.ToString(); entityViewsToBuild = descriptor.entityViewsToBuild; } protected EntityDescriptorInfo() - {} + { + } } -} - +} \ No newline at end of file diff --git a/Svelto.ECS/EntityFactory.cs b/Svelto.ECS/EntityFactory.cs index 78cba8a..5ce8640 100644 --- a/Svelto.ECS/EntityFactory.cs +++ b/Svelto.ECS/EntityFactory.cs @@ -2,17 +2,20 @@ using System; using System.Collections.Generic; using Svelto.DataStructures; using Svelto.Utilities; +using Console = Utility.Console; namespace Svelto.ECS.Internal { static class EntityFactory { - internal static void BuildGroupedEntityViews(int entityID, int groupID, + internal static void BuildGroupedEntityViews(int entityID, int groupID, Dictionary> groupEntityViewsByType, - IEntityDescriptorInfo eentityViewsToBuildDescriptor, - object[] implementors) + Dictionary entityViewsByType, + IEntityDescriptorInfo eentityViewsToBuildDescriptor, + object[] implementors) { - var entityViewsToBuildDescriptor = eentityViewsToBuildDescriptor as EntityDescriptorInfo; + var entityViewsToBuildDescriptor = + eentityViewsToBuildDescriptor as EntityDescriptorInfo; Dictionary groupedEntityViewsTyped; if (groupEntityViewsByType.TryGetValue(groupID, out groupedEntityViewsTyped) == false) @@ -22,51 +25,53 @@ namespace Svelto.ECS.Internal } InternalBuildEntityViews(entityID, groupedEntityViewsTyped, entityViewsToBuildDescriptor, implementors); - - EntityInfoView removeEntityView = new EntityInfoView(); - removeEntityView.groupID = groupID; - removeEntityView.isInAGroup = true; + var removeEntityView = EntityView.BuildEntityView(entityID); + + removeEntityView.groupID = groupID; + removeEntityView.isInAGroup = true; removeEntityView.entityViews = entityViewsToBuildDescriptor.entityViewsToBuild; - - AddEntityInfoView(groupEntityViewsByType[groupID], removeEntityView); + + AddEntityInfoView(entityViewsByType, removeEntityView); } - internal static void BuildEntityViews(int entityID, + internal static void BuildEntityViews(int entityID, Dictionary entityViewsByType, IEntityDescriptorInfo eentityViewsToBuildDescriptor, object[] implementors) { var entityViewsToBuildDescriptor = eentityViewsToBuildDescriptor as EntityDescriptorInfo; - + InternalBuildEntityViews(entityID, entityViewsByType, entityViewsToBuildDescriptor, implementors); - - EntityInfoView removeEntityView = new EntityInfoView(); + + var removeEntityView = EntityView.BuildEntityView(entityID); removeEntityView.entityViews = entityViewsToBuildDescriptor.entityViewsToBuild; - + AddEntityInfoView(entityViewsByType, removeEntityView); } - - static void AddEntityInfoView(Dictionary entityViewsByType, EntityInfoView removeEntityView) + + static void AddEntityInfoView(Dictionary entityViewsByType, + EntityInfoView removeEntityView) { ITypeSafeList list; - + if (entityViewsByType.TryGetValue(typeof(EntityInfoView), out list) == false) - list = entityViewsByType[typeof(EntityInfoView)] = new TypeSafeFasterListForECSForClasses(); - + list = entityViewsByType[typeof(EntityInfoView)] = + new TypeSafeFasterListForECSForClasses(); + (list as TypeSafeFasterListForECSForClasses).Add(removeEntityView); } - static void InternalBuildEntityViews(int entityID, - Dictionary entityViewsByType, - IEntityDescriptorInfo eentityViewsToBuildDescriptor, + static void InternalBuildEntityViews(int entityID, + Dictionary entityViewsByType, + IEntityDescriptorInfo eentityViewsToBuildDescriptor, object[] implementors) { var entityViewsToBuildDescriptor = eentityViewsToBuildDescriptor as EntityDescriptorInfo; var entityViewsToBuild = entityViewsToBuildDescriptor.entityViewsToBuild; - int count = entityViewsToBuild.Length; + var count = entityViewsToBuild.Length; - for (int index = 0; index < count; index++) + for (var index = 0; index < count; index++) { var entityViewBuilder = entityViewsToBuild[index]; var entityViewType = entityViewBuilder.GetEntityViewType(); @@ -74,12 +79,10 @@ namespace Svelto.ECS.Internal var entityViewObjectToFill = BuildEntityView(entityID, entityViewsByType, entityViewType, entityViewBuilder); - if (entityViewBuilder.mustBeFilled == true) - { + if (entityViewBuilder.mustBeFilled) FillEntityView(entityViewObjectToFill as EntityView - ,implementors - ,entityViewsToBuildDescriptor.name); - } + , implementors + , entityViewsToBuildDescriptor.name); } } @@ -106,24 +109,26 @@ namespace Svelto.ECS.Internal //this is used to avoid newing a dictionary every time, but it's used locally only and it's clearead for each use #if DEBUG && !PROFILER - static readonly Dictionary> implementorsByType = new Dictionary>(); + static readonly Dictionary> implementorsByType = + new Dictionary>(); #else static readonly Dictionary implementorsByType = new Dictionary(); #endif static void FillEntityView(EntityView entityView - , object[] implementors - , string entityDescriptorName) + , object[] implementors + , string entityDescriptorName) { int count; //Very efficent way to collect the fields of every EntityViewType - KeyValuePair>[] setters = - FasterList>>.NoVirt.ToArrayFast(entityView.entityViewBlazingFastReflection, out count); + var setters = + FasterList>> + .NoVirt.ToArrayFast(entityView.entityViewBlazingFastReflection, out count); if (count == 0) return; - - for (int index = 0; index < implementors.Length; index++) + + for (var index = 0; index < implementors.Length; index++) { var implementor = implementors[index]; @@ -133,15 +138,15 @@ namespace Svelto.ECS.Internal Type[] interfaces; if (_cachedTypes.TryGetValue(type, out interfaces) == false) - interfaces = _cachedTypes[type] = type.GetInterfacesEx(); + interfaces = _cachedTypes[type] = type.GetInterfacesEx(); - for (int iindex = 0; iindex < interfaces.Length; iindex++) + for (var iindex = 0; iindex < interfaces.Length; iindex++) { var componentType = interfaces[iindex]; #if DEBUG && !PROFILER Tuple implementorHolder; - if (implementorsByType.TryGetValue(componentType, out implementorHolder) == true) + if (implementorsByType.TryGetValue(componentType, out implementorHolder)) implementorHolder.numberOfImplementations++; else implementorsByType[componentType] = new Tuple(implementor, 1); @@ -152,39 +157,44 @@ namespace Svelto.ECS.Internal } #if DEBUG && !PROFILER else - Utility.Console.LogError(NULL_IMPLEMENTOR_ERROR.FastConcat(entityView.ToString())); + { + Console.LogError(NULL_IMPLEMENTOR_ERROR.FastConcat(entityView.ToString())); + } #endif } - for (int i = 0; i < count; i++) + for (var i = 0; i < count; i++) { - var fieldSetter = setters[i]; - Type fieldType = fieldSetter.Key; - + var fieldSetter = setters[i]; + var fieldType = fieldSetter.Key; + #if DEBUG && !PROFILER - Tuple component; + Tuple component; #else object component; #endif - if (implementorsByType.TryGetValue(fieldType, out component) == false) - { - Exception e = new Exception(NOT_FOUND_EXCEPTION + " Component Type: " + fieldType.Name + " - EntityView: " + - entityView.GetType().Name + " - EntityDescriptor " + entityDescriptorName); + if (implementorsByType.TryGetValue(fieldType, out component) == false) + { + var e = new Exception(NOT_FOUND_EXCEPTION + " Component Type: " + fieldType.Name + + " - EntityView: " + + entityView.GetType().Name + " - EntityDescriptor " + entityDescriptorName); - throw e; - } + throw e; + } #if DEBUG && !PROFILER - if (component.numberOfImplementations > 1) - Utility.Console.LogError(DUPLICATE_IMPLEMENTOR_ERROR.FastConcat( - "Component Type: ", fieldType.Name, " implementor: ", - component.implementorType.ToString()) + " - EntityView: " + - entityView.GetType().Name + " - EntityDescriptor " + entityDescriptorName); + if (component.numberOfImplementations > 1) + Console.LogError(DUPLICATE_IMPLEMENTOR_ERROR.FastConcat( + "Component Type: ", fieldType.Name, + " implementor: ", + component.implementorType.ToString()) + + " - EntityView: " + + entityView.GetType().Name + " - EntityDescriptor " + entityDescriptorName); #endif #if DEBUG && !PROFILER - fieldSetter.Value.Call(entityView, component.implementorType); + fieldSetter.Value.Call(entityView, component.implementorType); #else - keyValuePair.Value.Call(entityView, component); + fieldSetter.Value.Call(entityView, component); #endif } @@ -193,17 +203,17 @@ namespace Svelto.ECS.Internal #if DEBUG && !PROFILER struct Tuple { - public T1 implementorType; - public T2 numberOfImplementations; + public readonly T1 implementorType; + public T2 numberOfImplementations; public Tuple(T1 implementor, T2 v) { - implementorType = implementor; + implementorType = implementor; numberOfImplementations = v; } } -#endif - static Dictionary _cachedTypes = new Dictionary(); +#endif + static readonly Dictionary _cachedTypes = new Dictionary(); const string DUPLICATE_IMPLEMENTOR_ERROR = "Svelto.ECS the same component is implemented with more than one implementor. This is considered an error and MUST be fixed. "; diff --git a/Svelto.ECS/EntityInfoImplementor.cs b/Svelto.ECS/EntityInfoImplementor.cs index fd47890..81d09c1 100644 --- a/Svelto.ECS/EntityInfoImplementor.cs +++ b/Svelto.ECS/EntityInfoImplementor.cs @@ -3,8 +3,7 @@ class EntityInfoView : EntityView { internal IEntityViewBuilder[] entityViews; - internal int groupID; - internal bool isInAGroup; + internal int groupID; + internal bool isInAGroup; } -} - +} \ No newline at end of file diff --git a/Svelto.ECS/EntitySubmissionScheduler.cs b/Svelto.ECS/EntitySubmissionScheduler.cs index cfa8168..09335fd 100644 --- a/Svelto.ECS/EntitySubmissionScheduler.cs +++ b/Svelto.ECS/EntitySubmissionScheduler.cs @@ -4,6 +4,6 @@ namespace Svelto.ECS.Schedulers { public abstract class EntitySubmissionScheduler { - abstract public void Schedule(WeakAction submitEntityViews); + public abstract void Schedule(WeakAction submitEntityViews); } } \ No newline at end of file diff --git a/Svelto.ECS/Experimental/StructNodeCollections.cs b/Svelto.ECS/Experimental/StructNodeCollections.cs index 1b81938..f09b605 100644 --- a/Svelto.ECS/Experimental/StructNodeCollections.cs +++ b/Svelto.ECS/Experimental/StructNodeCollections.cs @@ -79,7 +79,8 @@ namespace Svelto.ECS.Experimental { T convert = (T)entityView; - var fasterList = (SharedGroupedStructEntityViewsLists.NoVirt.GetList(_container, groupID) as FasterList); + var fasterList = + (SharedGroupedStructEntityViewsLists.NoVirt.GetList(_container, groupID) as FasterList); indices[entityView.ID] = fasterList.Count; fasterList.Add(convert); @@ -87,7 +88,8 @@ namespace Svelto.ECS.Experimental public void Remove(int groupID, T entityView) { - var fasterList = (SharedGroupedStructEntityViewsLists.NoVirt.GetList(_container, groupID) as FasterList); + var fasterList = + (SharedGroupedStructEntityViewsLists.NoVirt.GetList(_container, groupID) as FasterList); var index = indices[entityView.ID]; indices.Remove(entityView.ID); @@ -97,7 +99,8 @@ namespace Svelto.ECS.Experimental public T[] GetList(int groupID, out int numberOfItems) { - var fasterList = (SharedGroupedStructEntityViewsLists.NoVirt.GetList(_container, groupID) as FasterList); + var fasterList = + (SharedGroupedStructEntityViewsLists.NoVirt.GetList(_container, groupID) as FasterList); return FasterList.NoVirt.ToArrayFast(fasterList, out numberOfItems); } diff --git a/Svelto.ECS/IEngine.cs b/Svelto.ECS/IEngine.cs index 7cca317..e482ed5 100644 --- a/Svelto.ECS/IEngine.cs +++ b/Svelto.ECS/IEngine.cs @@ -2,7 +2,7 @@ namespace Svelto.ECS.Internal { public interface IHandleEntityViewEngine : IEngine { - void Add(IEntityView entityView); + void Add(IEntityView entityView); void Remove(IEntityView entityView); } } @@ -10,5 +10,6 @@ namespace Svelto.ECS.Internal namespace Svelto.ECS { public interface IEngine - {} -} + { + } +} \ No newline at end of file diff --git a/Svelto.ECS/IEntityDescriptorHolder.cs b/Svelto.ECS/IEntityDescriptorHolder.cs index c144811..1971d25 100644 --- a/Svelto.ECS/IEntityDescriptorHolder.cs +++ b/Svelto.ECS/IEntityDescriptorHolder.cs @@ -4,4 +4,4 @@ namespace Svelto.ECS { IEntityDescriptorInfo RetrieveDescriptor(); } -} +} \ No newline at end of file diff --git a/Svelto.ECS/IEntityViewsDB.cs b/Svelto.ECS/IEntityViewsDB.cs index 35e7f32..581b698 100644 --- a/Svelto.ECS/IEntityViewsDB.cs +++ b/Svelto.ECS/IEntityViewsDB.cs @@ -4,21 +4,20 @@ namespace Svelto.ECS { public interface IEntityViewsDB { - FasterReadOnlyList QueryEntityViews() where T:EntityView; - FasterReadOnlyList QueryMetaEntityViews() where T: EntityView; - FasterReadOnlyList QueryGroupedEntityViews(int group) where T: EntityView; - - T[] QueryEntityViewsAsArray(out int count) where T: IEntityView; - T[] QueryGroupedEntityViewsAsArray(int @group, out int count) where T: IEntityView; - - ReadOnlyDictionary QueryIndexableEntityViews() where T: EntityView; - ReadOnlyDictionary QueryIndexableMetaEntityViews() where T: EntityView; - + FasterReadOnlyList QueryEntityViews() where T : EntityView; + FasterReadOnlyList QueryMetaEntityViews() where T : EntityView; + FasterReadOnlyList QueryGroupedEntityViews(int group) where T : EntityView; + + T[] QueryEntityViewsAsArray(out int count) where T : IEntityView; + T[] QueryGroupedEntityViewsAsArray(int group, out int count) where T : IEntityView; + + ReadOnlyDictionary QueryIndexableEntityViews() where T : EntityView; + ReadOnlyDictionary QueryIndexableMetaEntityViews() where T : EntityView; + bool TryQueryEntityView(int ID, out T entityView) where T : EntityView; - T QueryEntityView(int ID) where T: EntityView; + T QueryEntityView(int ID) where T : EntityView; - bool TryQueryMetaEntityView(int metaEntityID, out T entityView) where T: EntityView; - T QueryMetaEntityView(int metaEntityID) where T: EntityView; + bool TryQueryMetaEntityView(int metaEntityID, out T entityView) where T : EntityView; + T QueryMetaEntityView(int metaEntityID) where T : EntityView; } -} - +} \ No newline at end of file diff --git a/Svelto.ECS/MultiEntityViewsEngine.cs b/Svelto.ECS/MultiEntityViewsEngine.cs index 324bc36..5ea53d8 100644 --- a/Svelto.ECS/MultiEntityViewsEngine.cs +++ b/Svelto.ECS/MultiEntityViewsEngine.cs @@ -2,11 +2,8 @@ using Svelto.ECS.Internal; namespace Svelto.ECS.Internal { - public abstract class MultiEntityViewsEngine:IHandleEntityViewEngine where T:EntityView, new() + public abstract class MultiEntityViewsEngine : IHandleEntityViewEngine where T : EntityView, new() { - protected abstract void Add(T entityView); - protected abstract void Remove(T entityView); - public virtual void Add(IEntityView entityView) { Add((T) entityView); @@ -16,56 +13,49 @@ namespace Svelto.ECS.Internal { Remove((T) entityView); } + + protected abstract void Add(T entityView); + protected abstract void Remove(T entityView); } } namespace Svelto.ECS { public abstract class MultiEntityViewsEngine : MultiEntityViewsEngine - where U:EntityView, new() where T : EntityView, new() + where U : EntityView, new() where T : EntityView, new() { - protected abstract void Add(U entityView); + protected abstract void Add(U entityView); protected abstract void Remove(U entityView); public override void Add(IEntityView entityView) { var castedEntityView = entityView as U; if (castedEntityView != null) - { Add(castedEntityView); - } else - { base.Add(entityView); - } } public override void Remove(IEntityView entityView) { if (entityView is U) - { Remove((U) entityView); - } else - { base.Remove(entityView); - } } } public abstract class MultiEntityViewsEngine : MultiEntityViewsEngine where V : EntityView, new() where U : EntityView, new() where T : EntityView, new() { - protected abstract void Add(V entityView); + protected abstract void Add(V entityView); protected abstract void Remove(V entityView); public override void Add(IEntityView entityView) { var castedEntityView = entityView as V; if (castedEntityView != null) - { Add(castedEntityView); - } else base.Add(entityView); } @@ -74,32 +64,28 @@ namespace Svelto.ECS { var castedEntityView = entityView as V; if (castedEntityView != null) - { Remove(castedEntityView); - } else base.Remove(entityView); } } - + /// - /// Please do not add more MultiEntityViewsEngine - /// if you use more than 4 nodes, your engine has - /// already too many responsabilities. + /// Please do not add more MultiEntityViewsEngine + /// if you use more than 4 nodes, your engine has + /// already too many responsabilities. /// public abstract class MultiEntityViewsEngine : MultiEntityViewsEngine where W : EntityView, new() where V : EntityView, new() where U : EntityView, new() where T : EntityView, new() { - protected abstract void Add(W entityView); + protected abstract void Add(W entityView); protected abstract void Remove(W entityView); public override void Add(IEntityView entityView) { var castedEntityView = entityView as W; if (castedEntityView != null) - { Add(castedEntityView); - } else base.Add(entityView); } @@ -108,9 +94,7 @@ namespace Svelto.ECS { var castedEntityView = entityView as W; if (castedEntityView != null) - { Remove(castedEntityView); - } else base.Remove(entityView); } diff --git a/Svelto.ECS/Profiler/Editor/EngineProfiler/EngineProfilerInspector.cs b/Svelto.ECS/Profiler/Editor/EngineProfiler/EngineProfilerInspector.cs index 0947e8a..ae9f263 100644 --- a/Svelto.ECS/Profiler/Editor/EngineProfiler/EngineProfilerInspector.cs +++ b/Svelto.ECS/Profiler/Editor/EngineProfiler/EngineProfilerInspector.cs @@ -1,5 +1,4 @@ #if UNITY_EDITOR - using System; using UnityEditor; using UnityEngine; diff --git a/Svelto.ECS/Profiler/EngineProfiler.cs b/Svelto.ECS/Profiler/EngineProfiler.cs index a74333b..4dc5ae4 100644 --- a/Svelto.ECS/Profiler/EngineProfiler.cs +++ b/Svelto.ECS/Profiler/EngineProfiler.cs @@ -12,6 +12,8 @@ namespace Svelto.ECS.Profiler { static readonly Stopwatch _stopwatch = new Stopwatch(); + public static readonly Dictionary engineInfos = new Dictionary(); + public static void MonitorAddDuration(IHandleEntityViewEngine engine, IEntityView entityView) { EngineInfo info; @@ -42,19 +44,12 @@ namespace Svelto.ECS.Profiler public static void AddEngine(IEngine engine) { if (engineInfos.ContainsKey(engine.GetType()) == false) - { engineInfos.Add(engine.GetType(), new EngineInfo(engine)); - } } public static void ResetDurations() { - foreach (var engine in engineInfos) - { - engine.Value.ResetDurations(); - } + foreach (var engine in engineInfos) engine.Value.ResetDurations(); } - - public static readonly Dictionary engineInfos = new Dictionary(); } -} +} \ No newline at end of file diff --git a/Svelto.ECS/SingleEntityViewEngine.cs b/Svelto.ECS/SingleEntityViewEngine.cs index 605f775..683257d 100644 --- a/Svelto.ECS/SingleEntityViewEngine.cs +++ b/Svelto.ECS/SingleEntityViewEngine.cs @@ -2,19 +2,19 @@ using Svelto.ECS.Internal; namespace Svelto.ECS { - public abstract class SingleEntityViewEngine : IHandleEntityViewEngine where T:EntityView, new() + public abstract class SingleEntityViewEngine : IHandleEntityViewEngine where T : EntityView, new() { public void Add(IEntityView entityView) { - Add((T)entityView); //when byref returns will be vailable, this should be passed by reference, not copy! + Add((T) entityView); //when byref returns will be vailable, this should be passed by reference, not copy! } public void Remove(IEntityView entityView) { - Remove((T)entityView); + Remove((T) entityView); } - protected abstract void Add(T entityView); + protected abstract void Add(T entityView); protected abstract void Remove(T entityView); } -} +} \ No newline at end of file