use of org.apollo.game.message.impl.RegionChangeMessage in project apollo by apollo-rsps.
the class PrePlayerSynchronizationTask method run.
@Override
public void run() {
Position old = player.getPosition();
player.getWalkingQueue().pulse();
boolean local = true;
if (player.isTeleporting()) {
player.resetViewingDistance();
local = false;
}
Position position = player.getPosition();
if (!player.hasLastKnownRegion() || isRegionUpdateRequired()) {
player.setRegionChanged(true);
local = false;
player.setLastKnownRegion(position);
player.send(new RegionChangeMessage(position));
}
RegionRepository repository = player.getWorld().getRegionRepository();
Set<RegionCoordinates> oldViewable = repository.fromPosition(old).getSurrounding();
Set<RegionCoordinates> newViewable = repository.fromPosition(position).getSurrounding();
Set<RegionCoordinates> differences = new HashSet<>(newViewable);
differences.retainAll(oldViewable);
Set<RegionCoordinates> full = new HashSet<>(newViewable);
if (local) {
full.removeAll(oldViewable);
}
sendUpdates(player.getLastKnownRegion(), differences, full);
}
Aggregations