Whirled actionscript code, transferred from narya.
git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@5 c613c5cb-e716-0410-b11b-feb51c14d237
This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
//
|
||||
// $Id: Cluster.java 3310 2005-01-24 23:08:21Z mdb $
|
||||
//
|
||||
// Narya library - tools for developing networked games
|
||||
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
|
||||
// http://www.threerings.net/code/narya/
|
||||
//
|
||||
// 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.spot.data {
|
||||
|
||||
import flash.geom.Rectangle;
|
||||
|
||||
import com.threerings.io.Streamable;
|
||||
import com.threerings.io.ObjectInputStream;
|
||||
import com.threerings.io.ObjectOutputStream;
|
||||
|
||||
import com.threerings.presents.dobj.DSet_Entry;
|
||||
|
||||
/**
|
||||
* Contains information on clusters.
|
||||
*/
|
||||
public class Cluster extends Rectangle
|
||||
implements DSet_Entry, Streamable
|
||||
{
|
||||
/** A unique identifier for this cluster (also the distributed object
|
||||
* id of the cluster chat object). */
|
||||
public var clusterOid :int;
|
||||
|
||||
// documentation inherited from interface DSet_Entry
|
||||
public function getKey () :Object
|
||||
{
|
||||
return clusterOid;
|
||||
}
|
||||
|
||||
// documentation inherited from interface Streamable
|
||||
public function writeObject (out :ObjectOutputStream) :void
|
||||
{
|
||||
out.writeInt(x);
|
||||
out.writeInt(y);
|
||||
out.writeInt(width);
|
||||
out.writeInt(height);
|
||||
out.writeInt(clusterOid);
|
||||
}
|
||||
|
||||
// documentation inherited from interface Streamable
|
||||
public function readObject (ins :ObjectInputStream) :void
|
||||
{
|
||||
x = ins.readInt();
|
||||
y = ins.readInt();
|
||||
width = ins.readInt();
|
||||
height = ins.readInt();
|
||||
clusterOid = ins.readInt();
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a string representation of this instance.
|
||||
*/
|
||||
public function toString () :String
|
||||
{
|
||||
return super.toString() + ", clusterOid=" + clusterOid;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
//
|
||||
// $Id: ClusterObject.java 3288 2004-12-28 03:51:29Z mdb $
|
||||
//
|
||||
// Narya library - tools for developing networked games
|
||||
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
|
||||
// http://www.threerings.net/code/narya/
|
||||
//
|
||||
// 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.spot.data {
|
||||
|
||||
import com.threerings.presents.dobj.DObject;
|
||||
import com.threerings.presents.dobj.OidList;
|
||||
|
||||
import com.threerings.crowd.chat.data.SpeakObject;
|
||||
|
||||
/**
|
||||
* Used to dispatch chat in clusters.
|
||||
*/
|
||||
public class ClusterObject extends DObject
|
||||
{
|
||||
// AUTO-GENERATED: FIELDS START
|
||||
/** The field name of the <code>occupants</code> field. */
|
||||
public static const OCCUPANTS :String = "occupants";
|
||||
// AUTO-GENERATED: FIELDS END
|
||||
|
||||
/**
|
||||
* Tracks the oid of the body objects that occupy this cluster.
|
||||
*/
|
||||
public var occupants :OidList = new OidList();
|
||||
|
||||
// AUTO-GENERATED: METHODS START
|
||||
/**
|
||||
* Requests that <code>oid</code> be added to the <code>occupants</code>
|
||||
* oid list. The list will not change until the event is actually
|
||||
* propagated through the system.
|
||||
*/
|
||||
public function addToOccupants (oid :int) :void
|
||||
{
|
||||
requestOidAdd(OCCUPANTS, oid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Requests that <code>oid</code> be removed from the
|
||||
* <code>occupants</code> oid list. The list will not change until the
|
||||
* event is actually propagated through the system.
|
||||
*/
|
||||
public function removeFromOccupants (oid :int) :void
|
||||
{
|
||||
requestOidRemove(OCCUPANTS, oid);
|
||||
}
|
||||
// AUTO-GENERATED: METHODS END
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
//
|
||||
// $Id: ClusteredBodyObject.java 3310 2005-01-24 23:08:21Z mdb $
|
||||
//
|
||||
// Narya library - tools for developing networked games
|
||||
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
|
||||
// http://www.threerings.net/code/narya/
|
||||
//
|
||||
// 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.spot.data {
|
||||
|
||||
import com.threerings.whirled.data.ScenedBodyObject;
|
||||
|
||||
/**
|
||||
* Defines some required methods for a {@link ScenedBodyObject} that is to
|
||||
* participate in the Whirled Spot system.
|
||||
*/
|
||||
public interface ClusteredBodyObject extends ScenedBodyObject
|
||||
{
|
||||
/**
|
||||
* Returns the field name of the cluster oid distributed object field.
|
||||
*/
|
||||
function getClusterField () :String;
|
||||
|
||||
/**
|
||||
* Returns the oid of the cluster to which this user currently
|
||||
* belongs.
|
||||
*/
|
||||
function getClusterOid () :int;
|
||||
|
||||
/**
|
||||
* Sets the oid of the cluster to which this user currently belongs.
|
||||
*/
|
||||
function setClusterOid (clusterOid :int) :void;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
//
|
||||
// $Id: Location.java 3726 2005-10-11 19:17:43Z ray $
|
||||
//
|
||||
// Narya library - tools for developing networked games
|
||||
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
|
||||
// http://www.threerings.net/code/narya/
|
||||
//
|
||||
// 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.spot.data {
|
||||
|
||||
import com.threerings.io.Streamable;
|
||||
|
||||
import com.threerings.util.Cloneable;
|
||||
import com.threerings.util.Hashable;
|
||||
|
||||
/**
|
||||
* Contains information on a scene occupant's position and orientation.
|
||||
*/
|
||||
public interface Location extends Cloneable, Streamable, Hashable
|
||||
{
|
||||
/**
|
||||
* Get a new Location instance that is equals() to this one but that
|
||||
* has an orientation facing the opposite direction.
|
||||
*/
|
||||
function getOpposite () :Location;
|
||||
|
||||
/**
|
||||
* Two locations are equivalent if they specify the same location
|
||||
* and orientation.
|
||||
*/
|
||||
function equivalent (other :Location) :Boolean;
|
||||
|
||||
/** Two locations are equals by coordinates only. */
|
||||
//function equals (other :Object) :Boolean;
|
||||
|
||||
/** The hashcode should be based on coordinates only. */
|
||||
//function hashCode () :int;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,141 @@
|
||||
//
|
||||
// $Id: Portal.java 4072 2006-04-28 01:34:02Z ray $
|
||||
//
|
||||
// Narya library - tools for developing networked games
|
||||
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
|
||||
// http://www.threerings.net/code/narya/
|
||||
//
|
||||
// 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.spot.data {
|
||||
|
||||
import com.threerings.util.ClassUtil;
|
||||
import com.threerings.util.Cloneable;
|
||||
|
||||
import com.threerings.io.Streamable;
|
||||
import com.threerings.io.ObjectInputStream;
|
||||
import com.threerings.io.ObjectOutputStream;
|
||||
|
||||
import com.threerings.util.Hashable;
|
||||
|
||||
/**
|
||||
* Represents an exit to another scene. A body sprite would walk over to a
|
||||
* portal's coordinates and then either proceed off of the edge of the
|
||||
* display, or open a door and walk through it, or fizzle away in a Star
|
||||
* Trekkian transporter style or whatever is appropriate for the game in
|
||||
* question. It contains information on the scene to which the body exits
|
||||
* when using this portal and the location at which the body sprite should
|
||||
* appear in that target scene.
|
||||
*/
|
||||
public class Portal
|
||||
implements Streamable, Hashable, Cloneable
|
||||
{
|
||||
/** This portal's unique identifier. */
|
||||
public var portalId :int;
|
||||
|
||||
/** The location of the portal. Typically this is a base Location (2d)
|
||||
* class, but different games could use a different subclass of
|
||||
* Location. */
|
||||
public var loc :Location;
|
||||
|
||||
/** The scene identifier of the scene to which a body will exit when
|
||||
* they "use" this portal. */
|
||||
public var targetSceneId :int;
|
||||
|
||||
/** The portal identifier of the portal at which a body will enter
|
||||
* the target scene when they "use" this portal. */
|
||||
public var targetPortalId :int;
|
||||
|
||||
/**
|
||||
* Returns a location instance configured with the location and
|
||||
* orientation of this portal.
|
||||
*/
|
||||
public function getLocation () :Location
|
||||
{
|
||||
return (loc.clone() as Location);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a location instance configured with the location and
|
||||
* opposite orientation of this portal. This is useful for when a body
|
||||
* is entering a scene at a portal and we want them to face the
|
||||
* opposite direction (as they are entering via the portal rather than
|
||||
* leaving, which is the natural "orientation" of a portal).
|
||||
*/
|
||||
public function getOppLocation () :Location
|
||||
{
|
||||
return loc.getOpposite();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the portal has a potentially valid target scene and
|
||||
* portal id (they are not guaranteed to exist, but they are at least
|
||||
* potentially valid values rather than -1 or 0).
|
||||
*/
|
||||
public function isValid () :Boolean
|
||||
{
|
||||
return (targetSceneId > 0) && (targetPortalId > 0);
|
||||
}
|
||||
|
||||
// documentation inherited from interface Streamable
|
||||
public function writeObject (out :ObjectOutputStream) :void
|
||||
{
|
||||
out.writeShort(portalId);
|
||||
out.writeObject(loc);
|
||||
out.writeInt(targetSceneId);
|
||||
out.writeShort(targetPortalId);
|
||||
}
|
||||
|
||||
// documentation inherited from interface Streamable
|
||||
public function readObject (ins :ObjectInputStream) :void
|
||||
{
|
||||
portalId = ins.readShort();
|
||||
loc = (ins.readObject() as Location);
|
||||
targetSceneId = ins.readInt();
|
||||
targetPortalId = ins.readShort();
|
||||
}
|
||||
|
||||
// documentation inherited from interface Cloneable
|
||||
public function clone () :Object
|
||||
{
|
||||
var clazz :Class = ClassUtil.getClass(this);
|
||||
var p :Portal = new clazz();
|
||||
p.portalId = portalId;
|
||||
p.loc = loc;
|
||||
p.targetSceneId = targetSceneId;
|
||||
p.targetPortalId = targetPortalId;
|
||||
return p;
|
||||
}
|
||||
|
||||
// documentation inherited from interface Hashable
|
||||
public function equals (other :Object) :Boolean
|
||||
{
|
||||
return (other is Portal) &&
|
||||
((other as Portal).portalId == portalId);
|
||||
}
|
||||
|
||||
// documentation inherited from interface Hashable
|
||||
public function hashCode () :int
|
||||
{
|
||||
return portalId;
|
||||
}
|
||||
|
||||
public function toString () :String
|
||||
{
|
||||
return "Portal[id=" + portalId + ", destScene=" + targetSceneId +
|
||||
", loc=" + loc + "].";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
//
|
||||
// $Id: SceneLocation.java 3310 2005-01-24 23:08:21Z mdb $
|
||||
//
|
||||
// Narya library - tools for developing networked games
|
||||
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
|
||||
// http://www.threerings.net/code/narya/
|
||||
//
|
||||
// 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.spot.data {
|
||||
|
||||
import com.threerings.util.Hashable;
|
||||
|
||||
import com.threerings.io.ObjectInputStream;
|
||||
import com.threerings.io.ObjectOutputStream;
|
||||
|
||||
import com.threerings.presents.dobj.DSet_Entry;
|
||||
|
||||
/**
|
||||
* Extends {@link Location} with the data and functionality needed to
|
||||
* represent a particular user's location in a scene.
|
||||
*/
|
||||
public class SceneLocation
|
||||
implements DSet_Entry, Hashable
|
||||
{
|
||||
/** The oid of the body that occupies this location. */
|
||||
public var bodyOid :int;
|
||||
|
||||
/** The actual location, which is interpreted by the display system. */
|
||||
public var loc :Location;
|
||||
|
||||
/**
|
||||
* Creates a scene location with the specified information.
|
||||
*/
|
||||
public function SceneLocation (loc :Location = null, bodyOid :int = 0)
|
||||
{
|
||||
this.loc = loc;
|
||||
this.bodyOid = bodyOid;
|
||||
}
|
||||
|
||||
// documentation inherited from interface DSet_Entry
|
||||
public function getKey () :Object
|
||||
{
|
||||
return bodyOid;
|
||||
}
|
||||
|
||||
// documentation inherited from interface Hashable
|
||||
public function equals (other :Object) :Boolean
|
||||
{
|
||||
return (other is SceneLocation) &&
|
||||
this.loc.equals((other as SceneLocation).loc);
|
||||
}
|
||||
|
||||
// documentation inherited from interface Hashable
|
||||
public function hashCode () :int
|
||||
{
|
||||
return loc.hashCode();
|
||||
}
|
||||
|
||||
// documentation inherited from superinterface Streamable
|
||||
public function writeObject (out :ObjectOutputStream) :void
|
||||
{
|
||||
out.writeInt(bodyOid);
|
||||
out.writeObject(loc);
|
||||
}
|
||||
|
||||
// documentation inherited from superinterface Streamable
|
||||
public function readObject (ins :ObjectInputStream) :void
|
||||
{
|
||||
bodyOid = ins.readInt();
|
||||
loc = (ins.readObject() as Location);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
//
|
||||
// $Id: SpotCodes.java 3099 2004-08-27 02:21:06Z mdb $
|
||||
//
|
||||
// Narya library - tools for developing networked games
|
||||
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
|
||||
// http://www.threerings.net/code/narya/
|
||||
//
|
||||
// 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.spot.data {
|
||||
|
||||
import com.threerings.crowd.chat.data.ChatCodes;
|
||||
|
||||
import com.threerings.whirled.data.SceneCodes;
|
||||
|
||||
/**
|
||||
* Contains codes used by the Spot invocation services.
|
||||
*/
|
||||
public class SpotCodes extends SceneCodes /*, ChatCodes */
|
||||
{
|
||||
/** An error code indicating that the portal specified in a
|
||||
* traversePortal request does not exist. */
|
||||
public static const NO_SUCH_PORTAL :String = "m.no_such_portal";
|
||||
|
||||
/** An error code indicating that a location is occupied. Usually
|
||||
* generated by a failed changeLoc request. */
|
||||
public static const LOCATION_OCCUPIED :String = "m.location_occupied";
|
||||
|
||||
/** An error code indicating that a location is not valid. Usually
|
||||
* generated by a failed changeLoc request. */
|
||||
public static const INVALID_LOCATION :String = "m.invalid_location";
|
||||
|
||||
/** An error code indicating that a cluster is not valid. Usually
|
||||
* generated by a failed joinCluster request. */
|
||||
public static const NO_SUCH_CLUSTER :String = "m.no_such_cluster";
|
||||
|
||||
/** An error code indicating that a cluster is full. Usually generated
|
||||
* by a failed joinCluster request. */
|
||||
public static const CLUSTER_FULL :String = "m.cluster_full";
|
||||
|
||||
/** The chat type code with which we register our cluster auxiliary
|
||||
* chat objects. Chat display implementations should interpret chat
|
||||
* messages with this type accordingly. */
|
||||
public static const CLUSTER_CHAT_TYPE :String = "clusterChat";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
// Narya library - tools for developing networked games
|
||||
// Copyright (C) 2002-2005 Three Rings Design, Inc., All Rights Reserved
|
||||
// http://www.threerings.net/code/narya/
|
||||
//
|
||||
// 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.spot.data {
|
||||
|
||||
import com.threerings.util.Byte;
|
||||
import com.threerings.util.Integer;
|
||||
|
||||
import com.threerings.presents.client.Client;
|
||||
import com.threerings.presents.client.InvocationService;
|
||||
import com.threerings.presents.client.ConfirmListener;
|
||||
import com.threerings.presents.data.InvocationMarshaller;
|
||||
import com.threerings.presents.data.InvocationMarshaller_ConfirmMarshaller;
|
||||
import com.threerings.presents.dobj.InvocationResponseEvent;
|
||||
import com.threerings.whirled.client.SceneService;
|
||||
import com.threerings.whirled.client.SceneService_SceneMoveListener;
|
||||
import com.threerings.whirled.data.SceneMarshaller_SceneMoveMarshaller;
|
||||
import com.threerings.whirled.spot.client.SpotService;
|
||||
import com.threerings.whirled.spot.data.Location;
|
||||
|
||||
/**
|
||||
* Provides the implementation of the {@link SpotService} interface
|
||||
* that marshalls the arguments and delivers the request to the provider
|
||||
* on the server. Also provides an implementation of the response listener
|
||||
* interfaces that marshall the response arguments and deliver them back
|
||||
* to the requesting client.
|
||||
*/
|
||||
public class SpotMarshaller extends InvocationMarshaller
|
||||
implements SpotService
|
||||
{
|
||||
/** The method id used to dispatch {@link #changeLocation} requests. */
|
||||
public static const CHANGE_LOCATION :int = 1;
|
||||
|
||||
// documentation inherited from interface
|
||||
public function changeLocation (arg1 :Client, arg2 :int, arg3 :Location, arg4 :ConfirmListener) :void
|
||||
{
|
||||
var listener4 :InvocationMarshaller_ConfirmMarshaller = new InvocationMarshaller_ConfirmMarshaller();
|
||||
listener4.listener = arg4;
|
||||
sendRequest(arg1, CHANGE_LOCATION, [
|
||||
new Integer(arg2), arg3, listener4
|
||||
]);
|
||||
}
|
||||
|
||||
/** The method id used to dispatch {@link #clusterSpeak} requests. */
|
||||
public static const CLUSTER_SPEAK :int = 2;
|
||||
|
||||
// documentation inherited from interface
|
||||
public function clusterSpeak (arg1 :Client, arg2 :String, arg3 :int) :void
|
||||
{
|
||||
sendRequest(arg1, CLUSTER_SPEAK, [
|
||||
arg2, new Byte(arg3)
|
||||
]);
|
||||
}
|
||||
|
||||
/** The method id used to dispatch {@link #joinCluster} requests. */
|
||||
public static const JOIN_CLUSTER :int = 3;
|
||||
|
||||
// documentation inherited from interface
|
||||
public function joinCluster (arg1 :Client, arg2 :int, arg3 :ConfirmListener) :void
|
||||
{
|
||||
var listener3 :InvocationMarshaller_ConfirmMarshaller = new InvocationMarshaller_ConfirmMarshaller();
|
||||
listener3.listener = arg3;
|
||||
sendRequest(arg1, JOIN_CLUSTER, [
|
||||
new Integer(arg2), listener3
|
||||
]);
|
||||
}
|
||||
|
||||
/** The method id used to dispatch {@link #traversePortal} requests. */
|
||||
public static const TRAVERSE_PORTAL :int = 4;
|
||||
|
||||
// documentation inherited from interface
|
||||
public function traversePortal (arg1 :Client, arg2 :int, arg3 :int, arg4 :int, arg5 :SceneService_SceneMoveListener) :void
|
||||
{
|
||||
var listener5 :SceneMarshaller_SceneMoveMarshaller = new SceneMarshaller_SceneMoveMarshaller();
|
||||
listener5.listener = arg5;
|
||||
sendRequest(arg1, TRAVERSE_PORTAL, [
|
||||
new Integer(arg2), new Integer(arg3), new Integer(arg4), listener5
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
//
|
||||
// $Id: SpotScene.java 3451 2005-03-31 19:40:55Z mdb $
|
||||
//
|
||||
// Narya library - tools for developing networked games
|
||||
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
|
||||
// http://www.threerings.net/code/narya/
|
||||
//
|
||||
// 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.spot.data {
|
||||
|
||||
import com.threerings.util.Iterator;
|
||||
|
||||
/**
|
||||
* Makes available the spot scene information that the server needs to do
|
||||
* its business.
|
||||
*/
|
||||
public interface SpotScene
|
||||
{
|
||||
/**
|
||||
* Returns a {@link Portal} object for the portal with the specified
|
||||
* id or null if no portal exists with that id.
|
||||
*/
|
||||
function getPortal (portalId :int) :Portal;
|
||||
|
||||
/**
|
||||
* Returns the number of portals in this scene.
|
||||
*/
|
||||
function getPortalCount () :int;
|
||||
|
||||
/**
|
||||
* Returns an iterator over the portals in this scene.
|
||||
*/
|
||||
function getPortals () :Iterator;
|
||||
|
||||
/**
|
||||
* Returns the portal id that should be assigned to the next portal
|
||||
* added to this scene.
|
||||
*/
|
||||
function getNextPortalId () :int;
|
||||
|
||||
/**
|
||||
* Returns the portal that represents the default entrance to this
|
||||
* scene. If a body enters the scene at logon time rather than
|
||||
* entering from some other scene, this is the portal at which they
|
||||
* would appear.
|
||||
*/
|
||||
function getDefaultEntrance () :Portal;
|
||||
|
||||
/**
|
||||
* Adds a portal to this scene, immediately making the requisite
|
||||
* modifications to the underlying scene model. The portal id should
|
||||
* have already been assigned using the value obtained from {@link
|
||||
* #getNextPortalId}.
|
||||
*/
|
||||
function addPortal (portal :Portal) :void;
|
||||
|
||||
/**
|
||||
* Removes the specified portal from the scene.
|
||||
*/
|
||||
function removePortal (portal :Portal) :void;
|
||||
|
||||
/**
|
||||
* Sets the default entrance in this scene, immediately making the
|
||||
* requisite modifications to the underlying scene model.
|
||||
*/
|
||||
function setDefaultEntrance (portal :Portal) :void;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,152 @@
|
||||
//
|
||||
// $Id: SpotSceneImpl.java 3451 2005-03-31 19:40:55Z mdb $
|
||||
//
|
||||
// Narya library - tools for developing networked games
|
||||
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
|
||||
// http://www.threerings.net/code/narya/
|
||||
//
|
||||
// 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.spot.data {
|
||||
|
||||
import com.threerings.util.ArrayIterator;
|
||||
import com.threerings.util.Iterator;
|
||||
import com.threerings.util.HashMap;
|
||||
|
||||
/**
|
||||
* An implementation of the {@link SpotScene} interface.
|
||||
*/
|
||||
public class SpotSceneImpl
|
||||
implements SpotScene
|
||||
{
|
||||
/**
|
||||
* Creates an instance that will obtain data from the supplied spot
|
||||
* scene model.
|
||||
*/
|
||||
public function SpotSceneImpl (model :SpotSceneModel = null)
|
||||
{
|
||||
if (model != null) {
|
||||
_smodel = model;
|
||||
readPortals();
|
||||
|
||||
} else {
|
||||
_smodel = new SpotSceneModel();
|
||||
}
|
||||
}
|
||||
|
||||
protected function readPortals () :void
|
||||
{
|
||||
_portals.clear();
|
||||
for each (var port :Portal in _smodel.portals) {
|
||||
_portals.put(port.portalId, port);
|
||||
}
|
||||
}
|
||||
|
||||
// documentation inherited from interface
|
||||
public function getPortal (portalId :int) :Portal
|
||||
{
|
||||
return (_portals.get(portalId) as Portal);
|
||||
}
|
||||
|
||||
// documentation inherited from interface
|
||||
public function getPortalCount () :int
|
||||
{
|
||||
return _portals.size();
|
||||
}
|
||||
|
||||
// documentation inherited from interface
|
||||
public function getPortals () :Iterator
|
||||
{
|
||||
return new ArrayIterator(_portals.values());
|
||||
}
|
||||
|
||||
// documentation inherited from interface
|
||||
public function getNextPortalId () :int
|
||||
{
|
||||
// compute a new portal id for our friend the portal
|
||||
for (var ii :int = 1; ii < MAX_PORTAL_ID; ii++) {
|
||||
if (!_portals.containsKey(ii)) {
|
||||
return ii;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
// documentation inherited from interface
|
||||
public function getDefaultEntrance () :Portal
|
||||
{
|
||||
return getPortal(_smodel.defaultEntranceId);
|
||||
}
|
||||
|
||||
// documentation inherited from interface
|
||||
public function addPortal (portal :Portal) :void
|
||||
{
|
||||
if (portal.portalId <= 0) {
|
||||
Log.getLog(this).warning("Refusing to add zero-id portal " +
|
||||
"[scene=" + this + ", portal=" + portal + "].");
|
||||
return;
|
||||
}
|
||||
|
||||
// add it to our model
|
||||
_smodel.addPortal(portal);
|
||||
|
||||
// and slap it into our table
|
||||
_portals.put(portal.portalId, portal);
|
||||
}
|
||||
|
||||
// documentation inherited from interface
|
||||
public function removePortal (portal :Portal) :void
|
||||
{
|
||||
// remove the portal from our mapping
|
||||
_portals.remove(portal.portalId);
|
||||
|
||||
// remove it from the model
|
||||
_smodel.removePortal(portal);
|
||||
}
|
||||
|
||||
/**
|
||||
* Used when we're being parsed from an XML scene model.
|
||||
*/
|
||||
public function setDefaultEntranceId (defaultEntranceId :int) :void
|
||||
{
|
||||
_smodel.defaultEntranceId = defaultEntranceId;
|
||||
}
|
||||
|
||||
// documentation inherited from interface
|
||||
public function setDefaultEntrance (portal :Portal) :void
|
||||
{
|
||||
_smodel.defaultEntranceId = (portal == null) ? -1 : portal.portalId;
|
||||
}
|
||||
|
||||
/**
|
||||
* This should be called if a scene update was received that caused
|
||||
* our underlying scene model to change.
|
||||
*/
|
||||
public function updateReceived () :void
|
||||
{
|
||||
readPortals();
|
||||
}
|
||||
|
||||
/** A casted reference to our scene model. */
|
||||
protected var _smodel :SpotSceneModel;
|
||||
|
||||
/** A mapping from portal id to portal. */
|
||||
protected var _portals :HashMap = new HashMap();
|
||||
|
||||
/** We don't allow more than ~32k portals in a scene. Things would
|
||||
* slow down *way* before we got there. */
|
||||
protected static const MAX_PORTAL_ID :int = int(Math.pow(2, 15) - 1);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
//
|
||||
// $Id: SpotSceneModel.java 3726 2005-10-11 19:17:43Z ray $
|
||||
//
|
||||
// Narya library - tools for developing networked games
|
||||
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
|
||||
// http://www.threerings.net/code/narya/
|
||||
//
|
||||
// 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.spot.data {
|
||||
|
||||
import com.threerings.util.ClassUtil;
|
||||
|
||||
import com.threerings.io.Streamable;
|
||||
import com.threerings.io.ObjectInputStream;
|
||||
import com.threerings.io.ObjectOutputStream;
|
||||
import com.threerings.io.TypedArray;
|
||||
|
||||
import com.threerings.whirled.data.AuxModel;
|
||||
import com.threerings.whirled.data.SceneModel;
|
||||
|
||||
/**
|
||||
* The spot scene model extends the standard scene model with information
|
||||
* on portals. Portals are referenced by an identifier, unique within the
|
||||
* scene and unchanging, so that portals can stably reference the target
|
||||
* portal in the scene to which they connect.
|
||||
*/
|
||||
public class SpotSceneModel
|
||||
implements Streamable, AuxModel
|
||||
{
|
||||
/** An array containing all portals in this scene. */
|
||||
public var portals :TypedArray =
|
||||
new TypedArray(TypedArray.getJavaType(Portal));
|
||||
|
||||
/** The portal id of the default entrance to this scene. If a body
|
||||
* enters the scene without coming from another scene, this is the
|
||||
* portal at which they would appear. */
|
||||
public var defaultEntranceId :int = -1;
|
||||
|
||||
/**
|
||||
* Adds a portal to this scene model.
|
||||
*/
|
||||
public function addPortal (portal :Portal) :void
|
||||
{
|
||||
portals.push(portal);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a portal from this model.
|
||||
*/
|
||||
public function removePortal (portal :Portal) :void
|
||||
{
|
||||
for (var ii :int = 0; ii < portals.length; ii++) {
|
||||
if (portal.equals(portals[ii])) {
|
||||
portals.splice(ii, 1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// documentation inherited from superinterface Cloneable
|
||||
public function clone () :Object
|
||||
{
|
||||
var clazz :Class = ClassUtil.getClass(this);
|
||||
var model :SpotSceneModel = new clazz();
|
||||
|
||||
for each (var portal :Portal in portals) {
|
||||
model.portals.push(portal.clone());
|
||||
}
|
||||
return model;
|
||||
}
|
||||
|
||||
// documentation inherited from interface Streamable
|
||||
public function writeObject (out :ObjectOutputStream) :void
|
||||
{
|
||||
out.writeObject(portals);
|
||||
out.writeInt(defaultEntranceId);
|
||||
}
|
||||
|
||||
// documentation inherited from interface Streamable
|
||||
public function readObject (ins :ObjectInputStream) :void
|
||||
{
|
||||
portals = (ins.readObject() as TypedArray);
|
||||
defaultEntranceId = ins.readInt();
|
||||
}
|
||||
|
||||
/**
|
||||
* Locates and returns the {@link SpotSceneModel} among the auxiliary
|
||||
* scene models associated with the supplied scene
|
||||
* model. <code>null</code> is returned if no spot scene model could
|
||||
* be found.
|
||||
*/
|
||||
public static function getSceneModel (model :SceneModel) :SpotSceneModel
|
||||
{
|
||||
for each (var aux :AuxModel in model.auxModels) {
|
||||
if (aux is SpotSceneModel) {
|
||||
return (aux as SpotSceneModel);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,162 @@
|
||||
//
|
||||
// $Id: SpotSceneObject.java 3300 2005-01-08 22:05:00Z ray $
|
||||
//
|
||||
// Narya library - tools for developing networked games
|
||||
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
|
||||
// http://www.threerings.net/code/narya/
|
||||
//
|
||||
// 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.spot.data {
|
||||
|
||||
import com.threerings.io.ObjectInputStream;
|
||||
import com.threerings.io.ObjectOutputStream;
|
||||
|
||||
import com.threerings.presents.dobj.DSet;
|
||||
import com.threerings.whirled.data.SceneObject;
|
||||
|
||||
/**
|
||||
* Extends the {@link SceneObject} with information specific to spots.
|
||||
*/
|
||||
public class SpotSceneObject extends SceneObject
|
||||
{
|
||||
// AUTO-GENERATED: FIELDS START
|
||||
/** The field name of the <code>occupantLocs</code> field. */
|
||||
public static const OCCUPANT_LOCS :String = "occupantLocs";
|
||||
|
||||
/** The field name of the <code>clusters</code> field. */
|
||||
public static const CLUSTERS :String = "clusters";
|
||||
// AUTO-GENERATED: FIELDS END
|
||||
|
||||
/** A distributed set containing {@link SceneLocation} records for all
|
||||
* occupants of this scene. */
|
||||
public var occupantLocs :DSet = new DSet();
|
||||
|
||||
/** Contains information on all {@link Cluster}s in this scene. */
|
||||
public var clusters :DSet = new DSet();
|
||||
|
||||
// AUTO-GENERATED: METHODS START
|
||||
/**
|
||||
* Requests that the specified entry be added to the
|
||||
* <code>occupantLocs</code> set. The set will not change until the event is
|
||||
* actually propagated through the system.
|
||||
*/
|
||||
public function addToOccupantLocs (elem :DSet_Entry) :void
|
||||
{
|
||||
requestEntryAdd(OCCUPANT_LOCS, elem);
|
||||
}
|
||||
|
||||
/**
|
||||
* Requests that the entry matching the supplied key be removed from
|
||||
* the <code>occupantLocs</code> set. The set will not change until the
|
||||
* event is actually propagated through the system.
|
||||
*/
|
||||
public function removeFromOccupantLocs (key :Object) :void
|
||||
{
|
||||
requestEntryRemove(OCCUPANT_LOCS, key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Requests that the specified entry be updated in the
|
||||
* <code>occupantLocs</code> set. The set will not change until the event is
|
||||
* actually propagated through the system.
|
||||
*/
|
||||
public function updateOccupantLocs (elem :DSet_Entry) :void
|
||||
{
|
||||
requestEntryUpdate(OCCUPANT_LOCS, elem);
|
||||
}
|
||||
|
||||
/**
|
||||
* Requests that the <code>occupantLocs</code> field be set to the
|
||||
* specified value. Generally one only adds, updates and removes
|
||||
* entries of a distributed set, but certain situations call for a
|
||||
* complete replacement of the set value. The local value will be
|
||||
* updated immediately and an event will be propagated through the
|
||||
* system to notify all listeners that the attribute did
|
||||
* change. Proxied copies of this object (on clients) will apply the
|
||||
* value change when they received the attribute changed notification.
|
||||
*/
|
||||
public function setOccupantLocs (value :DSet) :void
|
||||
{
|
||||
requestAttributeChange(OCCUPANT_LOCS, value, this.occupantLocs);
|
||||
this.occupantLocs = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Requests that the specified entry be added to the
|
||||
* <code>clusters</code> set. The set will not change until the event is
|
||||
* actually propagated through the system.
|
||||
*/
|
||||
public function addToClusters (elem :DSet_Entry) :void
|
||||
{
|
||||
requestEntryAdd(CLUSTERS, elem);
|
||||
}
|
||||
|
||||
/**
|
||||
* Requests that the entry matching the supplied key be removed from
|
||||
* the <code>clusters</code> set. The set will not change until the
|
||||
* event is actually propagated through the system.
|
||||
*/
|
||||
public function removeFromClusters (key :Object) :void
|
||||
{
|
||||
requestEntryRemove(CLUSTERS, key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Requests that the specified entry be updated in the
|
||||
* <code>clusters</code> set. The set will not change until the event is
|
||||
* actually propagated through the system.
|
||||
*/
|
||||
public function updateClusters (elem :DSet_Entry) :void
|
||||
{
|
||||
requestEntryUpdate(CLUSTERS, elem);
|
||||
}
|
||||
|
||||
/**
|
||||
* Requests that the <code>clusters</code> field be set to the
|
||||
* specified value. Generally one only adds, updates and removes
|
||||
* entries of a distributed set, but certain situations call for a
|
||||
* complete replacement of the set value. The local value will be
|
||||
* updated immediately and an event will be propagated through the
|
||||
* system to notify all listeners that the attribute did
|
||||
* change. Proxied copies of this object (on clients) will apply the
|
||||
* value change when they received the attribute changed notification.
|
||||
*/
|
||||
public function setClusters (value :DSet) :void
|
||||
{
|
||||
requestAttributeChange(CLUSTERS, value, this.clusters);
|
||||
this.clusters = value;
|
||||
}
|
||||
// AUTO-GENERATED: METHODS END
|
||||
|
||||
// documentation inherited
|
||||
override public function writeObject (out :ObjectOutputStream) :void
|
||||
{
|
||||
super.writeObject(out);
|
||||
|
||||
out.writeObject(occupantLocs);
|
||||
out.writeObject(clusters);
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
override public function readObject (ins :ObjectInputStream) :void
|
||||
{
|
||||
super.readObject(ins);
|
||||
|
||||
occupantLocs = (ins.readObject() as DSet);
|
||||
clusters = (ins.readObject() as DSet);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user