Zones! Scenes can be grouped into zones which are traversed via a
higher-level mechanism. Zones provide zone summaries which can be used to generate maps of the zones on the client. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@727 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
//
|
||||
// $Id: SceneSummary.java,v 1.1 2001/12/04 00:31:58 mdb Exp $
|
||||
|
||||
package com.threerings.whirled.zone.data;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import com.threerings.presents.io.Streamable;
|
||||
import com.threerings.presents.io.StreamableUtil;
|
||||
|
||||
/**
|
||||
* The scene summary class is used to provide info about the connected
|
||||
* group of scenes that make up an island. The group of scenes that make
|
||||
* up an island is a self-contained set of scenes, connected with one
|
||||
* another (by portals) but not to any scenes outside the group.
|
||||
*/
|
||||
public class SceneSummary implements Streamable
|
||||
{
|
||||
/** The id of this scene. */
|
||||
public int sceneId;
|
||||
|
||||
/** The name of this scene. */
|
||||
public String name;
|
||||
|
||||
/** The ids of the scenes to which this scene is connected via
|
||||
* portals. */
|
||||
public int[] neighbors;
|
||||
|
||||
/**
|
||||
* Returns the population of this scene summary instance. This is
|
||||
* synchronized because the population can be updated by a background
|
||||
* thread.
|
||||
*/
|
||||
public synchronized int getPopulation ()
|
||||
{
|
||||
return _population;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to set the population of this scene summary instance.
|
||||
*/
|
||||
public synchronized void setPopulation (int population)
|
||||
{
|
||||
_population = population;
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
public void writeTo (DataOutputStream out)
|
||||
throws IOException
|
||||
{
|
||||
out.writeInt(sceneId);
|
||||
out.writeUTF(name);
|
||||
StreamableUtil.writeInts(out, neighbors);
|
||||
out.writeInt(_population);
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
public void readFrom (DataInputStream in)
|
||||
throws IOException
|
||||
{
|
||||
sceneId = in.readInt();
|
||||
name = in.readUTF();
|
||||
neighbors = StreamableUtil.readInts(in);
|
||||
_population = in.readInt();
|
||||
}
|
||||
|
||||
/** The number of people currently occupying this scene. */
|
||||
protected int _population;
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
//
|
||||
// $Id: ZoneSummary.java,v 1.1 2001/12/04 00:31:58 mdb Exp $
|
||||
|
||||
package com.threerings.whirled.zone.data;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import com.threerings.presents.io.Streamable;
|
||||
|
||||
/**
|
||||
* The zone summary contains information on a zone, including its name and
|
||||
* summary info on all of the scenes in this zone (which can be used to
|
||||
* generate a map of the zone on the client).
|
||||
*/
|
||||
public class ZoneSummary implements Streamable
|
||||
{
|
||||
/** The zone's unique identifier. */
|
||||
public int zoneId;
|
||||
|
||||
/** The name of the zone. */
|
||||
public String name;
|
||||
|
||||
/** The summary information for all of the scenes in the zone. */
|
||||
public SceneSummary[] scenes;
|
||||
|
||||
// documentation inherited
|
||||
public void writeTo (DataOutputStream out)
|
||||
throws IOException
|
||||
{
|
||||
out.writeInt(zoneId);
|
||||
out.writeUTF(name);
|
||||
int scount = scenes.length;
|
||||
out.writeInt(scount);
|
||||
for (int i = 0; i < scount; i++) {
|
||||
scenes[i].writeTo(out);
|
||||
}
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
public void readFrom (DataInputStream in)
|
||||
throws IOException
|
||||
{
|
||||
zoneId = in.readInt();
|
||||
name = in.readUTF();
|
||||
int scount = in.readInt();
|
||||
scenes = new SceneSummary[scount];
|
||||
for (int i = 0; i < scount; i++) {
|
||||
scenes[i] = new SceneSummary();
|
||||
scenes[i].readFrom(in);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
//
|
||||
// $Id: ZonedBodyObject.java,v 1.1 2001/12/04 00:31:58 mdb Exp $
|
||||
|
||||
package com.threerings.whirled.zone.data;
|
||||
|
||||
/**
|
||||
* A system that uses the zone services must provide a body object
|
||||
* extension that implements this interface.
|
||||
*/
|
||||
public interface ZonedBodyObject
|
||||
{
|
||||
/**
|
||||
* Returns the zone id currently occupied by this body.
|
||||
*/
|
||||
public int getZoneId ();
|
||||
|
||||
/**
|
||||
* Sets the zone id currently occupied by this body.
|
||||
*/
|
||||
public void setZoneId (int zoneId);
|
||||
}
|
||||
Reference in New Issue
Block a user