|
|
@ -78,6 +78,11 @@ public class Train extends BaseClass implements Comparable<Train> { |
|
|
|
private Block currentBlock,destination = null; |
|
|
|
private Block currentBlock,destination = null; |
|
|
|
LinkedList<Tile> trace = new LinkedList<Tile>(); |
|
|
|
LinkedList<Tile> trace = new LinkedList<Tile>(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public int speed = 0; |
|
|
|
|
|
|
|
private Autopilot autopilot = null; |
|
|
|
|
|
|
|
private Route nextRoute; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private class Autopilot extends Thread{ |
|
|
|
private class Autopilot extends Thread{ |
|
|
|
boolean stop = false; |
|
|
|
boolean stop = false; |
|
|
|
int waitTime = 100; |
|
|
|
int waitTime = 100; |
|
|
@ -103,13 +108,6 @@ public class Train extends BaseClass implements Comparable<Train> { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public int speed = 0; |
|
|
|
|
|
|
|
private Autopilot autopilot = null; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private Plan plan; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private Route nextRoute; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public Train(Locomotive loco) { |
|
|
|
public Train(Locomotive loco) { |
|
|
|
this(loco,null); |
|
|
|
this(loco,null); |
|
|
|
} |
|
|
|
} |
|
|
@ -257,7 +255,8 @@ public class Train extends BaseClass implements Comparable<Train> { |
|
|
|
private static Object create(HashMap<String, String> params, Plan plan) { |
|
|
|
private static Object create(HashMap<String, String> params, Plan plan) { |
|
|
|
Locomotive loco = (Locomotive) Locomotive.get(params.get(Train.LOCO_ID)); |
|
|
|
Locomotive loco = (Locomotive) Locomotive.get(params.get(Train.LOCO_ID)); |
|
|
|
if (isNull(loco)) return t("unknown locomotive: {}",params.get(ID)); |
|
|
|
if (isNull(loco)) return t("unknown locomotive: {}",params.get(ID)); |
|
|
|
Train train = new Train(loco).plan(plan); |
|
|
|
Train train = new Train(loco); |
|
|
|
|
|
|
|
train.parent(plan); |
|
|
|
if (params.containsKey(NAME)) train.name(params.get(NAME)); |
|
|
|
if (params.containsKey(NAME)) train.name(params.get(NAME)); |
|
|
|
return train; |
|
|
|
return train; |
|
|
|
} |
|
|
|
} |
|
|
@ -379,7 +378,7 @@ public class Train extends BaseClass implements Comparable<Train> { |
|
|
|
JSONObject json = new JSONObject(line); |
|
|
|
JSONObject json = new JSONObject(line); |
|
|
|
|
|
|
|
|
|
|
|
Train train = new Train(null,Id.from(json)); |
|
|
|
Train train = new Train(null,Id.from(json)); |
|
|
|
train.plan(plan).load(json); |
|
|
|
train.load(json).parent(plan); |
|
|
|
|
|
|
|
|
|
|
|
line = file.readLine(); |
|
|
|
line = file.readLine(); |
|
|
|
} |
|
|
|
} |
|
|
@ -498,11 +497,6 @@ public class Train extends BaseClass implements Comparable<Train> { |
|
|
|
return this; |
|
|
|
return this; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private Train plan(Plan plan) { |
|
|
|
|
|
|
|
this.plan = plan; |
|
|
|
|
|
|
|
return this; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected Window properties(List<Fieldset> preForm, FormInput formInputs, List<Fieldset> postForm) { |
|
|
|
protected Window properties(List<Fieldset> preForm, FormInput formInputs, List<Fieldset> postForm) { |
|
|
|
Fieldset otherTrainProsps = new Fieldset(t("other train properties")); |
|
|
|
Fieldset otherTrainProsps = new Fieldset(t("other train properties")); |
|
|
@ -570,6 +564,7 @@ public class Train extends BaseClass implements Comparable<Train> { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void removeChild(BaseClass child) { |
|
|
|
public void removeChild(BaseClass child) { |
|
|
|
if (child == route) route = null; |
|
|
|
if (child == route) route = null; |
|
|
|
|
|
|
|
if (child == nextRoute) nextRoute = null; |
|
|
|
if (child == currentBlock) currentBlock = null; |
|
|
|
if (child == currentBlock) currentBlock = null; |
|
|
|
if (child == destination) destination = null; |
|
|
|
if (child == destination) destination = null; |
|
|
|
cars.remove(child); |
|
|
|
cars.remove(child); |
|
|
|