Phase one of the scene refactoring (which will set the stage for all
manner of happiness and joy). git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@615 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
//
|
||||
// $Id: DefaultSceneConfig.java,v 1.1 2001/11/12 20:56:55 mdb Exp $
|
||||
|
||||
package com.threerings.whirled.data;
|
||||
|
||||
import com.threerings.crowd.data.PlaceConfig;
|
||||
import com.threerings.whirled.client.SceneController;
|
||||
|
||||
/**
|
||||
* The default scene config simply causes the default scene manager and
|
||||
* controller to be created. A user of the Whirled services would most
|
||||
* likely extend the default scene config.
|
||||
*
|
||||
* <p> Note that this place config won't even work on the client side
|
||||
* because it instantiates a {@link SceneController} which is an abstract
|
||||
* class. It is used only for testing the server side and as a placeholder
|
||||
* in case standard scene configuration information is one day needed.
|
||||
*/
|
||||
public class DefaultSceneConfig extends PlaceConfig
|
||||
{
|
||||
// documentation inherited
|
||||
public Class getControllerClass ()
|
||||
{
|
||||
return SceneController.class;
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
public String getManagerClassName ()
|
||||
{
|
||||
return "com.threerings.whirled.server.SceneManager";
|
||||
}
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
//
|
||||
// $Id: DummyScene.java,v 1.7 2001/11/08 02:59:17 mdb Exp $
|
||||
|
||||
package com.threerings.whirled.data;
|
||||
|
||||
import com.threerings.crowd.data.PlaceConfig;
|
||||
|
||||
public class DummyScene implements Scene
|
||||
{
|
||||
public DummyScene (int sceneId)
|
||||
{
|
||||
_sceneId = sceneId;
|
||||
}
|
||||
|
||||
public int getId ()
|
||||
{
|
||||
return _sceneId;
|
||||
}
|
||||
|
||||
public int getVersion ()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
public String getName ()
|
||||
{
|
||||
return "scene";
|
||||
}
|
||||
|
||||
public int[] getNeighborIds ()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public PlaceConfig getPlaceConfig ()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
protected int _sceneId;
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
//
|
||||
// $Id: EditableScene.java,v 1.3 2001/10/05 23:59:36 mdb Exp $
|
||||
|
||||
package com.threerings.whirled.data;
|
||||
|
||||
/**
|
||||
* The editable scene interface. This separate interface allows the
|
||||
* ability to modify the scenes to be restricted only to code that needs
|
||||
* such an ability.
|
||||
*/
|
||||
public interface EditableScene extends Scene
|
||||
{
|
||||
/**
|
||||
* Updates the scene's unique identifier.
|
||||
*/
|
||||
public void setId (int sceneId);
|
||||
|
||||
/**
|
||||
* Updates the scene's version.
|
||||
*/
|
||||
public void setVersion (int version);
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
//
|
||||
// $Id: Scene.java,v 1.6 2001/10/11 04:07:54 mdb Exp $
|
||||
|
||||
package com.threerings.whirled.data;
|
||||
|
||||
import com.threerings.crowd.data.PlaceConfig;
|
||||
|
||||
/**
|
||||
* The base scene interface. This encapsulates the minimum information
|
||||
* needed about a scene in the Whirled system.
|
||||
*/
|
||||
public interface Scene
|
||||
{
|
||||
/**
|
||||
* Returns the scene's unique identifier.
|
||||
*/
|
||||
public int getId ();
|
||||
|
||||
/**
|
||||
* Returns the scene's version. The version should be updated every
|
||||
* time the scene is modified and stored back to the repository. This
|
||||
* allows a client to determine whether or not they need an updated
|
||||
* version of the scene for their local cache.
|
||||
*/
|
||||
public int getVersion ();
|
||||
|
||||
/**
|
||||
* Returns the scene ids of all scenes that neighbor this scene. A
|
||||
* neighboring scene is one to which the user can traverse from this
|
||||
* scene and vice versa.
|
||||
*/
|
||||
public int[] getNeighborIds ();
|
||||
|
||||
/**
|
||||
* A scene is associated with a place on the server. Because the
|
||||
* scenes are loaded on demand, the scene implementation must be able
|
||||
* to provide a place config instance for each scene. This will allow
|
||||
* the server to figure out what manager class to instantiate to
|
||||
* manage the scene and all the client to figure out what controller
|
||||
* class to instantiate to controll the scene. Additionally, it may
|
||||
* contain runtime configuration information needed by the application
|
||||
* using the Whirled services.
|
||||
*/
|
||||
public PlaceConfig getPlaceConfig ();
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
//
|
||||
// $Id: SceneModel.java,v 1.1 2001/11/12 20:56:55 mdb Exp $
|
||||
|
||||
package com.threerings.whirled.data;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
|
||||
import com.threerings.presents.io.Streamable;
|
||||
|
||||
/**
|
||||
* The scene model is the bare bones representation of the data for a
|
||||
* scene in the Whirled system. From the scene model, one would create an
|
||||
* instance of {@link com.threerings.whirled.server.RuntimeScene}, {@link
|
||||
* com.threerings.whirled.client.DisplayScene} or {@link
|
||||
* com.threerings.whirled.tools.EditableScene}.
|
||||
*
|
||||
* <p> The scene model is what is loaded from the scene repositories and
|
||||
* what is transmitted over the wire when communicating scenes from the
|
||||
* server to the client.
|
||||
*/
|
||||
public class SceneModel implements Streamable
|
||||
{
|
||||
/** This scene's unique identifier. */
|
||||
public int sceneId;
|
||||
|
||||
/** The version number of this scene. Versions are incremented
|
||||
* whenever modifications are made to a scene so that clients can
|
||||
* determine whether or not they have the latest version of a
|
||||
* scene. */
|
||||
public int version;
|
||||
|
||||
/** The scene ids of the scenes that neighbor this scene. A neighbor
|
||||
* is a scene that can be entered from this scene. */
|
||||
public int[] neighborIds;
|
||||
|
||||
// documentation inherited
|
||||
public void writeTo (DataOutputStream out)
|
||||
throws IOException
|
||||
{
|
||||
out.writeInt(sceneId);
|
||||
out.writeInt(version);
|
||||
int nlength = neighborIds.length;
|
||||
out.writeInt(nlength);
|
||||
for (int i = 0; i < nlength; i++) {
|
||||
out.writeInt(neighborIds[i]);
|
||||
}
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
public void readFrom (DataInputStream in)
|
||||
throws IOException
|
||||
{
|
||||
sceneId = in.readInt();
|
||||
version = in.readInt();
|
||||
int nlength = in.readInt();
|
||||
neighborIds = new int[nlength];
|
||||
for (int i = 0; i < nlength; i++) {
|
||||
neighborIds[i] = in.readInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user