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
This commit is contained in:
@@ -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;
|
package com.threerings.media.sprite;
|
||||||
|
|
||||||
@@ -215,6 +215,11 @@ public abstract class Sprite extends AbstractMedia
|
|||||||
*/
|
*/
|
||||||
public void move (Path path)
|
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
|
// save off this path
|
||||||
_path = 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,
|
// TODO: make sure we come to a stop on a full coordinate,
|
||||||
// even in the case where we aborted a path mid-traversal.
|
// 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
|
// keep a reference to the path just completed
|
||||||
Path oldpath = _path;
|
Path oldpath = _path;
|
||||||
|
// let the path know that it's audi
|
||||||
|
_path.wasRemoved(this);
|
||||||
// clear out the path we've now finished
|
// clear out the path we've now finished
|
||||||
_path = null;
|
_path = null;
|
||||||
// inform observers that we've finished our path
|
// inform observers that we've finished our path
|
||||||
|
|||||||
@@ -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;
|
package com.threerings.media.util;
|
||||||
|
|
||||||
@@ -131,6 +131,12 @@ public class BobblePath implements Path
|
|||||||
gfx.drawRect(_sx - _dx, _sy - _dy, _dx * 2, _dy * 2);
|
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
|
* Update the position of the pathable or return false
|
||||||
* if it's already there.
|
* if it's already there.
|
||||||
|
|||||||
@@ -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;
|
package com.threerings.media.util;
|
||||||
|
|
||||||
@@ -227,6 +227,12 @@ public class LineSegmentPath
|
|||||||
_nodestamp += timeDelta;
|
_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
|
* 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
|
* path node, face it appropriately for the next node, and start it on
|
||||||
|
|||||||
@@ -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;
|
package com.threerings.media.util;
|
||||||
|
|
||||||
@@ -53,4 +53,12 @@ public interface Path
|
|||||||
* Paint this path on the screen (used for debugging purposes only).
|
* Paint this path on the screen (used for debugging purposes only).
|
||||||
*/
|
*/
|
||||||
public void paint (Graphics2D gfx);
|
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);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
package com.threerings.media.util;
|
||||||
|
|
||||||
@@ -44,6 +44,12 @@ public abstract class TimedPath implements Path
|
|||||||
_startStamp += timeDelta;
|
_startStamp += timeDelta;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// documentation inherited from interface
|
||||||
|
public void wasRemoved (Pathable pable)
|
||||||
|
{
|
||||||
|
// nothing doing
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates a string representation of this instance.
|
* Generates a string representation of this instance.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user