コード例 #1
0
 /** Load the list of trains which the module will use. */
 public void setTrainList(ArrayList<Train> trainList) {
   this.trainList = trainList;
   if ((trainList != null) && (trainList.size() > 0)) {
     idArray = new String[trainList.size()];
     for (int i = 0; i < trainList.size(); i++) {
       idArray[i] = new String(trainList.get(i).stringId);
     }
   } else {
     idArray = null;
   }
 }
コード例 #2
0
 /** Return a list containing all trains which are in the Block with given id. */
 public ArrayList<Train> getTrainsInBlock(int id) {
   ArrayList<Train> tempAL = new ArrayList<Train>();
   for (int i = 0; i < trainList.size(); i++) {
     if (trainList.get(i).positionBlock.id == id) {
       tempAL.add(trainList.get(i));
     }
   }
   return tempAL;
 }
コード例 #3
0
  /** Updates all train data and refreshes the GUI. */
  public static void timeTick(Date date, int delta) {
    if (!isPaused) {
      refreshUI += delta;
      double time = date.getHours() * 60 * 60 + date.getMinutes() * 60 + date.getSeconds();

      for (int i = 0; i < trainList.size(); i++) {
        // Update the data for each train.
        boolean isSelectedByTNC = false;
        if (!isSolo) {
          isSelectedByTNC = tncUI.uiSelect(trainList.get(i).id);
        }
        trainList.get(i).timeTick(time, ((double) (delta)) / 1000.0, isSolo, isSelectedByTNC);
      }

      if (refreshUI >= 1000) {
        // Refresh the train module GUI.

        if (isSolo) {
          // If TNM is running solo, figure out the new time.
          soloTime += 1;
          if (soloTime >= 24 * 60 * 60) {
            soloTime = soloTime % (24 * 60 * 60);
          }
          int hrs = (int) soloTime / (60 * 60);
          int min = ((int) soloTime / 60) % 60;
          int sec = (int) soloTime - (hrs * 60 * 60 + min * 60);
          soloDate = new Date(93, 2, 2, hrs, min, sec);
        } else {
          soloTime = time;
        }

        refreshUI = refreshUI % 1000;
        setSelectedId(selectedId);
      }
    }
  }