use of org.apollo.game.model.entity.Player in project apollo by apollo-rsps.
the class ObjectActionVerificationHandlerTests method terminateIfOutOfRange.
@Test
public void terminateIfOutOfRange() throws Exception {
Position playerPosition = new Position(3200, 3200);
Position objectPosition = new Position(3200, 3216);
World world = mock(World.class);
Region region = mock(Region.class);
RegionRepository regionRepository = mock(RegionRepository.class);
Player player = mock(Player.class);
Set<Entity> entitySet = new HashSet<>();
entitySet.add(new StaticGameObject(world, 4151, objectPosition, 0, 0));
when(world.getRegionRepository()).thenReturn(regionRepository);
when(regionRepository.fromPosition(objectPosition)).thenReturn(region);
when(player.getPosition()).thenReturn(playerPosition);
when(region.getEntities(objectPosition, EntityType.STATIC_OBJECT, EntityType.DYNAMIC_OBJECT)).thenReturn(entitySet);
ObjectActionMessage objectActionMessage = new ObjectActionMessage(1, 4151, objectPosition);
ObjectActionVerificationHandler objectActionVerificationHandler = new ObjectActionVerificationHandler(world);
objectActionVerificationHandler.handle(player, objectActionMessage);
assertTrue("ObjectVerificationHandler: message not terminated when out of range!", objectActionMessage.terminated());
}
use of org.apollo.game.model.entity.Player in project apollo by apollo-rsps.
the class ParallelClientSynchronizer method synchronize.
@Override
public void synchronize(MobRepository<Player> players, MobRepository<Npc> npcs) {
int playerCount = players.size();
int npcCount = npcs.size();
Map<RegionCoordinates, Set<RegionUpdateMessage>> encodes = new ConcurrentHashMap<>();
Map<RegionCoordinates, Set<RegionUpdateMessage>> updates = new ConcurrentHashMap<>();
phaser.bulkRegister(playerCount);
for (Player player : players) {
SynchronizationTask task = new PrePlayerSynchronizationTask(player, encodes, updates);
executor.submit(new PhasedSynchronizationTask(phaser, task));
}
phaser.arriveAndAwaitAdvance();
phaser.bulkRegister(npcCount);
for (Npc npc : npcs) {
SynchronizationTask task = new PreNpcSynchronizationTask(npc);
executor.submit(new PhasedSynchronizationTask(phaser, task));
}
phaser.arriveAndAwaitAdvance();
phaser.bulkRegister(playerCount);
for (Player player : players) {
SynchronizationTask task = new PlayerSynchronizationTask(player);
executor.submit(new PhasedSynchronizationTask(phaser, task));
}
phaser.arriveAndAwaitAdvance();
phaser.bulkRegister(playerCount);
for (Player player : players) {
SynchronizationTask task = new NpcSynchronizationTask(player);
executor.submit(new PhasedSynchronizationTask(phaser, task));
}
phaser.arriveAndAwaitAdvance();
phaser.bulkRegister(playerCount);
for (Player player : players) {
SynchronizationTask task = new PostPlayerSynchronizationTask(player);
executor.submit(new PhasedSynchronizationTask(phaser, task));
}
phaser.arriveAndAwaitAdvance();
phaser.bulkRegister(npcCount);
for (Npc npc : npcs) {
SynchronizationTask task = new PostNpcSynchronizationTask(npc);
executor.submit(new PhasedSynchronizationTask(phaser, task));
}
phaser.arriveAndAwaitAdvance();
}
Aggregations