com.artemis.Entity Java Examples

The following examples show how to use com.artemis.Entity. 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: PlayerSystem.java    From Bomberman_libGdx with MIT License 6 votes vote down vote up
protected boolean checkCanKickBomb(Body body, Vector2 fromV, Vector2 toV) {
    World b2dWorld = body.getWorld();
    kickingBomb = null;
    kicking = false;

    RayCastCallback rayCastCallback = new RayCastCallback() {

        @Override
        public float reportRayFixture(Fixture fixture, Vector2 point, Vector2 normal, float fraction) {
            if (fixture.getFilterData().categoryBits == GameManager.BOMB_BIT) {
                Entity bombEntity = (Entity) fixture.getBody().getUserData();
                kickingBomb = bombEntity.getComponent(Bomb.class);
                return 0;
            }
            return 0;
        }
    };

    b2dWorld.rayCast(rayCastCallback, fromV, toV);
    if (kickingBomb != null) {
        kicking = true;
    }
    return kicking;
}
 
Example #2
Source File: RenderSystem.java    From Bomberman_libGdx with MIT License 6 votes vote down vote up
@Override
protected void processSystem() {
    Bag<Entity> entities = getEntities();
    
    Sort sort = Sort.instance();
    sort.sort(entities, new Comparator<Entity>() {
        @Override
        public int compare(Entity o1, Entity o2) {
            Transform t1 = mTransform.get(o1);
            Transform t2 = mTransform.get(o2);
            if (t1.z < t2.z) {
                return 1;
            }
            else if (t1.z > t2.z) {
                return -1;
            }
            else {
                return 0;
            }
        }
    });
    
    for (Entity e : entities) {
        process(e);
    }
}
 
Example #3
Source File: ActorBuilder.java    From Bomberman_libGdx with MIT License 6 votes vote down vote up
private boolean checkCanExplodeThrough(Vector2 fromV, Vector2 toV) {
    canExplodeThrough = true;
    RayCastCallback rayCastCallback = new RayCastCallback() {

        @Override
        public float reportRayFixture(Fixture fixture, Vector2 point, Vector2 normal, float fraction) {
            if (fixture.getFilterData().categoryBits == GameManager.INDESTRUCTIIBLE_BIT) {
                canExplodeThrough = false;
                return 0;
            }

            if (fixture.getFilterData().categoryBits == GameManager.BREAKABLE_BIT) {
                canExplodeThrough = false;
                Entity e = (Entity) fixture.getBody().getUserData();
                Breakable breakable = e.getComponent(Breakable.class);
                breakable.state = Breakable.State.EXPLODING;
                return 0;
            }
            return 0;
        }
    };

    b2dWorld.rayCast(rayCastCallback, fromV, toV);
    return canExplodeThrough;
}
 
Example #4
Source File: PlainPositionSystem.java    From entity-system-benchmarks with Apache License 2.0 5 votes vote down vote up
@Override
protected void process(Entity e) {
	PlainPosition pos = positionMapper.get(e);
	pos.x += 1;
	pos.y -= 1;
	
	voidness.consume(e);
}
 
Example #5
Source File: PooledPositionSystem2.java    From entity-system-benchmarks with Apache License 2.0 5 votes vote down vote up
@Override
protected void process(Entity e) {
	PooledPosition pos = positionMapper.get(e);
	pos.x -= 1;
	pos.y += 1;
	
	voidness.consume(e);
}
 
Example #6
Source File: PlainPositionSystem2.java    From entity-system-benchmarks with Apache License 2.0 5 votes vote down vote up
@Override
protected void process(Entity e) {
	PlainPosition pos = positionMapper.get(e);
	pos.x -= 1;
	pos.y += 1;
	
	voidness.consume(e);
}
 
Example #7
Source File: EntityManglerSystem.java    From entity-system-benchmarks with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
private final void createEntity() {
	Entity e = world.createEntity();
	Bag<Class<? extends Component>> components = permutations[cmp[cmpIndex++]];
	if (cmpIndex == cmp.length) cmpIndex = 0;
	
	Object[] data = components.getData();
	for (int i = 0, s = components.size(); s > i; i++) {
		e.addComponent(newInstance(data[i]));
	}
	e.addToWorld();
}
 
