示例#1
0
        public static void Copy <T, TCopy>(ME.ECS.Collections.BufferArray <T> fromArr, ref ME.ECS.Collections.BufferArray <T> arr, TCopy copy) where TCopy : IArrayElementCopy <T>
        {
            if (fromArr.arr == null)
            {
                if (arr.arr != null)
                {
                    for (int i = 0; i < arr.Length; ++i)
                    {
                        copy.Recycle(arr.arr[i]);
                    }
                    PoolArray <T> .Recycle(ref arr);
                }
                arr = BufferArray <T> .Empty;
                return;
            }

            if (arr.arr == null || fromArr.Length != arr.Length)
            {
                if (arr.arr != null)
                {
                    PoolArray <T> .Recycle(ref arr);
                }
                arr = PoolArray <T> .Spawn(fromArr.Length);
            }

            for (int i = 0; i < fromArr.Length; ++i)
            {
                copy.Copy(fromArr.arr[i], ref arr.arr[i]);
            }
        }
示例#2
0
        public override void Update(ME.ECS.Collections.BufferArray <Views> list, float deltaTime, bool hasChanged)
        {
            if (this.world.settings.useJobsForViews == true && this.world.settings.viewsSettings.unityNoViewProviderDisableJobs == false)
            {
                NoViewProvider.currentList = list;

                var job = new Job()
                {
                    deltaTime = deltaTime
                };
                var handle = job.Schedule(list.Length, 16);
                handle.Complete();
            }
            else
            {
                for (int j = 0; j < list.Length; ++j)
                {
                    var item = list.arr[j];
                    for (int i = 0, count = item.Length; i < count; ++i)
                    {
                        var instance = item[i] as NoView;
                        if (instance == null)
                        {
                            continue;
                        }

                        instance.ApplyStateJob(deltaTime, immediately: false);
                    }
                }
            }
        }
示例#3
0
        public static void Recycle <T, TCopy>(ref ME.ECS.Collections.BufferArray <T> item, TCopy copy) where TCopy : IArrayElementCopy <T>
        {
            for (int i = 0; i < item.Length; ++i)
            {
                copy.Recycle(item.arr[i]);
            }

            PoolArray <T> .Recycle(ref item);
        }
示例#4
0
        public void Push(World world, ME.ECS.Collections.BufferArray <Entity> arr)
        {
            var reg = (StructComponents <T>)world.currentState.structComponents.list.arr[WorldUtilities.GetAllComponentTypeId <T>()];

            for (int i = 0; i < arr.Length; ++i)
            {
                var entity = arr.arr[i];
                reg.components.arr[entity.id]       = this.Get(entity.id);
                reg.componentsStates.arr[entity.id] = 1;
            }
        }
示例#5
0
        public DataBuffer(World world, ME.ECS.Collections.BufferArray <Entity> arr)
        {
            var reg = (StructComponents <T>)world.currentState.structComponents.list.arr[WorldUtilities.GetAllComponentTypeId <T>()];

            this.minIdx = 0;
            var maxIdx = reg.components.Length;

            for (int i = 0; i < arr.Length; ++i)
            {
                var entity = arr.arr[i];
                if (this.minIdx > entity.id)
                {
                    this.minIdx = entity.id;
                }
                if (maxIdx < entity.id)
                {
                    maxIdx = entity.id;
                }
            }

            this.data = new System.Span <T>(reg.components.arr, this.minIdx, maxIdx);
        }
示例#6
0
 public abstract void Update(ME.ECS.Collections.BufferArray <Views> list, float deltaTime, bool hasChanged);