From an AbstractGameSystem > Update:
@Override
public void update(SimTime tpf) {
time = tpf;
//warpTouchEntities.applyChanges();
warpers.update();
if (warpToEntities.applyChanges()) {
for (Entity e : warpToEntities) {
SimpleBody body = simplePhysics.getBody(e.getId());
if (body != null) {
BodyPosition pos = e.get(BodyPosition.class);
Vec3d targetLocation = ed.getComponent(e.getId(), WarpTo.class).getTargetLocation();
Vector2 originalLocation = body.getTransform().getTranslation();
Vec3d origLocationVec3d = new Vec3d(originalLocation.x, originalLocation.y, 1);
//Right now, this is how I translate the ship (and everything else) to the new location - and it works as long as the `ZONE_RADIUS` is big enough for the `targetlocation` to be included in the radius.
body.getTransform().setTranslation(targetLocation.x, targetLocation.y);
//This is how it 'could also be done?'
/*
HostedConnection hc = getSystem(AccountHostedService.class).getHostedConnection(e.getId());
if (hc != null) {
getSystem(EtherealHost.class).setConnectionObject(getSystem(AccountHostedService.class).getHostedConnection(e.getId()), e.getId().getId(), targetLocation);
}
*/
//getStateListener(hc).setSelf(selfId, initialPosition);
GameEntities.createWarpEffect(origLocationVec3d, ed);
GameEntities.createWarpEffect(targetLocation, ed);
ed.removeComponent(e.getId(), WarpTo.class);
}
else{
throw new RuntimeException("Entity has a body position, but no physical body");
}
}
}
}
But as I wrote above, mixing game logic with session logic seems like a no-go to me - but it would be a work around ‘for now’.