com.badlogic.ashley.utils.ImmutableArray Java Examples

The following examples show how to use com.badlogic.ashley.utils.ImmutableArray. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WorldRenderer.java    From xibalba with MIT License 6 votes vote down vote up
private void renderItems() {
  ImmutableArray<Entity> entities =
      WorldManager.engine.getEntitiesFor(
          Family.all(ItemComponent.class, PositionComponent.class, VisualComponent.class).get()
      );

  for (Entity entity : entities) {
    PositionComponent position = ComponentMappers.position.get(entity);

    if (Main.tweenManager.getRunningTimelinesCount() == 0) {
      WorldManager.entityHelpers.updateSprite(entity, position.pos.x, position.pos.y);
    }

    if (WorldManager.entityHelpers.isVisible(entity)) {
      ComponentMappers.visual.get(entity).sprite.draw(batch);
    }
  }
}
 
Example #2
Source File: SystemManagerTests.java    From ashley with Apache License 2.0 6 votes vote down vote up
@Test
public void systemUpdateOrder () {
	Array<Integer> updates = new Array<Integer>();

	SystemListenerSpy systemSpy = new SystemListenerSpy();
	SystemManager manager = new SystemManager(systemSpy);
	EntitySystemMock system1 = new EntitySystemMockA(updates);
	EntitySystemMock system2 = new EntitySystemMockB(updates);

	system1.priority = 2;
	system2.priority = 1;

	manager.addSystem(system1);
	manager.addSystem(system2);

	ImmutableArray<EntitySystem> systems = manager.getSystems();
	assertEquals(system2, systems.get(0));
	assertEquals(system1, systems.get(1));
}
 
Example #3
Source File: IntervalIteratingTest.java    From ashley with Apache License 2.0 6 votes vote down vote up
@Test
public void intervalSystem () {
	Engine engine = new Engine();
	IntervalIteratingSystemSpy intervalSystemSpy = new IntervalIteratingSystemSpy();
	ImmutableArray<Entity> entities = engine.getEntitiesFor(Family.all(IntervalComponentSpy.class).get());
	ComponentMapper<IntervalComponentSpy> im = ComponentMapper.getFor(IntervalComponentSpy.class);

	engine.addSystem(intervalSystemSpy);

	for (int i = 0; i < 10; ++i) {
		Entity entity = new Entity();
		entity.add(new IntervalComponentSpy());
		engine.addEntity(entity);
	}

	for (int i = 1; i <= 10; ++i) {
		engine.update(deltaTime);

		for (int j = 0; j < entities.size(); ++j) {
			assertEquals(i / 2, im.get(entities.get(j)).numUpdates);
		}
	}
}
 
Example #4
Source File: GameSaver.java    From StockSimulator with GNU General Public License v2.0 6 votes vote down vote up
public String saveToJson() {
    gameState.stopThread();
    try {
        ImmutableArray<Entity> entities = gameState.getEntityEngine().getEntities();
        SavedGame savedGame = new SavedGame();
        for (Entity entity : entities) {
            List<ComponentContainer> componentContainers = new ArrayList<ComponentContainer>();
            for (Component c : entity.getComponents()) {
                componentContainers.add(new ComponentContainer(c));
            }
            EntityContainer entityContainer = new EntityContainer(entity.getId(), entity.getClass().getName(), componentContainers);
            savedGame.entitiesContainers.add(entityContainer);

        }

        return new GsonBuilder().enableComplexMapKeySerialization().create().toJson(savedGame);
    } catch (Exception e) {
        e.printStackTrace();
    }
    gameState.startThread();
    return "Failed";
}
 
Example #5
Source File: EngineTests.java    From ashley with Apache License 2.0 6 votes vote down vote up
@Test
public void entityForFamilyWithRemoval () {
	// Test for issue #13
	Engine engine = new Engine();

	Entity entity = new Entity();
	entity.add(new ComponentA());

	engine.addEntity(entity);

	ImmutableArray<Entity> entities = engine.getEntitiesFor(Family.all(ComponentA.class).get());

	assertEquals(1, entities.size());
	assertTrue(entities.contains(entity, true));

	engine.removeEntity(entity);

	assertEquals(0, entities.size());
	assertFalse(entities.contains(entity, true));
}
 
