diff --git a/EnginesRoot.Engines.cs b/EnginesRoot.Engines.cs index 8438e5b..9d7a31d 100644 --- a/EnginesRoot.Engines.cs +++ b/EnginesRoot.Engines.cs @@ -34,6 +34,7 @@ namespace Svelto.ECS public EnginesRoot(IEntitySubmissionScheduler entityViewScheduler) { _entitiesOperations = new FasterDictionary(); + serializationDescriptorMap = new SerializationDescriptorMap(); _reactiveEnginesAddRemove = new FasterDictionary, FasterList>(); _reactiveEnginesSwap = new FasterDictionary, FasterList>(); _enginesSet = new FasterList(); diff --git a/Serialization/EntitiesDB.DescriptorMap.cs b/Serialization/EntitiesDB.DescriptorMap.cs index 6e23c57..297f793 100644 --- a/Serialization/EntitiesDB.DescriptorMap.cs +++ b/Serialization/EntitiesDB.DescriptorMap.cs @@ -10,10 +10,7 @@ namespace Svelto.ECS sealed class SerializationDescriptorMap { /// - /// Here we want to register all the EntityDescriptors that need to be serialized for network play. - /// - /// Remember! This needs to in sync across different clients and server as the values are serialized across - /// the network also want this to not change so we can save to a DB + /// Use reflection to register all the ISerializableEntityDescriptor to be used for serialization /// internal SerializationDescriptorMap() { @@ -25,8 +22,8 @@ namespace Svelto.ECS { foreach (Type type in GetTypesSafe(assembly)) { - if (type != null && type.IsClass && type.GetConstructor(Type.EmptyTypes) != null && - typeof(ISerializableEntityDescriptor).IsAssignableFrom(type)) + if (type != null && type.IsClass && type.IsAbstract == false && type.BaseType != null && type.BaseType.IsGenericType && + type.BaseType.GetGenericTypeDefinition() == typeof(SerializableEntityDescriptor<>)) { var descriptor = Activator.CreateInstance(type) as ISerializableEntityDescriptor; @@ -91,7 +88,6 @@ namespace Svelto.ECS _factories.Add(SerializationEntityDescriptorTemplate.hash, deserializationFactory); } - readonly Dictionary _descriptors; readonly Dictionary _factories; } @@ -100,6 +96,6 @@ namespace Svelto.ECS /// The map of serializable entity hashes to the serializable entity builders (to know the entity structs /// to serialize) /// - SerializationDescriptorMap serializationDescriptorMap { get; } = new SerializationDescriptorMap(); + SerializationDescriptorMap serializationDescriptorMap { get; } } } diff --git a/package.json b/package.json index 8c71913..51e1e52 100644 --- a/package.json +++ b/package.json @@ -3,13 +3,13 @@ "category": "Svelto", "description": "Svelto ECS C# Lightweight Data Oriented Entity Component System Framework", "dependencies": { - "com.sebaslab.svelto.common": "2.9.7" + "com.sebaslab.svelto.common": "2.9.9" }, "keywords": [ "svelto" ], "name": "com.sebaslab.svelto.ecs", "unity": "2019.2", - "version": "2.9.9", + "version": "2.9.10", "type": "framework" } \ No newline at end of file