From: ChadF <ch...@us...> - 2007-07-12 02:53:13
|
Update of /cvsroot/arianne/stendhal/src/games/stendhal/server/entity In directory sc8-pr-cvs11.sourceforge.net:/tmp/cvs-serv23074/src/games/stendhal/server/entity Modified Files: ActiveEntity.java GuidedEntity.java Log Message: Changed remaining old direction motion code to use setPath() [everything using setPath() now?]. Replaced Path.faceto() with ActiveEntity.faceToward(). Index: GuidedEntity.java =================================================================== RCS file: /cvsroot/arianne/stendhal/src/games/stendhal/server/entity/GuidedEntity.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** GuidedEntity.java 12 Jul 2007 01:03:15 -0000 1.11 --- GuidedEntity.java 12 Jul 2007 02:53:11 -0000 1.12 *************** *** 16,19 **** --- 16,21 ---- import java.util.List; + import marauroa.common.Log4J; + import marauroa.common.Logger; import marauroa.common.game.RPObject; *************** *** 23,26 **** --- 25,33 ---- public abstract class GuidedEntity extends ActiveEntity { /** + * The logger. + */ + private static final Logger logger = Log4J.getLogger(GuidedEntity.class); + + /** * The current path. */ *************** *** 156,159 **** --- 163,168 ---- notifyWorldAboutChanges(); + } else if(!isStopped()) { + logger.debug("WARNING: Moving without path: " + this); } Index: ActiveEntity.java =================================================================== RCS file: /cvsroot/arianne/stendhal/src/games/stendhal/server/entity/ActiveEntity.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** ActiveEntity.java 3 Jul 2007 17:55:58 -0000 1.14 --- ActiveEntity.java 12 Jul 2007 02:53:11 -0000 1.15 *************** *** 178,181 **** --- 178,192 ---- /** + * Face toward a point. + * + * @param x The target X coordinate. + * @param y The target Y coordinate. + */ + public void faceToward(final int x, final int y) { + setDirection(getDirectionToward(x, y)); + } + + + /** * Generate the RPClass (compatible with manual init/order). * *************** *** 207,211 **** Rectangle2D area = entity.getArea(); ! return getDirectionToward(area.getCenterX(), area.getCenterY()); } --- 218,222 ---- Rectangle2D area = entity.getArea(); ! return getDirectionToward((int) area.getCenterX(), (int) area.getCenterY()); } *************** *** 219,230 **** * @return A facing direction. */ ! private Direction getDirectionToward(final double x, final double y) { ! Rectangle2D area = getArea(); ! ! double rx = area.getCenterX(); ! double ry = area.getCenterY(); ! if (Math.abs(x - rx) > Math.abs(y - ry)) { ! if (x - rx > 0) { return Direction.RIGHT; } else { --- 230,239 ---- * @return A facing direction. */ ! private Direction getDirectionToward(final int x, final int y) { ! int dx = x - getX(); ! int dy = y - getY(); ! if (Math.abs(dx) > Math.abs(dy)) { ! if (dx > 0) { return Direction.RIGHT; } else { *************** *** 232,236 **** } } else { ! if (y - ry > 0) { return Direction.DOWN; } else { --- 241,245 ---- } } else { ! if (dy > 0) { return Direction.DOWN; } else { *************** *** 252,255 **** --- 261,276 ---- /** + * Determine if moving a direction would [currently] be blocked. + * + * @param dir The direction to test. + * + * @return <code>true</code> if that direction is blocked. + */ + public boolean isDirectionBlocked(final Direction dir) { + return getZone().collides(this, getX() + dir.getdx(), getY() + dir.getdy()); + } + + + /** * Determine if this entity is facing toward another entity. * |