Mirror of Svelto.ECS because we're a fan of it
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
1.3KB

  1. using System.Collections.Generic;
  2. using Svelto.Common;
  3. namespace Svelto.ECS.Serialization
  4. {
  5. public class DefaultVersioningFactory<T> : IDeserializationFactory where T : IEntityDescriptor, new()
  6. {
  7. readonly IEnumerable<object> _implementors;
  8. public DefaultVersioningFactory() {}
  9. public DefaultVersioningFactory(IEnumerable<object> implementors)
  10. {
  11. _implementors = implementors;
  12. }
  13. public EntityComponentInitializer BuildDeserializedEntity
  14. (EGID egid, ISerializationData serializationData, ISerializableEntityDescriptor entityDescriptor
  15. , int serializationType, IEntitySerialization entitySerialization, IEntityFactory factory
  16. , bool enginesRootIsDeserializationOnly)
  17. {
  18. var entityDescriptorEntitiesToSerialize = enginesRootIsDeserializationOnly ? entityDescriptor.entitiesToSerialize : entityDescriptor.componentsToBuild;
  19. var initializer = factory.BuildEntity(egid, entityDescriptorEntitiesToSerialize, TypeCache<T>.type, _implementors);
  20. entitySerialization.DeserializeEntityComponents(serializationData, entityDescriptor, ref initializer
  21. , serializationType);
  22. return initializer;
  23. }
  24. }
  25. }