Example #6
Source File: GameState.java    From StockSimulator with GNU General Public License v2.0 6 votes vote down vote up
public void printMarketHistory() {
    Family market = Family.all(MarketItemComponent.class, PriceComponent.class, NameComponent.class, PriceHistoryComponent.class).get();
    ImmutableArray<Entity> entities = entityEngine.getEntitiesFor(market);

    System.out.println("Current Prices: ");
    for (Entity e : entities) {
        PriceComponent p = e.getComponent(PriceComponent.class);
        NameComponent n = e.getComponent(NameComponent.class);
        PriceHistoryComponent history = e.getComponent(PriceHistoryComponent.class);

        Iterator itr;

        System.out.print(n.name + " Resolution 1 \n");
        itr = history.getPriceHistory().iterator();
        while (itr.hasNext()) System.out.print((Integer) itr.next() + "\n");
        System.out.print(n.name + " Resolution 5\n");
        itr = history.getPriceHistorySkipFive().iterator();
        while (itr.hasNext()) System.out.print((Integer) itr.next() + "\n");

        System.out.print(n.name + " Resolution 15\n");
        itr = history.getPriceHistorySkipFifteen().iterator();
        while (itr.hasNext()) System.out.print((Integer) itr.next() + "\n");

    }

}
 
Example #7
Source File: GameState.java    From StockSimulator with GNU General Public License v2.0 6 votes vote down vote up
public void printUserData() {
    Family market = Family.all(MarketItemComponent.class, PriceComponent.class, NameComponent.class, PriceHistoryComponent.class).get();
    ImmutableArray<Entity> marketItemEntities = entityEngine.getEntitiesFor(market);

    Family players = Family.all(WalletComponent.class, NameComponent.class, InventoryComponent.class).get();
    for (Entity player : entityEngine.getEntitiesFor(players)) {
        NameComponent nc = player.getComponent(NameComponent.class);
        WalletComponent wc = player.getComponent(WalletComponent.class);
        InventoryComponent ic = player.getComponent(InventoryComponent.class);
        System.out.println("Name: " + nc.name);
        ic.printInventory(marketItemEntities);
        long value = ic.getInventoryValue(marketItemEntities);
        System.out.println("Inventory Value: $" + value);
        System.out.println(" Wallet Balance: $" + wc.balance);
        System.out.println("    Total Value: $" + (value + wc.balance));
    }
}
 
Example #8
Source File: FamilyManager.java    From ashley with Apache License 2.0 6 votes vote down vote up
private ImmutableArray<Entity> registerFamily(Family family) {
	ImmutableArray<Entity> entitiesInFamily = immutableFamilies.get(family);

	if (entitiesInFamily == null) {
		Array<Entity> familyEntities = new Array<Entity>(false, 16);
		entitiesInFamily = new ImmutableArray<Entity>(familyEntities);
		families.put(family, familyEntities);
		immutableFamilies.put(family, entitiesInFamily);
		entityListenerMasks.put(family, new Bits());

		for (Entity entity : entities){
			updateFamilyMembership(entity);
		}
	}

	return entitiesInFamily;
}
 
Example #9
Source File: EngineTests.java    From ashley with Apache License 2.0 6 votes vote down vote up
@Test
public void entitySystemRemovalWhileIterating () {
	Engine engine = new Engine();

	engine.addSystem(new CounterSystem());

	for (int i = 0; i < 20; ++i) {
		Entity entity = new Entity();
		entity.add(new CounterComponent());
		engine.addEntity(entity);
	}

	ImmutableArray<Entity> entities = engine.getEntitiesFor(Family.all(CounterComponent.class).get());

	for (int i = 0; i < entities.size(); ++i) {
		assertEquals(0, entities.get(i).getComponent(CounterComponent.class).counter);
	}

	engine.update(deltaTime);

	for (int i = 0; i < entities.size(); ++i) {
		assertEquals(1, entities.get(i).getComponent(CounterComponent.class).counter);
	}
}
 
