Java Code Examples for com.badlogic.ashley.core.ComponentMapper#getFor()

The following examples show how to use com.badlogic.ashley.core.ComponentMapper#getFor() . 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: RenderingSystem.java    From ashley-superjumper with Apache License 2.0 6 votes vote down vote up
public RenderingSystem(SpriteBatch batch) {
	super(Family.all(TransformComponent.class, TextureComponent.class).get());
	
	textureM = ComponentMapper.getFor(TextureComponent.class);
	transformM = ComponentMapper.getFor(TransformComponent.class);
	
	renderQueue = new Array<Entity>();
	
	comparator = new Comparator<Entity>() {
		@Override
		public int compare(Entity entityA, Entity entityB) {
			return (int)Math.signum(transformM.get(entityB).pos.z -
									transformM.get(entityA).pos.z);
		}
	};
	
	this.batch = batch;
	
	cam = new OrthographicCamera(FRUSTUM_WIDTH, FRUSTUM_HEIGHT);
	cam.position.set(FRUSTUM_WIDTH / 2, FRUSTUM_HEIGHT / 2, 0);
}
 
Example 2
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 3
Source File: PlatformSystem.java    From ashley-superjumper with Apache License 2.0 5 votes vote down vote up
public PlatformSystem() {
	super(family);
	
	tm = ComponentMapper.getFor(TransformComponent.class);
	mm = ComponentMapper.getFor(MovementComponent.class);
	pm = ComponentMapper.getFor(PlatformComponent.class);
	sm = ComponentMapper.getFor(StateComponent.class);
}
 
Example 4
Source File: CollisionSystem.java    From ashley-superjumper with Apache License 2.0 5 votes vote down vote up
public CollisionSystem(World world, CollisionListener listener) {
	this.world = world;
	this.listener = listener;
	
	bm = ComponentMapper.getFor(BoundsComponent.class);
	mm = ComponentMapper.getFor(MovementComponent.class);
	sm = ComponentMapper.getFor(StateComponent.class);
	tm = ComponentMapper.getFor(TransformComponent.class);
}
 
Example 5
Source File: BobSystem.java    From ashley-superjumper with Apache License 2.0 5 votes vote down vote up
public BobSystem(World world) {
	super(family);
	
	this.world = world;
	
	bm = ComponentMapper.getFor(BobComponent.class);
	sm = ComponentMapper.getFor(StateComponent.class);
	tm = ComponentMapper.getFor(TransformComponent.class);
	mm = ComponentMapper.getFor(MovementComponent.class);
}
 
Example 6
Source File: SquirrelSystem.java    From ashley-superjumper with Apache License 2.0 5 votes vote down vote up
public SquirrelSystem() {
	super(Family.all(SquirrelComponent.class,
						TransformComponent.class,
						MovementComponent.class).get());
	
	tm = ComponentMapper.getFor(TransformComponent.class);
	mm = ComponentMapper.getFor(MovementComponent.class);
}
 
Example 7
Source File: AnimationSystem.java    From ashley-superjumper with Apache License 2.0 5 votes vote down vote up
public AnimationSystem() {
	super(Family.all(TextureComponent.class,
						AnimationComponent.class,
						StateComponent.class).get());
	
	tm = ComponentMapper.getFor(TextureComponent.class);
	am = ComponentMapper.getFor(AnimationComponent.class);
	sm = ComponentMapper.getFor(StateComponent.class);
}
 
Example 8
Source File: CameraSystem.java    From ashley-superjumper with Apache License 2.0 4 votes vote down vote up
public CameraSystem() {
	super(Family.all(CameraComponent.class).get());
	
	tm = ComponentMapper.getFor(TransformComponent.class);
	cm = ComponentMapper.getFor(CameraComponent.class);
}
 
Example 9
Source File: SortedIteratingSystemTest.java    From ashley with Apache License 2.0 4 votes vote down vote up
public IteratingRemovalSystem () {
	super(Family.all(SpyComponent.class, IndexComponent.class).get(), comparator);

	sm = ComponentMapper.getFor(SpyComponent.class);
	im = ComponentMapper.getFor(IndexComponent.class);
}
 
Example 10
Source File: SortedIteratingSystemTest.java    From ashley with Apache License 2.0 4 votes vote down vote up
public IteratingComponentRemovalSystem () {
	super(Family.all(SpyComponent.class, IndexComponent.class).get(), comparator);

	sm = ComponentMapper.getFor(SpyComponent.class);
	im = ComponentMapper.getFor(IndexComponent.class);
}
 
Example 11
Source File: IntervalIteratingTest.java    From ashley with Apache License 2.0 4 votes vote down vote up
public IntervalIteratingSystemSpy () {
	super(Family.all(IntervalComponentSpy.class).get(), deltaTime * 2.0f);

	im = ComponentMapper.getFor(IntervalComponentSpy.class);
}
 
Example 12
Source File: IteratingSystemTest.java    From ashley with Apache License 2.0 4 votes vote down vote up
public IteratingRemovalSystem () {
	super(Family.all(SpyComponent.class, IndexComponent.class).get());

	sm = ComponentMapper.getFor(SpyComponent.class);
	im = ComponentMapper.getFor(IndexComponent.class);
}
 
Example 13
Source File: IteratingSystemTest.java    From ashley with Apache License 2.0 4 votes vote down vote up
public IteratingComponentRemovalSystem () {
	super(Family.all(SpyComponent.class, IndexComponent.class).get());

	sm = ComponentMapper.getFor(SpyComponent.class);
	im = ComponentMapper.getFor(IndexComponent.class);
}
 
Example 14
Source File: StateSystem.java    From ashley-superjumper with Apache License 2.0 4 votes vote down vote up
public StateSystem() {
	super(Family.all(StateComponent.class).get());
	
	sm = ComponentMapper.getFor(StateComponent.class);
}
 
Example 15
Source File: MovementSystem.java    From ashley-superjumper with Apache License 2.0 4 votes vote down vote up
public MovementSystem() {
	super(Family.all(TransformComponent.class, MovementComponent.class).get());
	
	tm = ComponentMapper.getFor(TransformComponent.class);
	mm = ComponentMapper.getFor(MovementComponent.class);
}
 
Example 16
Source File: GravitySystem.java    From ashley-superjumper with Apache License 2.0 4 votes vote down vote up
public GravitySystem() {
	super(Family.all(GravityComponent.class, MovementComponent.class).get());
	
	mm = ComponentMapper.getFor(MovementComponent.class);
}
 
Example 17
Source File: BoundsSystem.java    From ashley-superjumper with Apache License 2.0 4 votes vote down vote up
public BoundsSystem() {
	super(Family.all(BoundsComponent.class, TransformComponent.class).get());
	
	tm = ComponentMapper.getFor(TransformComponent.class);
	bm = ComponentMapper.getFor(BoundsComponent.class);
}
 
Example 18
Source File: BackgroundSystem.java    From ashley-superjumper with Apache License 2.0 4 votes vote down vote up
public BackgroundSystem() {
	super(Family.all(BackgroundComponent.class).get());
	tm = ComponentMapper.getFor(TransformComponent.class);
}