Wired up rest of location change stuff.
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@776 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: SceneDirector.java,v 1.8 2001/12/04 00:30:27 mdb Exp $
|
||||
// $Id: SceneDirector.java,v 1.9 2001/12/14 01:51:45 mdb Exp $
|
||||
|
||||
package com.threerings.whirled.client;
|
||||
|
||||
@@ -304,10 +304,8 @@ public class SceneDirector
|
||||
* to enter. */
|
||||
protected SceneModel _pendingModel;
|
||||
|
||||
/**
|
||||
* The id of the scene for which we have an outstanding moveTo
|
||||
* request, or -1 if we have no outstanding request.
|
||||
*/
|
||||
/** The id of the scene for which we have an outstanding moveTo
|
||||
* request, or -1 if we have no outstanding request. */
|
||||
protected int _pendingSceneId = -1;
|
||||
|
||||
/** The id of the scene we previously occupied. */
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: SceneManager.java,v 1.8 2001/11/12 20:56:56 mdb Exp $
|
||||
// $Id: SceneManager.java,v 1.9 2001/12/14 01:51:46 mdb Exp $
|
||||
|
||||
package com.threerings.whirled.server;
|
||||
|
||||
@@ -40,12 +40,25 @@ public class SceneManager extends PlaceManager
|
||||
* Called by the scene registry once the scene manager has been
|
||||
* created (and initialized), but before it is started up.
|
||||
*/
|
||||
protected void postInit (
|
||||
protected void setSceneData (
|
||||
RuntimeScene scene, SceneModel model, SceneRegistry screg)
|
||||
{
|
||||
_scene = scene;
|
||||
_model = model;
|
||||
_screg = screg;
|
||||
|
||||
// let derived classes react to the receipt of scene data
|
||||
gotSceneData();
|
||||
}
|
||||
|
||||
/**
|
||||
* A method that can be overridden by derived classes to perform
|
||||
* initialization processing after we receive our scene information
|
||||
* but before we're started up (and hence registered as an active
|
||||
* place).
|
||||
*/
|
||||
protected void gotSceneData ()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: SceneRegistry.java,v 1.11 2001/12/13 07:23:25 mdb Exp $
|
||||
// $Id: SceneRegistry.java,v 1.12 2001/12/14 01:51:46 mdb Exp $
|
||||
|
||||
package com.threerings.whirled.server;
|
||||
|
||||
@@ -194,7 +194,7 @@ public class SceneRegistry
|
||||
// stuff; we'll somehow need to convey configuration
|
||||
// information for the scene to the scene manager, but for now
|
||||
// let's punt
|
||||
scmgr.postInit(scene, model, this);
|
||||
scmgr.setSceneData(scene, model, this);
|
||||
|
||||
// when the scene manager completes its startup procedings, it
|
||||
// will call back to the scene registry and let us know that
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: SpotSceneDirector.java,v 1.1 2001/12/14 00:12:32 mdb Exp $
|
||||
// $Id: SpotSceneDirector.java,v 1.2 2001/12/14 01:51:46 mdb Exp $
|
||||
|
||||
package com.threerings.whirled.spot.client;
|
||||
|
||||
@@ -22,6 +22,24 @@ import com.threerings.whirled.spot.data.Location;
|
||||
public class SpotSceneDirector extends SceneDirector
|
||||
implements SpotCodes
|
||||
{
|
||||
/**
|
||||
* This is used to communicate back to the caller of {@link
|
||||
* #changeLocation}.
|
||||
*/
|
||||
public static interface ChangeObserver
|
||||
{
|
||||
/**
|
||||
* Indicates that the requested location change succeeded.
|
||||
*/
|
||||
public void locationChangeSucceeded (int locationId);
|
||||
|
||||
/**
|
||||
* Indicates that the requested location change failed and
|
||||
* provides a reason code explaining the failure.
|
||||
*/
|
||||
public void locationChangeFailed (int locationId, String reason);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new spot scene director with the specified context.
|
||||
*
|
||||
@@ -39,9 +57,15 @@ public class SpotSceneDirector extends SceneDirector
|
||||
|
||||
/**
|
||||
* Issues a request to change our location within the scene to the
|
||||
* location identified by the specified id.
|
||||
* location identified by the specified id. Most client entities find
|
||||
* out about location changes via changes to the occupant info data,
|
||||
* but the initiator of a location change request can be notified of
|
||||
* its success or failure, primarily so that it can act in
|
||||
* anticipation of a successful location change (like by starting a
|
||||
* sprite moving toward the new location), but backtrack if it finds
|
||||
* out that the location change failed.
|
||||
*/
|
||||
public void changeLocation (int locationId)
|
||||
public void changeLocation (int locationId, ChangeObserver obs)
|
||||
{
|
||||
// refuse if there's a pending location change
|
||||
if (_pendingLocId != -1) {
|
||||
@@ -76,6 +100,7 @@ public class SpotSceneDirector extends SceneDirector
|
||||
|
||||
// make a note that we're changing to this location
|
||||
_pendingLocId = locationId;
|
||||
_changeObserver = obs;
|
||||
// and send the location change request
|
||||
SpotService.changeLoc(_ctx.getClient(), _sceneId, locationId, this);
|
||||
}
|
||||
@@ -85,6 +110,17 @@ public class SpotSceneDirector extends SceneDirector
|
||||
*/
|
||||
public void handleChangeLocSucceeded (int invid)
|
||||
{
|
||||
ChangeObserver obs = _changeObserver;
|
||||
int locId = _pendingLocId;
|
||||
|
||||
// clear out our pending location info
|
||||
_pendingLocId = -1;
|
||||
_changeObserver = null;
|
||||
|
||||
// if we had an observer, let them know things went well
|
||||
if (obs != null) {
|
||||
obs.locationChangeSucceeded(locId);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -92,9 +128,24 @@ public class SpotSceneDirector extends SceneDirector
|
||||
*/
|
||||
public void handleChangeLocFailed (int invid, String reason)
|
||||
{
|
||||
ChangeObserver obs = _changeObserver;
|
||||
int locId = _pendingLocId;
|
||||
|
||||
// clear out our pending location info
|
||||
_pendingLocId = -1;
|
||||
_changeObserver = null;
|
||||
|
||||
// if we had an observer, let them know things went well
|
||||
if (obs != null) {
|
||||
obs.locationChangeFailed(locId, reason);
|
||||
}
|
||||
}
|
||||
|
||||
/** The location id on which we have an outstanding change location
|
||||
* request. */
|
||||
protected int _pendingLocId = -1;
|
||||
|
||||
/** An entity that wants to know if a requested location change
|
||||
* succeded or failed. */
|
||||
protected ChangeObserver _changeObserver;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user