Grab our starting location from the scene when we switch scenes so that
getIntendedLocation() will return a valid value even before we've moved somewhere in our new scene. git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@327 c613c5cb-e716-0410-b11b-feb51c14d237
This commit is contained in:
@@ -39,18 +39,20 @@ import com.threerings.crowd.chat.client.ChatDirector;
|
|||||||
import com.threerings.crowd.chat.data.ChatCodes;
|
import com.threerings.crowd.chat.data.ChatCodes;
|
||||||
import com.threerings.crowd.client.LocationAdapter;
|
import com.threerings.crowd.client.LocationAdapter;
|
||||||
import com.threerings.crowd.client.LocationDirector;
|
import com.threerings.crowd.client.LocationDirector;
|
||||||
|
import com.threerings.crowd.data.BodyObject;
|
||||||
import com.threerings.crowd.data.PlaceObject;
|
import com.threerings.crowd.data.PlaceObject;
|
||||||
|
|
||||||
import com.threerings.whirled.client.SceneDirector;
|
import com.threerings.whirled.client.SceneDirector;
|
||||||
import com.threerings.whirled.data.SceneModel;
|
import com.threerings.whirled.data.SceneModel;
|
||||||
import com.threerings.whirled.data.ScenedBodyObject;
|
|
||||||
import com.threerings.whirled.util.WhirledContext;
|
import com.threerings.whirled.util.WhirledContext;
|
||||||
|
|
||||||
import com.threerings.whirled.spot.data.ClusteredBodyObject;
|
import com.threerings.whirled.spot.data.ClusteredBodyObject;
|
||||||
import com.threerings.whirled.spot.data.Location;
|
import com.threerings.whirled.spot.data.Location;
|
||||||
import com.threerings.whirled.spot.data.Portal;
|
import com.threerings.whirled.spot.data.Portal;
|
||||||
|
import com.threerings.whirled.spot.data.SceneLocation;
|
||||||
import com.threerings.whirled.spot.data.SpotCodes;
|
import com.threerings.whirled.spot.data.SpotCodes;
|
||||||
import com.threerings.whirled.spot.data.SpotScene;
|
import com.threerings.whirled.spot.data.SpotScene;
|
||||||
|
import com.threerings.whirled.spot.data.SpotSceneObject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extends the standard scene director with facilities to move between locations within a scene.
|
* Extends the standard scene director with facilities to move between locations within a scene.
|
||||||
@@ -77,9 +79,7 @@ public class SpotSceneDirector extends BasicDirector
|
|||||||
_scdir = scdir;
|
_scdir = scdir;
|
||||||
|
|
||||||
// wire ourselves up to hear about leave place notifications
|
// wire ourselves up to hear about leave place notifications
|
||||||
locdir.addLocationObserver(new LocationAdapter(null, function (place :PlaceObject) :void {
|
locdir.addLocationObserver(new LocationAdapter(null, handleSceneChange, null));
|
||||||
handleDeparture();
|
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -121,10 +121,9 @@ public class SpotSceneDirector extends BasicDirector
|
|||||||
|
|
||||||
// sanity check the server's notion of what scene we're in with our notion of it
|
// sanity check the server's notion of what scene we're in with our notion of it
|
||||||
var sceneId :int = _scdir.getScene().getId();
|
var sceneId :int = _scdir.getScene().getId();
|
||||||
var sbobj :ScenedBodyObject = (_wctx.getClient().getClientObject() as ScenedBodyObject);
|
if (sceneId != _self.getSceneId()) {
|
||||||
if (sceneId != sbobj.getSceneId()) {
|
|
||||||
log.warning("Client and server differ in opinion of what scene we're in " +
|
log.warning("Client and server differ in opinion of what scene we're in " +
|
||||||
"[sSceneId=" + sbobj.getSceneId() + ", cSceneId=" + sceneId + "].");
|
"[sSceneId=" + _self.getSceneId() + ", cSceneId=" + sceneId + "].");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -375,12 +374,17 @@ public class SpotSceneDirector extends BasicDirector
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clean up after a few things when we depart from a scene.
|
* Called when we move from one scene to another, or to a non-scene.
|
||||||
*/
|
*/
|
||||||
protected function handleDeparture () :void
|
protected function handleSceneChange (plobj :PlaceObject) :void
|
||||||
{
|
{
|
||||||
// clear out our last known location id
|
// determine our location in the new scene if we have one
|
||||||
_location = null;
|
var scloc :SceneLocation = null;
|
||||||
|
var ssobj :SpotSceneObject = (plobj as SpotSceneObject);
|
||||||
|
if (ssobj != null) {
|
||||||
|
scloc = ssobj.occupantLocs.get((_self as BodyObject).getOid()) as SceneLocation;
|
||||||
|
}
|
||||||
|
_location = (scloc == null) ? null : scloc.loc;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user