Skip to content

Commit

Permalink
Finally removes deprecated Family methods
Browse files Browse the repository at this point in the history
  • Loading branch information
dsaltares committed Jan 31, 2015
1 parent b7ce267 commit d6222d9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 44 deletions.
35 changes: 0 additions & 35 deletions ashley/src/com/badlogic/ashley/core/Family.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,41 +71,6 @@ public boolean matches (Entity entity) {
return true;
}

/**
* @return The family matching the specified {@link Component} classes as a descriptor. Each set of component types will always
* return the same Family instance.
* @deprecated Use builder functionality instead ({@link Family#all}, {@link Family#one}, {@link Family#exclude})
*/
@SafeVarargs
@Deprecated
public static Family getFor (Class<? extends Component>... componentTypes) {
return getFor(ComponentType.getBitsFor(componentTypes), zeroBits, zeroBits);
}

/**
* Returns a family with the passed {@link Component} classes as a descriptor. Each set of component types will always return
* the same Family instance.
* @param all entities will have to contain all of the components in the set. See {@link ComponentType#getBitsFor(Class<?
* extends Component> ...)}.
* @param one entities will have to contain at least one of the components in the set.See {@link
* ComponentType#getBitsFor(Class<? extends Component> ...)}.
* @param exclude entities cannot contain any of the components in the set. See {@link ComponentType#getBitsFor(Class<? extends
* Component> ...)}.
* @return The family
* @deprecated Use builder functionality instead ({@link Family#all}, {@link Family#one}, {@link Family#exclude})
*/
@Deprecated
public static Family getFor (Bits all, Bits one, Bits exclude) {
String hash = getFamilyHash(all, one, exclude);
Family family = families.get(hash, null);
if (family == null) {
family = new Family(all, one, exclude);
families.put(hash, family);
}

return family;
}

/**
* @param componentTypes entities will have to contain all of the specified components.
* @return A Builder singleton instance to get a family
Expand Down
6 changes: 3 additions & 3 deletions ashley/tests/com/badlogic/ashley/core/PooledEngineTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public CombinedSystem (Engine engine) {

@Override
public void addedToEngine (Engine engine) {
allEntities = engine.getEntitiesFor(Family.getFor(PositionComponent.class));
allEntities = engine.getEntitiesFor(Family.all(PositionComponent.class).get());
}

@Override
Expand All @@ -73,7 +73,7 @@ private static class RemoveEntityTwiceSystem extends EntitySystem {

@Override
public void addedToEngine (Engine engine) {
entities = engine.getEntitiesFor(Family.getFor(PositionComponent.class));
entities = engine.getEntitiesFor(Family.all(PositionComponent.class).get());
this.engine = (PooledEngine)engine;
}

Expand Down Expand Up @@ -102,7 +102,7 @@ public void entityRemovalListenerOrder () {
CombinedSystem combinedSystem = new CombinedSystem(engine);

engine.addSystem(combinedSystem);
engine.addEntityListener(Family.getFor(PositionComponent.class), new MyPositionListener());
engine.addEntityListener(Family.all(PositionComponent.class).get(), new MyPositionListener());

for (int i = 0; i < 10; i++) {
Entity entity = engine.createEntity();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ private static class IteratingComponentRemovalSystem extends SortedIteratingSyst
private ComponentMapper<IndexComponent> im;

public IteratingComponentRemovalSystem () {
super(Family.getFor(SpyComponent.class, IndexComponent.class), comparator);
super(Family.all(SpyComponent.class, IndexComponent.class).get(), comparator);

sm = ComponentMapper.getFor(SpyComponent.class);
im = ComponentMapper.getFor(IndexComponent.class);
Expand All @@ -112,7 +112,7 @@ private static class IteratingRemovalSystem extends SortedIteratingSystem {
private ComponentMapper<IndexComponent> im;

public IteratingRemovalSystem () {
super(Family.getFor(SpyComponent.class, IndexComponent.class), comparator);
super(Family.all(SpyComponent.class, IndexComponent.class).get(), comparator);

sm = ComponentMapper.getFor(SpyComponent.class);
im = ComponentMapper.getFor(IndexComponent.class);
Expand Down Expand Up @@ -141,7 +141,7 @@ public void processEntity (Entity entity, float deltaTime) {
public void shouldIterateEntitiesWithCorrectFamily () {
final Engine engine = new Engine();

final Family family = Family.getFor(OrderComponent.class, ComponentB.class);
final Family family = Family.all(OrderComponent.class, ComponentB.class).get();
final SortedIteratingSystemMock system = new SortedIteratingSystemMock(family);
final Entity e = new Entity();

Expand Down Expand Up @@ -171,7 +171,7 @@ public void shouldIterateEntitiesWithCorrectFamily () {
@Test
public void entityRemovalWhileIterating () {
Engine engine = new Engine();
ImmutableArray<Entity> entities = engine.getEntitiesFor(Family.getFor(SpyComponent.class, IndexComponent.class));
ImmutableArray<Entity> entities = engine.getEntitiesFor(Family.all(SpyComponent.class, IndexComponent.class).get());
ComponentMapper<SpyComponent> sm = ComponentMapper.getFor(SpyComponent.class);

engine.addSystem(new IteratingRemovalSystem());
Expand Down Expand Up @@ -205,7 +205,7 @@ public void entityRemovalWhileIterating () {
@Test
public void componentRemovalWhileIterating () {
Engine engine = new Engine();
ImmutableArray<Entity> entities = engine.getEntitiesFor(Family.getFor(SpyComponent.class, IndexComponent.class));
ImmutableArray<Entity> entities = engine.getEntitiesFor(Family.all(SpyComponent.class, IndexComponent.class).get());
ComponentMapper<SpyComponent> sm = ComponentMapper.getFor(SpyComponent.class);

engine.addSystem(new IteratingComponentRemovalSystem());
Expand Down Expand Up @@ -246,7 +246,7 @@ private static Entity createOrderEntity (String name, int zLayer) {
public void entityOrder () {
Engine engine = new Engine();

final Family family = Family.getFor(OrderComponent.class);
final Family family = Family.all(OrderComponent.class).get();
final SortedIteratingSystemMock system = new SortedIteratingSystemMock(family);
engine.addSystem(system);

Expand Down

0 comments on commit d6222d9

Please sign in to comment.