|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.kolls.railworld.car.CachedCar
public class CachedCar
A cached car is useful for cars created by scripts.
To avoid a significant performance hit, scripts should wrap their cars
in cached cars when possible. A cached car caches: canUserCreate,
isEngine, isLoadable, color, segs, length, midColor, show, weight, loaded.
These values are gathered when the cached car is created, and also on a Car.load()
Car.unload() or SaveLoad.load(Map).
| Field Summary |
|---|
| Fields inherited from interface net.kolls.railworld.Car |
|---|
CAR_WIDTH, DIST_BETWEEN_CARS |
| Constructor Summary | |
|---|---|
CachedCar(Car c)
Create a cached car. |
|
| Method Summary | |
|---|---|
boolean |
canUserCreate()
Indicates if this car should appear in any user creation selection window. |
java.awt.Color |
color()
Return the Car's color. |
boolean |
isEngine()
Indicates if this car provides power. |
boolean |
isLoadable()
Determine if the current Car can be loaded and unloaded; that is, does it carry cargo. |
Distance |
length()
Returns the length of this Car. |
void |
load()
Loads the current Car. |
void |
load(java.util.Map<java.lang.String,java.lang.String> data)
Load from saved. |
boolean |
loaded()
Indicates if the Car is currently loaded. |
java.awt.Color |
midColor()
Indicates what the middle line (loaded) color should be. |
java.lang.Object |
newInstance()
like getClass().newInstance(). |
java.util.Map<java.lang.String,java.lang.String> |
save()
Store all persistent data into a map and return for saving. |
java.util.Set<RailSegment> |
segs()
For the current Car, returns the segments that the Car occupies, if any. |
java.lang.String |
show()
Gives a human-readable word for the Car. |
java.lang.String |
toString()
|
void |
unload()
Unloads the current Car. |
int |
weight()
Returns the weight of this Car (taking load/unload into account, if necessary) in US Tons. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public CachedCar(Car c)
c - Car to cache| Method Detail |
|---|
public boolean canUserCreate()
Car
canUserCreate in interface Carpublic java.awt.Color color()
Car
color in interface CarColor of the current Car.public boolean isEngine()
Car
isEngine in interface Carpublic boolean isLoadable()
Car
isLoadable in interface Cartrue if the Car may be loaded and unloaded. Defaults to true.public Distance length()
Car
length in interface CarDistance indicating the length of the Car.public void load()
Car
load in interface Carpublic boolean loaded()
Car
loaded in interface Cartrue if the car is loadable and is currently loaded.public java.awt.Color midColor()
CarTrainPainter.
midColor in interface CarColor of the middle line in the carpublic java.util.Set<RailSegment> segs()
Car
segs in interface CarSet of RailSegments.public java.lang.String show()
Car
show in interface CarString indicating type of Car.public void unload()
Car
unload in interface Carpublic int weight()
Car
weight in interface Carint representing weight in tons.public void load(java.util.Map<java.lang.String,java.lang.String> data)
SaveLoad
load in interface SaveLoaddata - Key value pairs saved by an instance of this classpublic java.lang.Object newInstance()
SaveLoad
newInstance in interface SaveLoadpublic java.util.Map<java.lang.String,java.lang.String> save()
SaveLoad
save in interface SaveLoadpublic java.lang.String toString()
toString in interface SaveLoadtoString in class java.lang.Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||