Example #10
Source File: WorldRenderer.java    From xibalba with MIT License 6 votes vote down vote up
private void renderEnemies() {
  ImmutableArray<Entity> entities =
      WorldManager.engine.getEntitiesFor(Family.all(EnemyComponent.class).get());

  for (Entity entity : entities) {
    PositionComponent position = ComponentMappers.position.get(entity);

    if (Main.tweenManager.getRunningTimelinesCount() == 0) {
      WorldManager.entityHelpers.updateSprite(entity, position.pos.x, position.pos.y);
    }

    if (WorldManager.entityHelpers.isVisible(entity)) {
      ComponentMappers.visual.get(entity).sprite.draw(batch);
    } else if (WorldManager.entityHelpers.canHear(WorldManager.player, entity)) {
      question.setPosition(
          position.pos.x * Main.SPRITE_WIDTH, position.pos.y * Main.SPRITE_HEIGHT
      );

      question.draw(batch);
    }
  }
}
 
Example #11
Source File: EngineTests.java    From ashley with Apache License 2.0 6 votes vote down vote up
@Test
public void getEntities () {
	int numEntities = 10;
	
	Engine engine = new Engine();
	
	Array<Entity> entities = new Array<Entity>();
	
	for (int i = 0; i < numEntities; ++i) {
		Entity entity = new Entity();
		entities.add(entity);
		engine.addEntity(entity);
	}
	
	ImmutableArray<Entity> engineEntities = engine.getEntities();
	
	assertEquals(entities.size, engineEntities.size());
	
	for (int i = 0; i < numEntities; ++i) {
		assertEquals(entities.get(i), engineEntities.get(i));
	}
	
	engine.removeAllEntities();
	
	assertEquals(0, engineEntities.size());
}
 
Example #12
Source File: Engine.java    From ashley with Apache License 2.0 6 votes vote down vote up
/**
 * Updates all the systems in this Engine.
 * @param deltaTime The time passed since the last frame.
 */
public void update(float deltaTime){
	if (updating) {
		throw new IllegalStateException("Cannot call update() on an Engine that is already updating.");
	}
	
	updating = true;
	ImmutableArray<EntitySystem> systems = systemManager.getSystems();
	try {
		for (int i = 0; i < systems.size(); ++i) {
			EntitySystem system = systems.get(i);
			
			if (system.checkProcessing()) {
				system.update(deltaTime);
			}

			while(componentOperationHandler.hasOperationsToProcess() || entityManager.hasPendingOperations()) {
				componentOperationHandler.processOperations();
				entityManager.processPendingOperations();
			}
		}
	}
	finally {
		updating = false;
	}	
}
 
Example #13
Source File: WorldRenderer.java    From xibalba with MIT License 6 votes vote down vote up
private void renderStairs() {
  ImmutableArray<Entity> entrances =
      WorldManager.engine.getEntitiesFor(Family.all(EntranceComponent.class).get());
  ImmutableArray<Entity> exits =
      WorldManager.engine.getEntitiesFor(Family.all(ExitComponent.class).get());

  Object[] entities = ArrayUtils.addAll(entrances.toArray(), exits.toArray());

  for (Object e : entities) {
    Entity entity = (Entity) e;

    if (WorldManager.entityHelpers.isVisible(entity)) {
      ComponentMappers.visual.get(entity).sprite.draw(batch);
    }
  }
}
 
Example #14
Source File: MapHelpers.java    From xibalba with MIT License 6 votes vote down vote up
/**
 * Get trap at given position.
 *
 * @param position The position to check
 * @return The trap if one is found, null if not
 */
public Entity getTrapAt(Vector2 position) {
  ImmutableArray<Entity> entities =
      WorldManager.engine.getEntitiesFor(
          Family.all(TrapComponent.class).get()
      );

  for (Entity entity : entities) {
    PositionComponent entityPosition = ComponentMappers.position.get(entity);

    if (entityPosition.pos.epsilonEquals(position, 0.00001f)) {
      return entity;
    }
  }

  return null;
}
 
Example #15
Source File: MapHelpers.java    From xibalba with MIT License 6 votes vote down vote up
/**
 * Get all entities at a given position.
 *
 * @param position Where we're searching
 * @return List of entities at location
 */
public ArrayList<Entity> getEntitiesAt(Vector2 position) {
  ArrayList<Entity> list = new ArrayList<>();

  ImmutableArray<Entity> entities =
      WorldManager.engine.getEntitiesFor(
          Family.all(PositionComponent.class).exclude(LightComponent.class).get()
      );

  for (Entity entity : entities) {
    PositionComponent entityPosition = ComponentMappers.position.get(entity);

    if (entityPosition != null && entityPosition.pos.epsilonEquals(position, 0.00001f)) {
      list.add(entity);
    }
  }

  return list;
}
 
