コード例 #1
0
  @Override
  public void start() {
    log.info("Initializing world");
    // initialize maps
    worldMapData.iterate(
        new MemberVisitor<WorldMapTemplate>() {

          @Override
          public void visit(WorldMapTemplate template) {
            int worldMapId = template.getTemplateId();
            // skip initialization of the disabled maps
            if (WorldConfig.WORLDMAP_DISABLED.contains(worldMapId)) {
              return;
            }
            // create new world map
            WorldMap worldMap = new WorldMap(template, world);
            world.addWorldMap(template.getTemplateId(), worldMap);
            initializeWorldMap(template);
          }
        });
    log.info("Initialized {} world maps", world.mapCount());
    // initialize containers
    world.addContainer(ContainerType.PC, new PlainObjectContainer());
    world.addContainer(ContainerType.NPC, new PlainObjectContainer());
  }
コード例 #2
0
  /**
   * Create all default world map instances according to template<br>
   * For non-instances with undefined twin count - default to one channel<br>
   * <br>
   * Note that worldMap object should already be in {@code world} mapping
   *
   * @param template
   */
  private void initializeWorldMap(WorldMapTemplate template) {

    // dont initialize instance-type maps
    if (template.isInstance()) return;

    int twinCount = template.getTwinCount();
    // for non-instances with not defined twin count - default to 1 channel
    if (twinCount == 0 && !template.isInstance()) twinCount = 1;
    for (int i = 0; i < twinCount; i++) {
      worldInstanceService.createNewInstance(template.getTemplateId());
    }

    WorldMap worldMap = world.getWorldMap(template.getTemplateId());
    if (worldMap.size() > 0)
      log.info(
          "Initialized {} world map with {} channel(s)", template.getTemplateId(), worldMap.size());
  }
コード例 #3
0
 @Override
 public boolean isInstance(int mapId) {
   WorldMap worldMap = world.getWorldMap(mapId);
   return worldMap != null ? worldMap.getWorldMapTemplate().isInstance() : false;
 }
コード例 #4
0
 @Override
 public int mapCount() {
   return world.mapCount();
 }