public E basic() { mappers.mBasic.create(entityId); return this; }
/** * Checks if the entity has this type of component. * @param e the entity to check * @return true if the entity has this component type, false if it doesn't. */ public boolean has(Entity e) { return getSafe(e) != null; } }
@Override protected void setup(int e, Animation anim, AnimationAsset animAsset) { animAsset.asset = library.get(anim.id); if (animAsset.asset == null) { throw new RuntimeException("No such animation, '" + anim.id + "'"); } // set size to asset. if (!mSize.has(e)) { TextureRegion frame = animAsset.asset.getKeyFrame(0); mSize.create(e).set( frame.getRegionWidth(), frame.getRegionHeight()); } } }
@Override protected void process(int entityId) { Transform transform = mTransform.get(entityId); RigidBody rigidBody = mRigidBody.get(entityId); transform.setPosition(rigidBody.body.getPosition()); // if the entity is Boss, make it drawn on top Enemy enemy = mEnemy.getSafe(entityId); if (enemy != null) { if (enemy.type.startsWith("boss")) { transform.z = -1; } } } }
public boolean hasParaGetter() { return mappers.mParaGetter.has(entityId); }
/** * Remove component from entity. * Does nothing if already removed. * * @param entityId */ public void remove(int entityId) { mapper.remove(entityId); }
public E rename2(boolean value) { mappers.mRename2.set(entityId, value); return this; } }
void registerComponentType(ComponentType ct, int capacity) { int index = ct.getIndex(); ComponentMapper mapper = new ComponentMapper(ct.getType(), world); mapper.components.ensureCapacity(capacity); mappers.set(index, mapper); }
/** * @deprecated as of odb version 2.0.0 {@see #get} is as safe as getSafe. */ @Deprecated public A getSafe(int entityId) { return mapper.get(entityId); }
@Override protected void setup(int e, Animation anim, AnimationAsset animAsset) { animAsset.asset = library.get(anim.id); if (animAsset.asset == null) { throw new RuntimeException("No such animation, '" + anim.id + "'"); } // set size to asset. if (!mSize.has(e)) { TextureRegion frame = animAsset.asset.getKeyFrame(0); mSize.create(e).set( frame.getRegionWidth(), frame.getRegionHeight()); } } }
@Override protected void process(int e) { Pos pos = mPos.get(e); batch.setProjectionMatrix(cameraSystem.camera.combined); batch.begin(); Texture asset = mSpriteAsset.get(e).asset; final Angle angle = mAngle.getSafe(e, this.angle); region.setTexture(asset); region.setRegion(0,0,32,32); final Origin origin = mOrigin.getSafe(e, DEFAULT_ORIGIN); final Size size = mSize.getSafe(e, DEFAULT_SIZE); float ox = size.getX() * origin.getX(); float oy = size.getY() * origin.getY(); batch.draw( region, pos.xy.x - (size.getX() - ox), pos.xy.y - (size.getY() - oy), ox, oy, size.getX(), size.getY(), 1f,1f, angle.rotation); batch.end(); }
public boolean hasRename2() { return mappers.mRename2.has(entityId); }
public E removeBasic() { mappers.mBasic.remove(entityId); return this; }