From: ChadF <ch...@us...> - 2007-07-12 01:03:33
|
Update of /cvsroot/arianne/stendhal/src/games/stendhal/server/entity In directory sc8-pr-cvs11.sourceforge.net:/tmp/cvs-serv10601/src/games/stendhal/server/entity Modified Files: GuidedEntity.java Log Message: Added more uses of abstracted path started before cvs freeze. Technically the path is independent of the path finder(s), and ideally would belong in *.server.path, but would require changing all the imports. Index: GuidedEntity.java =================================================================== RCS file: /cvsroot/arianne/stendhal/src/games/stendhal/server/entity/GuidedEntity.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** GuidedEntity.java 11 Jul 2007 15:37:03 -0000 1.10 --- GuidedEntity.java 12 Jul 2007 01:03:15 -0000 1.11 *************** *** 23,32 **** public abstract class GuidedEntity extends ActiveEntity { /** ! * The path. */ ! private FixedPath path; ! ! /** current position in the path */ ! private int pathPosition; --- 23,29 ---- public abstract class GuidedEntity extends ActiveEntity { /** ! * The current path. */ ! private Path path; *************** *** 72,87 **** * for the entity. * - * TODO: Change to accept just 'Path' after everything is converted - * to use opaque Path's rather than Node lists. - * * @param path The path. */ ! public void setPath(final FixedPath path) { if((path != null) && !path.isFinished()) { this.path = path; - this.pathPosition = 0; setSpeed(getBaseSpeed()); ! Path.followPath(this); } else { clearPath(); --- 69,80 ---- * for the entity. * * @param path The path. */ ! public void setPath(final Path path) { if((path != null) && !path.isFinished()) { this.path = path; setSpeed(getBaseSpeed()); ! path.follow(this); } else { clearPath(); *************** *** 95,99 **** public void clearPath() { this.path = null; - this.pathPosition = 0; } --- 88,91 ---- *************** *** 110,125 **** /** ! * Get the path list. */ ! public List<Node> getPathList() { ! return (path != null) ? path.getNodeList() : null; } /** ! * Is the path a loop. */ ! public boolean isPathLoop() { ! return (path != null) ? path.isLoop() : false; } --- 102,126 ---- /** ! * Get the path. ! * ! * @return The current path, or <code>null</code> if none. */ ! public Path getPath() { ! return path; } /** ! * Get the path list. ! * TODO: Not depend on FixedPath's. ! * ! * @return A list of path points. */ ! public List<Node> getPathList() { ! if(path instanceof FixedPath) { ! return ((FixedPath) path).getNodeList(); ! } else { ! return null; ! } } *************** *** 127,141 **** /** * Get the path nodes position. */ public int getPathPosition() { ! return pathPosition; ! } ! ! ! /** ! * Set the path nodes position. ! */ ! public void setPathPosition(int pathPos) { ! this.pathPosition = pathPos; } --- 128,141 ---- /** * Get the path nodes position. + * TODO: Not assume FixedPath's. + * + * @return The current position in a fixed path. */ public int getPathPosition() { ! if(path instanceof FixedPath) { ! return ((FixedPath) path).getPosition(); ! } else { ! return 0; ! } } *************** *** 151,159 **** public void applyMovement() { if (hasPath()) { ! Path.followPath(this); notifyWorldAboutChanges(); } super.applyMovement(); } } --- 151,174 ---- public void applyMovement() { if (hasPath()) { ! if(!path.follow(this)) { ! stop(); ! } ! notifyWorldAboutChanges(); } + // TODO: Eventually only call super if a path is set, + // once GuidedEntity only uses Path for movement. super.applyMovement(); } + + + /** + * Stops entity movement. + */ + @Override + public void stop() { + setPath(null); + super.stop(); + } } |