Search in sources :

Example 1 with PreNpcSynchronizationTask

use of org.apollo.game.sync.task.PreNpcSynchronizationTask in project apollo by apollo-rsps.

the class SequentialClientSynchronizer method synchronize.

@Override
public void synchronize(MobRepository<Player> players, MobRepository<Npc> npcs) {
    Map<RegionCoordinates, Set<RegionUpdateMessage>> encodes = new HashMap<>(), updates = new HashMap<>();
    for (Player player : players) {
        SynchronizationTask task = new PrePlayerSynchronizationTask(player, encodes, updates);
        task.run();
    }
    for (Npc npc : npcs) {
        SynchronizationTask task = new PreNpcSynchronizationTask(npc);
        task.run();
    }
    for (Player player : players) {
        SynchronizationTask task = new PlayerSynchronizationTask(player);
        task.run();
        task = new NpcSynchronizationTask(player);
        task.run();
    }
    for (Player player : players) {
        SynchronizationTask task = new PostPlayerSynchronizationTask(player);
        task.run();
    }
    for (Npc npc : npcs) {
        SynchronizationTask task = new PostNpcSynchronizationTask(npc);
        task.run();
    }
}
Also used : Npc(org.apollo.game.model.entity.Npc) Player(org.apollo.game.model.entity.Player) Set(java.util.Set) PlayerSynchronizationTask(org.apollo.game.sync.task.PlayerSynchronizationTask) PrePlayerSynchronizationTask(org.apollo.game.sync.task.PrePlayerSynchronizationTask) PostPlayerSynchronizationTask(org.apollo.game.sync.task.PostPlayerSynchronizationTask) HashMap(java.util.HashMap) PrePlayerSynchronizationTask(org.apollo.game.sync.task.PrePlayerSynchronizationTask) NpcSynchronizationTask(org.apollo.game.sync.task.NpcSynchronizationTask) PlayerSynchronizationTask(org.apollo.game.sync.task.PlayerSynchronizationTask) PrePlayerSynchronizationTask(org.apollo.game.sync.task.PrePlayerSynchronizationTask) SynchronizationTask(org.apollo.game.sync.task.SynchronizationTask) PostNpcSynchronizationTask(org.apollo.game.sync.task.PostNpcSynchronizationTask) PostPlayerSynchronizationTask(org.apollo.game.sync.task.PostPlayerSynchronizationTask) PreNpcSynchronizationTask(org.apollo.game.sync.task.PreNpcSynchronizationTask) RegionCoordinates(org.apollo.game.model.area.RegionCoordinates) NpcSynchronizationTask(org.apollo.game.sync.task.NpcSynchronizationTask) PostNpcSynchronizationTask(org.apollo.game.sync.task.PostNpcSynchronizationTask) PreNpcSynchronizationTask(org.apollo.game.sync.task.PreNpcSynchronizationTask) PreNpcSynchronizationTask(org.apollo.game.sync.task.PreNpcSynchronizationTask) PostPlayerSynchronizationTask(org.apollo.game.sync.task.PostPlayerSynchronizationTask) PostNpcSynchronizationTask(org.apollo.game.sync.task.PostNpcSynchronizationTask)

Example 2 with PreNpcSynchronizationTask

use of org.apollo.game.sync.task.PreNpcSynchronizationTask 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();
}
Also used : Npc(org.apollo.game.model.entity.Npc) PhasedSynchronizationTask(org.apollo.game.sync.task.PhasedSynchronizationTask) Player(org.apollo.game.model.entity.Player) Set(java.util.Set) PlayerSynchronizationTask(org.apollo.game.sync.task.PlayerSynchronizationTask) PrePlayerSynchronizationTask(org.apollo.game.sync.task.PrePlayerSynchronizationTask) PostPlayerSynchronizationTask(org.apollo.game.sync.task.PostPlayerSynchronizationTask) PrePlayerSynchronizationTask(org.apollo.game.sync.task.PrePlayerSynchronizationTask) NpcSynchronizationTask(org.apollo.game.sync.task.NpcSynchronizationTask) PlayerSynchronizationTask(org.apollo.game.sync.task.PlayerSynchronizationTask) PrePlayerSynchronizationTask(org.apollo.game.sync.task.PrePlayerSynchronizationTask) SynchronizationTask(org.apollo.game.sync.task.SynchronizationTask) PostNpcSynchronizationTask(org.apollo.game.sync.task.PostNpcSynchronizationTask) PostPlayerSynchronizationTask(org.apollo.game.sync.task.PostPlayerSynchronizationTask) PreNpcSynchronizationTask(org.apollo.game.sync.task.PreNpcSynchronizationTask) PhasedSynchronizationTask(org.apollo.game.sync.task.PhasedSynchronizationTask) RegionCoordinates(org.apollo.game.model.area.RegionCoordinates) NpcSynchronizationTask(org.apollo.game.sync.task.NpcSynchronizationTask) PostNpcSynchronizationTask(org.apollo.game.sync.task.PostNpcSynchronizationTask) PreNpcSynchronizationTask(org.apollo.game.sync.task.PreNpcSynchronizationTask) PreNpcSynchronizationTask(org.apollo.game.sync.task.PreNpcSynchronizationTask) PostPlayerSynchronizationTask(org.apollo.game.sync.task.PostPlayerSynchronizationTask) PostNpcSynchronizationTask(org.apollo.game.sync.task.PostNpcSynchronizationTask) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap)

Aggregations

Set (java.util.Set)2 RegionCoordinates (org.apollo.game.model.area.RegionCoordinates)2 Npc (org.apollo.game.model.entity.Npc)2 Player (org.apollo.game.model.entity.Player)2 NpcSynchronizationTask (org.apollo.game.sync.task.NpcSynchronizationTask)2 PlayerSynchronizationTask (org.apollo.game.sync.task.PlayerSynchronizationTask)2 PostNpcSynchronizationTask (org.apollo.game.sync.task.PostNpcSynchronizationTask)2 PostPlayerSynchronizationTask (org.apollo.game.sync.task.PostPlayerSynchronizationTask)2 PreNpcSynchronizationTask (org.apollo.game.sync.task.PreNpcSynchronizationTask)2 PrePlayerSynchronizationTask (org.apollo.game.sync.task.PrePlayerSynchronizationTask)2 SynchronizationTask (org.apollo.game.sync.task.SynchronizationTask)2 HashMap (java.util.HashMap)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 PhasedSynchronizationTask (org.apollo.game.sync.task.PhasedSynchronizationTask)1