Example #1
0
        public void StartFill(Entity[] entities)
        {
            int n = entities.Length;
            int count = 1;
            while (count <= n)
            {
                count = count << 1;
            }
            nstart = count - 1;
            count = (count << 1) - 1;
            heap = new Entity[count];

            entities.CopyTo(this.heap, nstart);
            Entity inf = new Entity() { T = float.PositiveInfinity };
            for (int i = nstart + n; i < count; ++i)
            {
                this.heap[i] = inf;
            }

            int count_ = count;
            do
            {
                for (int i = count_ >> 1; i < count_; i += 2)
                {
                    heap[(i - 1) >> 1] = heap[i].T < heap[i + 1].T ? heap[i] : heap[i + 1];
                }
                count_ = count_ >> 1;
            } while ((count_ >> 1) > 0);

            this.isBuild = true;
        }
 /// Creates a new entity and adds copies of all
 /// specified components to it.
 /// If replaceExisting is true it will replace exisintg components.
 public static Entity CloneEntity(this Context context,
                                  Entity entity,
                                  bool replaceExisting = false,
                                  params int[] indices)
 {
     var target = context.CreateEntity();
     entity.CopyTo(target, replaceExisting, indices);
     return target;
 }