use of org.apollo.cache.map.MapObjectsDecoder in project apollo by apollo-rsps.
the class WorldObjectsDecoder method run.
/**
* Decode the {@code MapObject}s from the cache and register them with the world.
*/
@Override
public void run() {
Map<Integer, MapIndex> mapIndices = MapIndex.getIndices();
try {
for (MapIndex index : mapIndices.values()) {
MapObjectsDecoder decoder = MapObjectsDecoder.create(fs, index);
List<MapObject> objects = decoder.decode();
int mapX = index.getX(), mapY = index.getY();
for (MapObject object : objects) {
Position position = new Position(mapX + object.getLocalX(), mapY + object.getLocalY(), object.getHeight());
StaticGameObject gameObject = new StaticGameObject(world, object.getId(), position, object.getType(), object.getOrientation());
regionRepository.fromPosition(position).addEntity(gameObject, false);
}
}
} catch (IOException ex) {
throw new UncheckedIOException(ex);
}
}
Aggregations