jfreerails.controller
Class TrainAccessor
java.lang.Object
jfreerails.controller.TrainAccessor
public class TrainAccessor
- extends java.lang.Object
Provides convenience methods to access the properties of a train from the
world object.
- Author:
- Luke
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
w
private final ReadOnlyWorld w
p
private final FreerailsPrincipal p
id
private final int id
TrainAccessor
public TrainAccessor(ReadOnlyWorld w,
FreerailsPrincipal p,
int id)
getId
public int getId()
getStatus
public SpeedTimeAndStatus.TrainActivity getStatus(double time)
getStationId
public int getStationId(double time)
- Returns:
- the id of the station the train is currently at, or -1 if no
current station.
findPosition
public TrainPositionOnMap findPosition(double time)
findCurrentMotion
public TrainMotion findCurrentMotion(double time)
getTrain
public TrainModel getTrain()
getSchedule
public ImmutableSchedule getSchedule()
getCargoBundle
public ImmutableCargoBundle getCargoBundle()
keepWaiting
public boolean keepWaiting()
- Returns true iff all the following hold.
- The train is waiting for a full load at some station X.
- The current train order tells the train to goto station X.
- The current train order tells the train to wait for a full load.
- The current train order specifies a consist that matches the train's current consist.
getTarget
public ImPoint getTarget()
- Returns:
- the location of the station the train is currently heading
towards.
occupiedTrackSection
public java.util.HashSet<TrackSection> occupiedTrackSection(double time)
isMoving
public boolean isMoving(double time)
spaceAvailable
public ImInts spaceAvailable()
- The space available on the train measured in cargo units.
spaceAvailable2
public static ImInts spaceAvailable2(ReadOnlyWorld row,
ImmutableCargoBundle onTrain,
ImInts consist)