Example #8
Source File: EntityManglerSystem.java    From entity-system-benchmarks with Apache License 2.0 5 votes vote down vote up
@Override
protected void processSystem() {

	if (counter % 2 == 1) {
		for (int i = 0; RENEW > i; i++) {
			Entity e = world.getEntity(ids[index++]);
			e.deleteFromWorld();
			index = index % ENTITY_COUNT;
		}
	} else {
		for (int i = 0; RENEW > i; i++) {
			createEntity();
		}
	}
}
 
Example #9
Source File: EntityDeleterSystem.java    From entity-system-benchmarks with Apache License 2.0 5 votes vote down vote up
@Override
protected void processSystem() {
	if (counter == 100) {
		Entity e = world.getEntity(ids[index++]);
		e.deleteFromWorld();
		index = index % ENTITY_COUNT;
		counter = 0;
	} else if (counter == 1) { // need to wait one round to reclaim entities
		createEntity();
	}
}
 
Example #10
Source File: PlainPositionSystem3.java    From entity-system-benchmarks with Apache License 2.0 5 votes vote down vote up
@Override
protected void process(Entity e) {
	PlainPosition pos = positionMapper.get(e);
	pos.x += 0.5f;
	pos.y -= 0.5f;
	
	voidness.consume(e);
}
 
Example #11
Source File: PooledPositionSystem2.java    From entity-system-benchmarks with Apache License 2.0 5 votes vote down vote up
@Override
protected void process(Entity e) {
	PooledPosition pos = positionMapper.get(e);
	pos.x -= 1;
	pos.y += 1;
	
	voidness.consume(e);
}
 
Example #12
Source File: PooledPositionSystem.java    From entity-system-benchmarks with Apache License 2.0 5 votes vote down vote up
@Override
protected void process(Entity e) {
	PooledPosition pos = positionMapper.get(e);
	pos.x += 1;
	pos.y -= 1;
	
	voidness.consume(e);
}
 
Example #13
Source File: PooledPositionSystem3.java    From entity-system-benchmarks with Apache License 2.0 5 votes vote down vote up
@Override
protected void process(Entity e) {
	PooledPosition pos = positionMapper.get(e);
	pos.x += 0.5f;
	pos.y -= 0.5f;
	
	voidness.consume(e);
}
 
Example #14
Source File: PlainPositionSystem2.java    From entity-system-benchmarks with Apache License 2.0 5 votes vote down vote up
@Override
protected void process(Entity e) {
	PlainPosition pos = positionMapper.get(e);
	pos.x -= 1;
	pos.y += 1;
	
	voidness.consume(e);
}
 
Example #15
Source File: PlainPositionSystem3.java    From entity-system-benchmarks with Apache License 2.0 5 votes vote down vote up
@Override
protected void process(Entity e) {
	PlainPosition pos = positionMapper.get(e);
	pos.x += 0.5f;
	pos.y -= 0.5f;
	
	voidness.consume(e);
}
 
Example #16
Source File: PooledPositionSystem3.java    From entity-system-benchmarks with Apache License 2.0 5 votes vote down vote up
@Override
protected void process(Entity e) {
	PooledPosition pos = positionMapper.get(e);
	pos.x += 0.5f;
	pos.y -= 0.5f;
	
	voidness.consume(e);
}
 
Example #17
Source File: PlainPositionSystem.java    From entity-system-benchmarks with Apache License 2.0 5 votes vote down vote up
@Override
protected void process(Entity e) {
	PlainPosition pos = positionMapper.get(e);
	pos.x += 1;
	pos.y -= 1;
	
	voidness.consume(e);
}
 
Example #18
Source File: CompositionManglerSystem.java    From entity-system-benchmarks with Apache License 2.0 5 votes vote down vote up
@Override
protected void processSystem() {

	for (int i = 0; RENEW > i; i++) {
		Entity e = world.getEntity(ids[index++]);
		if (positionMapper.has(e)) {
			e.edit().remove(PlainPosition.class);
		} else {
			e.edit().create(PlainPosition.class);
		}
		index = index % ENTITY_COUNT;
	}
}
 
Example #19
Source File: TransmutingCompositionManglerSystem.java    From entity-system-benchmarks with Apache License 2.0 5 votes vote down vote up
@Override
protected void processSystem() {

	for (int i = 0; RENEW > i; i++) {
		Entity e = world.getEntity(ids[index++]);
		if (positionMapper.has(e)) {
			removePosition.transmute(e);
		} else {
			addPosition.transmute(e);
		}
		index = index % ENTITY_COUNT;
	}
}
 
