private void swap() {
// Record old tile
fOldTile = map().tile(fLayer, fTile.x(), fTile.y());
mapManager().parent().manager(GridManager.class).dispatcher().dispatch(fTile, "tilechange", new GridEvent());
// Swap with new tile
int tileid = map().tileset(fLayer).tile(fNewTile);
if (tileid >= 0) {
map().tile(fLayer, fTile.x(), fTile.y(), tileid);
// Queue if flip
frameManager().queue(new Minion<FrameEvent>() {
@Override
public long run(Dispatcher<FrameEvent> dispatcher, String type, FrameEvent event) {
map().tile(fLayer, fTile.x(), fTile.y(), fOldTile);
mapManager().parent().manager(GridManager.class).dispatcher().dispatch(fTile, "tilechange", new GridEvent());
return Minion.FINISH;
}
}, (long) Math.floor(timeManager().frameDuration(fFlip)));
}
}