Example #16
Source File: MapHelpers.java    From xibalba with MIT License 6 votes vote down vote up
/**
 * Try to find an entity at x, y.
 *
 * @param cellX x
 * @param cellY y
 * @return Either the entity or null if none were found
 */
public Entity getEntityAt(float cellX, float cellY) {
  ImmutableArray<Entity> entities =
      WorldManager.engine.getEntitiesFor(
          Family.all(PositionComponent.class).exclude(
              DecorationComponent.class, LightComponent.class
          ).get()
      );

  for (Entity entity : entities) {
    PositionComponent entityPosition = ComponentMappers.position.get(entity);

    if (entityPosition.pos.x == cellX && entityPosition.pos.y == cellY) {
      return entity;
    }
  }

  return null;
}
 
Example #17
Source File: EntityManager.java    From ashley with Apache License 2.0 6 votes vote down vote up
public void removeAllEntities(ImmutableArray<Entity> entities, boolean delayed) {
	if (delayed) {
		for(Entity entity: entities) {
			entity.scheduledForRemoval = true;
		}
		EntityOperation operation = entityOperationPool.obtain();
		operation.type = EntityOperation.Type.RemoveAll;
		operation.entities = entities;
		pendingOperations.add(operation);
	}
	else {
		while(entities.size() > 0) {
			removeEntity(entities.first(), false);
		}
	}
}
 
Example #18
Source File: EngineTests.java    From ashley with Apache License 2.0 5 votes vote down vote up
@Test
public void entitiesForFamilyAfter () {
	Engine engine = new Engine();

	Family family = Family.all(ComponentA.class, ComponentB.class).get();
	ImmutableArray<Entity> familyEntities = engine.getEntitiesFor(family);

	assertEquals(0, familyEntities.size());

	Entity entity1 = new Entity();
	Entity entity2 = new Entity();
	Entity entity3 = new Entity();
	Entity entity4 = new Entity();

	engine.addEntity(entity1);
	engine.addEntity(entity2);
	engine.addEntity(entity3);
	engine.addEntity(entity4);

	entity1.add(new ComponentA());
	entity1.add(new ComponentB());

	entity2.add(new ComponentA());
	entity2.add(new ComponentC());

	entity3.add(new ComponentA());
	entity3.add(new ComponentB());
	entity3.add(new ComponentC());

	entity4.add(new ComponentA());
	entity4.add(new ComponentB());
	entity4.add(new ComponentC());

	assertEquals(3, familyEntities.size());
	assertTrue(familyEntities.contains(entity1, true));
	assertTrue(familyEntities.contains(entity3, true));
	assertTrue(familyEntities.contains(entity4, true));
	assertFalse(familyEntities.contains(entity2, true));
}
 
Example #19
Source File: Entity.java    From ashley with Apache License 2.0 5 votes vote down vote up
/** Creates an empty Entity. */
public Entity () {
	components = new Bag<Component>();
	componentsArray = new Array<Component>(false, 16);
	immutableComponentsArray = new ImmutableArray<Component>(componentsArray);
	componentBits = new Bits();
	familyBits = new Bits();
	flags = 0;

	componentAdded = new Signal<Entity>();
	componentRemoved = new Signal<Entity>();
}
 
Example #20
Source File: EngineTests.java    From ashley with Apache License 2.0 5 votes vote down vote up
@Test
public void entitiesForFamily () {
	Engine engine = new Engine();

	Family family = Family.all(ComponentA.class, ComponentB.class).get();
	ImmutableArray<Entity> familyEntities = engine.getEntitiesFor(family);

	assertEquals(0, familyEntities.size());

	Entity entity1 = new Entity();
	Entity entity2 = new Entity();
	Entity entity3 = new Entity();
	Entity entity4 = new Entity();

	entity1.add(new ComponentA());
	entity1.add(new ComponentB());

	entity2.add(new ComponentA());
	entity2.add(new ComponentC());

	entity3.add(new ComponentA());
	entity3.add(new ComponentB());
	entity3.add(new ComponentC());

	entity4.add(new ComponentA());
	entity4.add(new ComponentB());
	entity4.add(new ComponentC());

	engine.addEntity(entity1);
	engine.addEntity(entity2);
	engine.addEntity(entity3);
	engine.addEntity(entity4);

	assertEquals(3, familyEntities.size());
	assertTrue(familyEntities.contains(entity1, true));
	assertTrue(familyEntities.contains(entity3, true));
	assertTrue(familyEntities.contains(entity4, true));
	assertFalse(familyEntities.contains(entity2, true));
}
 