Example #20
Source File: PlainPositionSystem3.java    From entity-system-benchmarks with Apache License 2.0 5 votes vote down vote up
@Override
protected void process(Entity e) {
	PlainPosition pos = positionMapper.get(e);
	pos.x += 0.5f;
	pos.y -= 0.5f;
	
	voidness.consume(e);
}
 
Example #21
Source File: EntityDeleterSystem.java    From entity-system-benchmarks with Apache License 2.0 5 votes vote down vote up
@Override
protected void processSystem() {
	if (counter == 100) {
		Entity e = world.getEntity(ids[index++]);
		e.deleteFromWorld();
		index = index % ENTITY_COUNT;
		counter = 0;
	} else if (counter == 1) { // need to wait one round to reclaim entities
		createEntity();
	}
}
 
Example #22
Source File: EntityManglerSystem.java    From entity-system-benchmarks with Apache License 2.0 5 votes vote down vote up
@Override
protected void processSystem() {

	if (counter % 2 == 1) {
		for (int i = 0; RENEW > i; i++) {
			Entity e = world.getEntity(ids[index++]);
			e.deleteFromWorld();
			index = index % ENTITY_COUNT;
		}
	} else {
		for (int i = 0; RENEW > i; i++) {
			createEntity();
		}
	}
}
 
Example #23
Source File: PackedPositionSystem2.java    From entity-system-benchmarks with Apache License 2.0 5 votes vote down vote up
@Override
protected void process(Entity e) {
	PackedPosition pos = positionMapper.get(e);
	pos.x -= 1;
	pos.y += 1;
	
	voidness.consume(e);
}
 
Example #24
Source File: PlainPositionSystem2.java    From entity-system-benchmarks with Apache License 2.0 5 votes vote down vote up
@Override
protected void process(Entity e) {
	PlainPosition pos = positionMapper.get(e);
	pos.x -= 1;
	pos.y += 1;
	
	voidness.consume(e);
}
 
Example #25
Source File: PooledPositionSystem3.java    From entity-system-benchmarks with Apache License 2.0 5 votes vote down vote up
@Override
protected void process(Entity e) {
	PooledPosition pos = positionMapper.get(e);
	pos.x += 0.5f;
	pos.y -= 0.5f;
	
	voidness.consume(e);
}
 
Example #26
Source File: PooledPositionSystem.java    From entity-system-benchmarks with Apache License 2.0 5 votes vote down vote up
@Override
protected void process(Entity e) {
	PooledPosition pos = positionMapper.get(e);
	pos.x += 1;
	pos.y -= 1;
	
	voidness.consume(e);
}
 
Example #27
Source File: PackedPositionSystem.java    From entity-system-benchmarks with Apache License 2.0 5 votes vote down vote up
@Override
protected void process(Entity e) {
	PackedPosition pos = positionMapper.get(e);
	pos.x += 1;
	pos.y -= 1;
	
	voidness.consume(e);
}
 
Example #28
Source File: PooledPositionSystem2.java    From entity-system-benchmarks with Apache License 2.0 5 votes vote down vote up
@Override
protected void process(Entity e) {
	PooledPosition pos = positionMapper.get(e);
	pos.x -= 1;
	pos.y += 1;
	
	voidness.consume(e);
}
 
Example #29
Source File: PackedPositionSystem3.java    From entity-system-benchmarks with Apache License 2.0 5 votes vote down vote up
@Override
protected void process(Entity e) {
	PackedPosition pos = positionMapper.get(e);
	pos.x += 0.5f;
	pos.y -= 0.5f;
	
	voidness.consume(e);
}
 
Example #30
Source File: MovementSystem.java    From ashley with Apache License 2.0 5 votes vote down vote up
@Override
protected void process (Entity entity) {
	PositionComponent pos = pm.get(entity);
	MovementComponent mov = mm.get(entity);

	tmp.set(mov.accel).scl(world.getDelta());
	mov.velocity.add(tmp);

	tmp.set(mov.velocity).scl(world.getDelta());
	pos.pos.add(tmp.x, tmp.y, 0.0f);
}