using Svelto.Common; using Svelto.DataStructures; using Svelto.ECS.Internal; namespace Svelto.ECS { interface IFiller { void FillFromByteArray(EntityInitializer init, NativeBag buffer); } class Filler : IFiller where T : struct, _IInternalEntityComponent { static Filler() { DBC.ECS.Check.Require(TypeCache.isUnmanaged == true, "invalid type used"); } //it's an internal interface public void FillFromByteArray(EntityInitializer init, NativeBag buffer) { var component = buffer.Dequeue(); init.Init(component); } } #if UNITY_NATIVE //at the moment I am still considering NativeOperations useful only for Unity static class EntityComponentIDMap { static readonly Svelto.DataStructures.FasterList TYPE_IDS; static EntityComponentIDMap() { TYPE_IDS = new Svelto.DataStructures.FasterList(); } internal static void Register(IFiller entityBuilder) where T : struct, _IInternalEntityComponent { ComponentID location = ComponentTypeID.id; TYPE_IDS.AddAt(location, entityBuilder); } internal static IFiller GetBuilderFromID(uint typeId) { return TYPE_IDS[typeId]; } } #endif }