@Override
  public void load() throws Exception {
    File file = Game.getInstance().getRelativeFile(Game.FILE_BASE_USER_DATA, "${world}/world.dat");

    if (!file.exists()) {
      System.err.println("No level data found! " + file.getPath());
      return;
    }

    DataInputStream dis = new DataInputStream(new BufferedInputStream(new FileInputStream(file)));

    _world.setTime(dis.readFloat());

    _spawnPoint = new Vec3f();
    IOUtilities.readVec3f(dis, _spawnPoint);

    readDataPointList(dis, _rawHeights);
    readDataPointList(dis, _heights);
    readDataPointList(dis, _humidities);
    readDataPointList(dis, _temperatures);

    /* Tree Definitions */
    {
      int size = dis.readInt();
      for (int i = 0; i < size; ++i) {
        TreeDefinition dp2d = new TreeDefinition(0, 0, 0, 0);
        dp2d.x = dis.readInt();
        dp2d.y = dis.readInt();
        dp2d.z = dis.readInt();
        dp2d.type = dis.readByte();
      }
    }

    dis.close();
  }
示例#2
0
文件: Tree.java 项目: tpso-src/cocoon
 protected Tree(TreeDefinition definition) {
   super(definition);
   this.treeDef = definition;
   this.rootVisible = definition.isRootVisible();
   if (!this.rootVisible) {
     // Expand it so that first-level children are visible
     this.expandedPaths.add(TreePath.ROOT_PATH);
   }
   this.treeModel = definition.createModel();
   this.treeModel.addTreeModelListener(modelListener);
   this.selectionListener = definition.getSelectionListener();
   this.selectionModel = definition.getSelectionModel();
 }