@Override protected void process(int entityId) { try { Position p = posMapper.get(entityId); Rotation r = rotMapper.get(entityId); Velocity v = velMapper.get(entityId); if (physMapper.has(entityId)) { Body body = world.getSystem(PhysicsSystem.class).getBody(entityId); if (inputMapper.has(entityId)) { // control physics body by input processPhysicsMovement(body, inputMapper.get(entityId), p, v, r, entityId); } else { // keep image with body for when physics is acting upon it p.position.set(body.getPosition()); r.angle = MathUtils.radiansToDegrees * body.getAngle(); v.velocity.set(body.getLinearVelocity()); } } else { // move image directly since there is no physics body float d = world.getDelta(); p.position.add(v.velocity.x * d, v.velocity.y * d); } // Keep equipment with entity if (equipMapper.has(entityId)) { EquipmentList equipmentList = equipMapper.get(entityId); equipmentList.moveEquipment(boundsMapper, posMapper); equipmentList.rechargeEquipment(); // TODO: move this to EnergySystem } } catch (NullPointerException ex) { logger.error("MoveSys error; killing offending entity #" + entityId, ex); world.getEntity(entityId).getComponent(Lifecycle.class).kill(); } }
protected void process(Entity e) { if (pm.has(e)) { Position position = pm.getSafe(e); Gdx.gl.glEnable(GL10.GL_BLEND); Gdx.gl.glEnable(GL10.GL_LINE_SMOOTH); // Gdx.gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA); if (cm.has(e)) { Circle circle = cm.getSafe(e); if (circle.filled) { shapeRenderer.begin(ShapeType.Filled); } else { shapeRenderer.begin(ShapeType.Line); } if (circle.borderSize > 0) { shapeRenderer.setColor(circle.borderColor); shapeRenderer.circle(position.x, position.y, circle.radius, circle.segments); shapeRenderer.setColor(circle.color); shapeRenderer.circle( position.x, position.y, circle.radius - circle.borderSize, circle.segments); } else { shapeRenderer.setColor(circle.color); shapeRenderer.circle(position.x, position.y, circle.radius, circle.segments); } shapeRenderer.end(); } if (rm.has(e)) { Rectangle rectangle = rm.getSafe(e); shapeRenderer.setColor(rectangle.color); if (rectangle.filled) { shapeRenderer.begin(ShapeType.Filled); } else { shapeRenderer.begin(ShapeType.Line); } shapeRenderer.rect(position.x, position.y, rectangle.width, rectangle.height); shapeRenderer.end(); } Gdx.gl.glDisable(GL10.GL_BLEND); Gdx.gl.glDisable(GL10.GL_LINE_SMOOTH); } }
@Override protected void begin() { batch.setProjectionMatrix(cameraSystem.camera.combined); batch.begin(); batch.setColor(1f, 1f, 1f, 1f); player = tagManager.getEntity("player"); walletCash = wm.has(player) ? wm.get(player).resources : 0; }
public static void dispatchEvent(World world, Entity entity, Event event) { if (scm.has(entity) && scm.get(entity).hasEventScripts(event.getType())) for (Script script : scm.get(entity).getScriptsByEvent(event.getType())) { script.run(world, event); } else LOGGER.fine( "Dispatch event " + event.getType() + " to a entity which do not has ScriptComponent"); }
/** * Apply force on joint, pushing the attached entity out of place. * * @param entity Entity to push * @param rotation Direction of force * @param force strength of force (don't factor in delta). */ public void push(final Entity entity, float rotation, float force) { if (am.has(entity)) { push(am.get(entity), rotation, force); } }