Example #21
Source File: MapHelpers.java    From xibalba with MIT License 5 votes vote down vote up
/**
 * Returns whether or not the given position is blocked.
 *
 * @param position Position to check
 * @return Is it blocked?
 */
public boolean isBlocked(int mapIndex, Vector2 position) {
  MapCell[][] map = WorldManager.world.getMap(mapIndex).getCellMap();

  boolean blocked = map[(int) position.x][(int) position.y].isWall()
      || map[(int) position.x][(int) position.y].isNothing();

  if (!blocked) {
    ImmutableArray<Entity> entities =
        WorldManager.engine.getEntitiesFor(
            Family.all(PositionComponent.class).exclude(LightComponent.class).get()
        );

    for (Entity entity : entities) {
      PositionComponent ep = ComponentMappers.position.get(entity);

      if (ep != null && ep.pos.epsilonEquals(position, 0.00001f)) {
        if (ComponentMappers.decoration.has(entity)) {
          if (ComponentMappers.decoration.get(entity).blocks) {
            blocked = true;
            break;
          }
        } else if (ComponentMappers.trap.has(entity)) {
          blocked = false;
        } else {
          blocked = true;
          break;
        }
      }
    }
  }

  return blocked;
}
 
Example #22
Source File: FamilyManagerTests.java    From ashley with Apache License 2.0 5 votes vote down vote up
@Test
public void entityForFamilyWithRemoval () {
	Array<Entity> entities = new Array<Entity>();
	ImmutableArray<Entity> immutableEntities = new ImmutableArray<Entity>(entities);
	FamilyManager manager = new FamilyManager(immutableEntities);

	Entity entity = new Entity();
	entity.add(new ComponentA());

	entities.add(entity);
	
	manager.updateFamilyMembership(entity);
	
	ImmutableArray<Entity> familyEntities = manager.getEntitiesFor(Family.all(ComponentA.class).get());
	
	assertEquals(1, familyEntities.size());
	assertTrue(familyEntities.contains(entity, true));
	
	entity.removing = true;
	entities.removeValue(entity, true);
	
	manager.updateFamilyMembership(entity);
	entity.removing = false;

	assertEquals(0, familyEntities.size());
	assertFalse(familyEntities.contains(entity, true));
}
 
Example #23
Source File: FamilyManagerTests.java    From ashley with Apache License 2.0 5 votes vote down vote up
@Test
public void entitiesForFamilyWithRemovalAndFiltering () {
	Array<Entity> entities = new Array<Entity>();
	ImmutableArray<Entity> immutableEntities = new ImmutableArray<Entity>(entities);
	FamilyManager manager = new FamilyManager(immutableEntities);

	ImmutableArray<Entity> entitiesWithComponentAOnly = manager.getEntitiesFor(Family.all(ComponentA.class)
		.exclude(ComponentB.class).get());

	ImmutableArray<Entity> entitiesWithComponentB = manager.getEntitiesFor(Family.all(ComponentB.class).get());

	Entity entity1 = new Entity();
	Entity entity2 = new Entity();

	entities.add(entity1);
	entities.add(entity2);

	entity1.add(new ComponentA());

	entity2.add(new ComponentA());
	entity2.add(new ComponentB());
	
	manager.updateFamilyMembership(entity1);
	manager.updateFamilyMembership(entity2);

	assertEquals(1, entitiesWithComponentAOnly.size());
	assertEquals(1, entitiesWithComponentB.size());

	entity2.remove(ComponentB.class);
	
	manager.updateFamilyMembership(entity2);

	assertEquals(2, entitiesWithComponentAOnly.size());
	assertEquals(0, entitiesWithComponentB.size());
}
 
