Archived
0

don't compute unladen ship mass if changes cargo or tank

This commit is contained in:
iMoHax
2016-04-05 13:06:50 +03:00
parent 58818ba2bc
commit 985f3b0f15

View File

@@ -157,7 +157,9 @@ public class ProfileModel {
} }
public void setShipMass(double shipMass) { public void setShipMass(double shipMass) {
updateUnladenMass(shipMass); double unladenMass = shipMass - profile.getShip().getTank() - profile.getShip().getCargo();
profile.getShip().setMass(unladenMass);
this.shipMass.set(profile.getShip().getLadenMass());
} }
public double getShipTank() { public double getShipTank() {
@@ -170,7 +172,7 @@ public class ProfileModel {
public void setShipTank(double shipTank) { public void setShipTank(double shipTank) {
profile.getShip().setTank(shipTank); profile.getShip().setTank(shipTank);
updateUnladenMass(getShipMass()); this.shipMass.set(profile.getShip().getLadenMass());
this.shipTank.set(shipTank); this.shipTank.set(shipTank);
} }
@@ -184,7 +186,7 @@ public class ProfileModel {
public void setShipCargo(int shipCargo) { public void setShipCargo(int shipCargo) {
profile.getShip().setCargo(shipCargo); profile.getShip().setCargo(shipCargo);
updateUnladenMass(getShipMass()); this.shipMass.set(profile.getShip().getLadenMass());
this.shipCargo.set(shipCargo); this.shipCargo.set(shipCargo);
} }
@@ -229,12 +231,6 @@ public class ProfileModel {
route.setValue(null); route.setValue(null);
} }
private void updateUnladenMass(double ladenMass){
double unladenMass = ladenMass - profile.getShip().getTank() - profile.getShip().getCargo();
profile.getShip().setMass(unladenMass);
this.shipMass.set(profile.getShip().getLadenMass());
}
private void refresh(){ private void refresh(){
name.setValue(profile.getName()); name.setValue(profile.getName());
balance.setValue(profile.getBalance()); balance.setValue(profile.getBalance());