Пример #1
0
 public void printError(java.io.PrintStream o) {
   if (failureMode != null) {
     failureMode.printStackTrace(o);
   } else {
     if (out != null && out.checkError()) o.println(outputFileName + ": Output write error");
   }
 }
  public void Visit(Mech m) throws Exception {
    CurMech = m;
    boolean CASEInstalled = false;
    boolean SChargerInstalled = false;
    Gyro g = CurMech.GetGyro();
    ifMechLoadout l = CurMech.GetLoadout();

    // see if we have CASE installed in the CT
    if (CurMech.HasCTCase()) {
      // remove it.  We may not be able to replace it, but we'll try
      CASEInstalled = true;
      CurMech.RemoveCTCase();
    }

    // see if we have a supercharger installed
    if (CurMech.GetLoadout().HasSupercharger()) {
      if (CurMech.GetLoadout().Find(CurMech.GetLoadout().GetSupercharger())
          == LocationIndex.MECH_LOC_CT) {
        SChargerInstalled = true;
        try {
          CurMech.GetLoadout().SetSupercharger(false, -1, -1);
        } catch (Exception e) {
          // wow, a problem removing it.  Log it for later.
          System.err.println(e.getMessage());
        }
      }
    }

    // We have to remove the engine as well as mess with the gyro here
    m.GetEngine().Remove(l);

    // remove the gyro crits
    g.Remove(l);

    // change the gyro
    g.SetStandard();

    // place the gyro
    if (!g.Place(l)) {
      throw new Exception("Standard Gyro cannot be allocated!");
    }

    // now replace the engine criticals
    if (!m.GetEngine().Place(l)) {
      throw new Exception(m.GetEngine().LookupName() + " cannot be allocated!");
    }

    // if we had CASE installed, try to replace it
    if (CASEInstalled) {
      // at this point, we don't care whether it happened or not since the
      // primary inhabitants of the CT are taken care of.
      try {
        CurMech.AddCTCase();
      } catch (Exception e) {
        // unhandled at this time.  write out a system error
        System.err.println(e.getMessage());
      }
    }

    // try to reinstall the Supercharger
    if (SChargerInstalled) {
      try {
        CurMech.GetLoadout().SetSupercharger(true, LocationIndex.MECH_LOC_CT, -1);
      } catch (Exception e) {
        System.err.println(e.getMessage());
      }
    }
  }