Example #24
Source File: EntityManagerTests.java    From ashley with Apache License 2.0 5 votes vote down vote up
@Test
public void getEntities () {
	int numEntities = 10;
	
	EntityListenerMock listener = new EntityListenerMock();
	EntityManager manager = new EntityManager(listener);
	
	Array<Entity> entities = new Array<Entity>();
	
	for (int i = 0; i < numEntities; ++i) {
		Entity entity = new Entity();
		entities.add(entity);
		manager.addEntity(entity);
	}
	
	ImmutableArray<Entity> engineEntities = manager.getEntities();
	
	assertEquals(entities.size, engineEntities.size());
	
	for (int i = 0; i < numEntities; ++i) {
		assertEquals(entities.get(i), engineEntities.get(i));
	}
	
	manager.removeAllEntities();
	
	assertEquals(0, engineEntities.size());
}
 
Example #25
Source File: MapHelpers.java    From xibalba with MIT License 5 votes vote down vote up
/**
 * Similar to getEntityAt, but only return an entity if it contains EnemyComponent.
 *
 * @param cellX x
 * @param cellY y
 * @return Either an enemy or null if none were found
 */
public Entity getEnemyAt(int cellX, int cellY) {
  ImmutableArray<Entity> entities =
      WorldManager.engine.getEntitiesFor(Family.all(EnemyComponent.class).get());

  for (Entity entity : entities) {
    PositionComponent entityPosition = ComponentMappers.position.get(entity);

    if (entityPosition.pos.x == cellX && entityPosition.pos.y == cellY) {
      return entity;
    }
  }

  return null;
}
 
Example #26
Source File: SortedIteratingSystem.java    From ashley with Apache License 2.0 5 votes vote down vote up
@Override
public void addedToEngine (Engine engine) {
	ImmutableArray<Entity> newEntities = engine.getEntitiesFor(family);
	sortedEntities.clear();
	if (newEntities.size() > 0) {
		for (int i = 0; i < newEntities.size(); ++i) {
			sortedEntities.add(newEntities.get(i));
		}
		sortedEntities.sort(comparator);
	}
	shouldSort = false;
	engine.addEntityListener(family, this);
}
 
Example #27
Source File: WorldRenderer.java    From xibalba with MIT License 5 votes vote down vote up
private void renderDecorations() {
  ImmutableArray<Entity> entities =
      WorldManager.engine.getEntitiesFor(Family.all(DecorationComponent.class).get());

  for (Entity entity : entities) {
    if (WorldManager.entityHelpers.isVisible(entity)) {
      ComponentMappers.visual.get(entity).sprite.draw(batch);
    }
  }
}
 
Example #28
Source File: WorldRenderer.java    From xibalba with MIT License 5 votes vote down vote up
private void renderTraps() {
  ImmutableArray<Entity> entities =
      WorldManager.engine.getEntitiesFor(Family.all(TrapComponent.class).get());

  for (Entity entity : entities) {
    if (ComponentMappers.visual.has(entity) && WorldManager.entityHelpers.isVisible(entity)) {
      ComponentMappers.visual.get(entity).sprite.draw(batch);
    }
  }
}
 
Example #29
Source File: WorldRenderer.java    From xibalba with MIT License 5 votes vote down vote up
private void renderPlayer() {
  ImmutableArray<Entity> entities =
      WorldManager.engine.getEntitiesFor(Family.all(PlayerComponent.class).get());

  if (entities.size() > 0) {
    Entity player = entities.first();

    if (Main.tweenManager.getRunningTimelinesCount() == 0) {
      PositionComponent position = ComponentMappers.position.get(player);
      WorldManager.entityHelpers.updateSprite(player, position.pos.x, position.pos.y);
    }

    ComponentMappers.visual.get(player).sprite.draw(batch);
  }
}
 
Example #30
Source File: SortedIteratingSystem.java    From ashley with Apache License 2.0 5 votes vote down vote up
/**
 * Instantiates a system that will iterate over the entities described by the Family, with a specific priority.
 * @param family The family of entities iterated over in this System
 * @param comparator The comparator to sort the entities
 * @param priority The priority to execute this system with (lower means higher priority)
 */
public SortedIteratingSystem (Family family, Comparator<Entity> comparator, int priority) {
	super(priority);

	this.family = family;
	sortedEntities = new Array<Entity>(false, 16);
	entities = new ImmutableArray<Entity>(sortedEntities);
	this.comparator = comparator;
}