From 0dcb5d67d1a677c9d44a63d5e11a541626793c5b Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Fri, 17 Jan 2003 22:57:08 +0000 Subject: [PATCH] Added Path.wasRemoved(), call it in the Sprite code. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@2178 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- src/java/com/threerings/media/sprite/Sprite.java | 14 ++++++++++++-- src/java/com/threerings/media/util/BobblePath.java | 8 +++++++- .../com/threerings/media/util/LineSegmentPath.java | 8 +++++++- src/java/com/threerings/media/util/Path.java | 10 +++++++++- src/java/com/threerings/media/util/TimedPath.java | 8 +++++++- 5 files changed, 42 insertions(+), 6 deletions(-) diff --git a/src/java/com/threerings/media/sprite/Sprite.java b/src/java/com/threerings/media/sprite/Sprite.java index dfd7460c4..459ecb189 100644 --- a/src/java/com/threerings/media/sprite/Sprite.java +++ b/src/java/com/threerings/media/sprite/Sprite.java @@ -1,5 +1,5 @@ // -// $Id: Sprite.java,v 1.59 2003/01/17 03:50:10 mdb Exp $ +// $Id: Sprite.java,v 1.60 2003/01/17 22:57:08 mdb Exp $ package com.threerings.media.sprite; @@ -215,6 +215,11 @@ public abstract class Sprite extends AbstractMedia */ public void move (Path path) { + // if there's a previous path, let it know that it's going away + if (_path != null) { + _path.wasRemoved(this); + } + // save off this path _path = path; @@ -230,7 +235,10 @@ public abstract class Sprite extends AbstractMedia // TODO: make sure we come to a stop on a full coordinate, // even in the case where we aborted a path mid-traversal. - _path = null; + if (_path != null) { + _path.wasRemoved(this); + _path = null; + } } /** @@ -257,6 +265,8 @@ public abstract class Sprite extends AbstractMedia { // keep a reference to the path just completed Path oldpath = _path; + // let the path know that it's audi + _path.wasRemoved(this); // clear out the path we've now finished _path = null; // inform observers that we've finished our path diff --git a/src/java/com/threerings/media/util/BobblePath.java b/src/java/com/threerings/media/util/BobblePath.java index d95e704c0..9d901044e 100644 --- a/src/java/com/threerings/media/util/BobblePath.java +++ b/src/java/com/threerings/media/util/BobblePath.java @@ -1,5 +1,5 @@ // -// $Id: BobblePath.java,v 1.2 2003/01/14 22:37:38 ray Exp $ +// $Id: BobblePath.java,v 1.3 2003/01/17 22:57:08 mdb Exp $ package com.threerings.media.util; @@ -131,6 +131,12 @@ public class BobblePath implements Path gfx.drawRect(_sx - _dx, _sy - _dy, _dx * 2, _dy * 2); } + // documentation inherited from interface + public void wasRemoved (Pathable pable) + { + // nothing doing + } + /** * Update the position of the pathable or return false * if it's already there. diff --git a/src/java/com/threerings/media/util/LineSegmentPath.java b/src/java/com/threerings/media/util/LineSegmentPath.java index ad346290f..572bf64a6 100644 --- a/src/java/com/threerings/media/util/LineSegmentPath.java +++ b/src/java/com/threerings/media/util/LineSegmentPath.java @@ -1,5 +1,5 @@ // -// $Id: LineSegmentPath.java,v 1.26 2002/12/04 02:45:09 shaper Exp $ +// $Id: LineSegmentPath.java,v 1.27 2003/01/17 22:57:08 mdb Exp $ package com.threerings.media.util; @@ -227,6 +227,12 @@ public class LineSegmentPath _nodestamp += timeDelta; } + // documentation inherited from interface + public void wasRemoved (Pathable pable) + { + // nothing doing + } + /** * Place the pathable moving along the path at the end of the previous * path node, face it appropriately for the next node, and start it on diff --git a/src/java/com/threerings/media/util/Path.java b/src/java/com/threerings/media/util/Path.java index 9de85e777..73aabc26a 100644 --- a/src/java/com/threerings/media/util/Path.java +++ b/src/java/com/threerings/media/util/Path.java @@ -1,5 +1,5 @@ // -// $Id: Path.java,v 1.9 2002/12/02 20:11:24 mdb Exp $ +// $Id: Path.java,v 1.10 2003/01/17 22:57:08 mdb Exp $ package com.threerings.media.util; @@ -53,4 +53,12 @@ public interface Path * Paint this path on the screen (used for debugging purposes only). */ public void paint (Graphics2D gfx); + + /** + * When a path is removed from a pathable, whether that is because the + * path was completed or because it was replaced by another path, this + * method will be called to let the path know that it is no longer + * associated with this pathable. + */ + public void wasRemoved (Pathable pable); } diff --git a/src/java/com/threerings/media/util/TimedPath.java b/src/java/com/threerings/media/util/TimedPath.java index b1abf432d..69e7ea989 100644 --- a/src/java/com/threerings/media/util/TimedPath.java +++ b/src/java/com/threerings/media/util/TimedPath.java @@ -1,5 +1,5 @@ // -// $Id: TimedPath.java,v 1.2 2002/12/02 20:11:24 mdb Exp $ +// $Id: TimedPath.java,v 1.3 2003/01/17 22:57:08 mdb Exp $ package com.threerings.media.util; @@ -44,6 +44,12 @@ public abstract class TimedPath implements Path _startStamp += timeDelta; } + // documentation inherited from interface + public void wasRemoved (Pathable pable) + { + // nothing doing + } + /** * Generates a string representation of this instance. */