@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(); } }
/** * get EquipementClass object from ID * * @param myID * @param eList * @return */ public static EquipmentClass getEquipmentByID(String myID, EquipmentList eList) { EquipmentClass oFound = null; for (EquipmentClass o : eList.getContent()) if (o.getMyID().equalsIgnoreCase(myID)) { oFound = o; break; } return (oFound); }