Updates to reflect new BodyObject.location change. We now have a ScenePlace and

ScenedBodyObject goes away.


git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@372 c613c5cb-e716-0410-b11b-feb51c14d237
This commit is contained in:
Michael Bayne
2007-07-21 00:47:00 +00:00
parent c8b2f7212b
commit e03ddd71e8
20 changed files with 174 additions and 156 deletions
@@ -73,9 +73,8 @@ public /*abstract*/ class GameController extends PlaceController
}
/**
* Adds this controller as a listener to the game object (thus derived
* classes need not do so) and lets the game manager know that we are
* now ready to go.
* Adds this controller as a listener to the game object (thus derived classes need not do so)
* and lets the game manager know that we are now ready to go.
*/
override public function willEnterPlace (plobj :PlaceObject) :void
{
@@ -84,26 +83,22 @@ public /*abstract*/ class GameController extends PlaceController
// obtain a casted reference
_gobj = (plobj as GameObject);
// if this place object is not our current location we'll need to
// add it as an auxiliary chat source
var bobj :BodyObject =
(_ctx.getClient().getClientObject() as BodyObject);
if (bobj.location != plobj.getOid()) {
_ctx.getChatDirector().addAuxiliarySource(
_gobj, GameCodes.GAME_CHAT_TYPE);
// if this place object is not our current location we'll need to add it as an auxiliary
// chat source
var bobj :BodyObject = (_ctx.getClient().getClientObject() as BodyObject);
if (bobj.getPlaceOid() != plobj.getOid()) {
_ctx.getChatDirector().addAuxiliarySource(_gobj, GameCodes.GAME_CHAT_TYPE);
}
// and add ourselves as a listener
_gobj.addListener(this);
// we don't want to claim to be finished until any derived classes
// that overrode this method have executed, so we'll queue up a
// runnable here that will let the game manager know that we're
// ready on the next pass through the distributed event loop
// we don't want to claim to be finished until any derived classes that overrode this
// method have executed, so we'll queue up a runnable here that will let the game manager
// know that we're ready on the next pass through the distributed event loop
log.info("Entering game " + _gobj.which() + ".");
if (_gobj.getPlayerIndex(bobj.getVisibleName()) != -1) {
// finally let the game manager know that we're ready
// to roll
// finally let the game manager know that we're ready to roll
_ctx.getClient().callLater(playerReady);
}
}
@@ -0,0 +1,69 @@
//
// $Id$
//
// Vilya library - tools for developing networked games
// Copyright (C) 2002-2007 Three Rings Design, Inc., All Rights Reserved
// http://www.threerings.net/code/vilya/
//
// This library is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License as published
// by the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package com.threerings.whirled.data {
import com.threerings.io.ObjectInputStream;
import com.threerings.io.ObjectOutputStream;
import com.threerings.crowd.data.BodyObject;
import com.threerings.crowd.data.Place;
/**
* Extends {@link Place} with scene information.
*/
public class ScenePlace extends Place
{
/** The id of the scene occupied by the body. */
public var sceneId :int;
/**
* Returns the scene id occupied by the supplied body or -1 if the body is not in a scene.
*/
public static function getSceneId (bobj :BodyObject) :int
{
return (bobj.location is ScenePlace) ? (bobj.location as ScenePlace).sceneId : -1;
}
/**
* Creates a scene place with the supplied {@link SceneObject} oid and scene id.
*/
public function ScenePlace (sceneOid :int = 0, sceneID :int = 0)
{
super(sceneOid);
this.sceneId = sceneId;
}
// from interface Streamable
override public function readObject (ins :ObjectInputStream) :void
{
super.readObject(ins);
sceneId = ins.readInt();
}
// from interface Streamable
override public function writeObject (out :ObjectOutputStream) :void
{
super.writeObject(out);
out.writeInt(sceneId);
}
}
}
@@ -1,40 +0,0 @@
//
// $Id$
//
// Vilya library - tools for developing networked games
// Copyright (C) 2002-2007 Three Rings Design, Inc., All Rights Reserved
// http://www.threerings.net/code/vilya/
//
// This library is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License as published
// by the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package com.threerings.whirled.data {
/**
* A system that uses the whirled services must provide a body object
* extension that implements this interface.
*/
public interface ScenedBodyObject
{
/**
* Returns the scene id currently occupied by this body.
*/
function getSceneId () :int;
// /**
// * Sets the scene id currently occupied by this body.
// */
// function setSceneId (sceneId :int) :void;
}
}
@@ -44,6 +44,7 @@ import com.threerings.crowd.data.PlaceObject;
import com.threerings.whirled.client.SceneDirector;
import com.threerings.whirled.data.SceneModel;
import com.threerings.whirled.data.ScenePlace;
import com.threerings.whirled.util.WhirledContext;
import com.threerings.whirled.spot.data.ClusteredBodyObject;
@@ -121,9 +122,10 @@ public class SpotSceneDirector extends BasicDirector
// sanity check the server's notion of what scene we're in with our notion of it
var sceneId :int = _scdir.getScene().getId();
if (sceneId != _self.getSceneId()) {
var clSceneId :int = ScenePlace.getSceneId(_self as BodyObject);
if (sceneId != clSceneId) {
log.warning("Client and server differ in opinion of what scene we're in " +
"[sSceneId=" + _self.getSceneId() + ", cSceneId=" + sceneId + "].");
"[sSceneId=" + clSceneId + ", cSceneId=" + sceneId + "].");
return false;
}
@@ -21,13 +21,13 @@
package com.threerings.whirled.spot.data {
import com.threerings.whirled.data.ScenedBodyObject;
import com.threerings.crowd.data.BodyObject;
/**
* Defines some required methods for a {@link ScenedBodyObject} that is to
* participate in the Whirled Spot system.
* Defines some required methods for a {@link BodyObject} that is to participate in the Whirled
* Spot system.
*/
public interface ClusteredBodyObject extends ScenedBodyObject
public interface ClusteredBodyObject
{
/**
* Returns the field name of the cluster oid distributed object field.