Beispiel #1
0
 public unsafe ChunkDataManager(Archetype archetype)
 {
     Archetype              = archetype;
     componentsCount        = archetype.Components.Count;
     managedComponentsCount = archetype.ManagedComponents.Count;
     //componentData = new byte[archetype.Components.Count][];
     componentData        = new byte *[componentsCount];
     managedComponentData = new object?[managedComponentsCount][];
 }
Beispiel #2
0
        public static void ForEach <T>(this Archetype archetype, Action <IChunkDataIterator, int, int, ComponentDataAccess <T> > process) where T : unmanaged, IComponentData
        {
            var entityManager = archetype.EntityManager;
            var iterator      = entityManager.ArchetypeIterator(archetype);

            foreach (var itr in iterator)
            {
                var access = itr.DataAccess <T>();
                process(itr, 0, itr.Length, access);
            }
        }
Beispiel #3
0
        public static void ForEach <T1, T2>(this Archetype archetype,
                                            System.Action <IChunkDataIterator, int, int, ComponentDataAccess <T1>, ComponentDataAccess <T2> > process)
            where T1 : unmanaged, IComponentData
            where T2 : unmanaged, IComponentData
        {
            var entityManager = archetype.EntityManager;
            var iterator      = entityManager.ArchetypeIterator(archetype);

            foreach (var itr in iterator)
            {
                process(itr, 0, itr.Length, itr.DataAccess <T1>(), itr.DataAccess <T2>());
            }
        }
Beispiel #4
0
        public static void ParallelForEach <T1>(this Archetype archetype,
                                                Action <IChunkDataIterator, int, int, ComponentDataAccess <T1> > process)
            where T1 : unmanaged, IComponentData
        {
            var entityManager = archetype.EntityManager;
            var iterator      = entityManager.ArchetypeIterator(archetype);

            foreach (var itr in iterator)
            {
                var a1 = itr.DataAccess <T1>();
                RunThreads(0, itr.Length, (s, e) => process(itr, s, e, a1));
            }
        }