Initial port of stage data (and some stub client bits) from java to actionscript.
git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@923 c613c5cb-e716-0410-b11b-feb51c14d237
This commit is contained in:
@@ -0,0 +1,41 @@
|
|||||||
|
// $Id: ClusterClickedInfo.as 887 2010-01-05 22:12:02Z dhoover $
|
||||||
|
//
|
||||||
|
// Vilya library - tools for developing networked games
|
||||||
|
// Copyright (C) 2002-2010 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.stage.client {
|
||||||
|
|
||||||
|
import flash.geom.Point;
|
||||||
|
|
||||||
|
import com.threerings.whirled.spot.data.Cluster;
|
||||||
|
|
||||||
|
public class ClusterClickedInfo
|
||||||
|
{
|
||||||
|
/** The description of the cluster in question. */
|
||||||
|
public var cluster :Cluster;
|
||||||
|
|
||||||
|
/** The point which was clicked. */
|
||||||
|
public var loc :Point;
|
||||||
|
|
||||||
|
public function ClusterClickedInfo (cluster :Cluster, loc :Point)
|
||||||
|
{
|
||||||
|
this.cluster = cluster;
|
||||||
|
this.loc = loc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,66 @@
|
|||||||
|
// $Id: ClusterClickedInfo.as 887 2010-01-05 22:12:02Z dhoover $
|
||||||
|
//
|
||||||
|
// Vilya library - tools for developing networked games
|
||||||
|
// Copyright (C) 2002-2010 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.stage.client {
|
||||||
|
|
||||||
|
import com.threerings.crowd.client.PlaceView;
|
||||||
|
import com.threerings.crowd.util.CrowdContext;
|
||||||
|
import com.threerings.stage.data.StageLocation;
|
||||||
|
import com.threerings.stage.util.StageContext;
|
||||||
|
import com.threerings.util.Log;
|
||||||
|
import com.threerings.whirled.data.SceneUpdate;
|
||||||
|
import com.threerings.whirled.spot.client.SpotSceneController;
|
||||||
|
|
||||||
|
public class StageSceneController extends SpotSceneController
|
||||||
|
{
|
||||||
|
public var log :Log = Log.getLog(StageSceneController);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when the user clicks on a location within the scene.
|
||||||
|
*/
|
||||||
|
public function handleLocationClicked (source :Object, loc :StageLocation) :void
|
||||||
|
{
|
||||||
|
log.warning("handleLocationClicked(" + source + ", " + loc + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles a cluster clicked event.
|
||||||
|
*
|
||||||
|
* @param tuple the cluster that was clicked and the screen coords of the click.
|
||||||
|
*/
|
||||||
|
public function handleClusterClicked (source :Object, clusterClick :ClusterClickedInfo) :void
|
||||||
|
{
|
||||||
|
log.warning("handleClusterClicked(" + source + ", " + clusterClick + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
override protected function createPlaceView (ctx :CrowdContext) :PlaceView
|
||||||
|
{
|
||||||
|
return new StageScenePanel(StageContext(ctx), this);
|
||||||
|
}
|
||||||
|
|
||||||
|
override protected function sceneUpdated (update :SceneUpdate) :void
|
||||||
|
{
|
||||||
|
super.sceneUpdated(update);
|
||||||
|
|
||||||
|
// let the scene panel know to rethink everything
|
||||||
|
(StageScenePanel(_view)).sceneUpdated(update);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,85 @@
|
|||||||
|
// $Id: StageScenePanel.as 887 2010-01-05 22:12:02Z dhoover $
|
||||||
|
//
|
||||||
|
// Vilya library - tools for developing networked games
|
||||||
|
// Copyright (C) 2002-2010 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.stage.client {
|
||||||
|
|
||||||
|
import flash.events.Event;
|
||||||
|
import flash.events.EventDispatcher;
|
||||||
|
|
||||||
|
import com.threerings.crowd.client.PlaceView;
|
||||||
|
import com.threerings.crowd.data.PlaceObject;
|
||||||
|
import com.threerings.whirled.data.SceneUpdate;
|
||||||
|
import com.threerings.stage.util.StageContext;
|
||||||
|
import com.threerings.util.Controller;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Eventually responsible for rendering a stage scene - but for now it's a stub.
|
||||||
|
*/
|
||||||
|
public class StageScenePanel
|
||||||
|
implements PlaceView
|
||||||
|
{
|
||||||
|
public function StageScenePanel (ctx :StageContext, ctrl :Controller)
|
||||||
|
{
|
||||||
|
_dispatcher = new EventDispatcher(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function willEnterPlace (plobj :PlaceObject) :void
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function didLeavePlace (plobj :PlaceObject) :void
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addEventListener (type :String, listener :Function, useCapture :Boolean = false,
|
||||||
|
priority:int = 0, useWeakReference :Boolean = false) :void
|
||||||
|
{
|
||||||
|
_dispatcher.addEventListener(type, listener, useCapture, priority, useWeakReference);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dispatchEvent (event :Event) :Boolean
|
||||||
|
{
|
||||||
|
return _dispatcher.dispatchEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function hasEventListener (type :String) :Boolean
|
||||||
|
{
|
||||||
|
return _dispatcher.hasEventListener(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function removeEventListener (type :String, listener :Function,
|
||||||
|
useCapture :Boolean = false) :void
|
||||||
|
{
|
||||||
|
_dispatcher.removeEventListener(type, listener, useCapture);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function willTrigger (type :String) :Boolean
|
||||||
|
{
|
||||||
|
return _dispatcher.willTrigger(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function sceneUpdated (update :SceneUpdate) :void
|
||||||
|
{
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
protected var _dispatcher :EventDispatcher;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,78 @@
|
|||||||
|
//
|
||||||
|
// $Id: DefaultColorUpdate.java 887 2010-01-05 22:12:02Z dhoover $
|
||||||
|
//
|
||||||
|
// Vilya library - tools for developing networked games
|
||||||
|
// Copyright (C) 2002-2010 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.stage.data {
|
||||||
|
|
||||||
|
import com.threerings.io.ObjectInputStream;
|
||||||
|
import com.threerings.io.ObjectOutputStream;
|
||||||
|
|
||||||
|
import com.threerings.whirled.data.SceneUpdate;
|
||||||
|
import com.threerings.whirled.data.SceneModel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update to change the default colorization for objects in a scene which
|
||||||
|
* do not define their own colorization.
|
||||||
|
*/
|
||||||
|
public class DefaultColorUpdate extends SceneUpdate
|
||||||
|
{
|
||||||
|
/** The class id of the colorization we're changing. */
|
||||||
|
public var classId :int;
|
||||||
|
|
||||||
|
/** The color id to set as the new default, or -1 to remove the default. */
|
||||||
|
public var colorId :int;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes this update.
|
||||||
|
*/
|
||||||
|
public function initUpdate (targetId :int, targetVersion :int,
|
||||||
|
classId :int, colorId :int) :void
|
||||||
|
{
|
||||||
|
init(targetId, targetVersion);
|
||||||
|
this.classId = classId;
|
||||||
|
this.colorId = colorId;
|
||||||
|
}
|
||||||
|
|
||||||
|
override public function apply (model :SceneModel) :void
|
||||||
|
{
|
||||||
|
super.apply(model);
|
||||||
|
|
||||||
|
var smodel :StageSceneModel = StageSceneModel(model);
|
||||||
|
smodel.setDefaultColor(classId, colorId);
|
||||||
|
}
|
||||||
|
|
||||||
|
// from interface Streamable
|
||||||
|
override public function readObject (ins :ObjectInputStream) :void
|
||||||
|
{
|
||||||
|
super.readObject(ins);
|
||||||
|
classId = ins.readInt();
|
||||||
|
colorId = ins.readInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
// from interface Streamable
|
||||||
|
override public function writeObject (out :ObjectOutputStream) :void
|
||||||
|
{
|
||||||
|
super.writeObject(out);
|
||||||
|
out.writeInt(classId);
|
||||||
|
out.writeInt(colorId);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,98 @@
|
|||||||
|
//
|
||||||
|
// $Id: ModifyObjectsUpdate.java 887 2010-01-05 22:12:02Z dhoover $
|
||||||
|
//
|
||||||
|
// Vilya library - tools for developing networked games
|
||||||
|
// Copyright (C) 2002-2010 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.stage.data {
|
||||||
|
|
||||||
|
import com.threerings.io.ObjectInputStream;
|
||||||
|
import com.threerings.io.ObjectOutputStream;
|
||||||
|
import com.threerings.io.TypedArray;
|
||||||
|
|
||||||
|
import com.threerings.whirled.data.SceneUpdate;
|
||||||
|
import com.threerings.whirled.data.SceneModel;
|
||||||
|
import com.threerings.miso.data.ObjectInfo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A scene update that is broadcast when objects have been added to or removed
|
||||||
|
* from the scene.
|
||||||
|
*/
|
||||||
|
public class ModifyObjectsUpdate extends SceneUpdate
|
||||||
|
{
|
||||||
|
/** The objects added to the scene (or <code>null</code> for none). */
|
||||||
|
public var added :TypedArray;
|
||||||
|
|
||||||
|
/** The objects removed from the scene (or <code>null</code> for none). */
|
||||||
|
public var removed :TypedArray;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes this update with all necessary data.
|
||||||
|
*
|
||||||
|
* @param added the objects added to the scene, or <code>null</code> for
|
||||||
|
* none
|
||||||
|
* @param removed the objects removed from the scene, or <code>null</code>
|
||||||
|
* for none
|
||||||
|
*/
|
||||||
|
public function initUpdate (targetId :int, targetVersion :int, added :Array,
|
||||||
|
removed :Array) :void
|
||||||
|
{
|
||||||
|
init(targetId, targetVersion);
|
||||||
|
this.added = TypedArray.create(ObjectInfo, added);
|
||||||
|
this.removed = TypedArray.create(ObjectInfo, removed);
|
||||||
|
}
|
||||||
|
|
||||||
|
override public function apply (model :SceneModel) :void
|
||||||
|
{
|
||||||
|
super.apply(model);
|
||||||
|
|
||||||
|
var mmodel :StageMisoSceneModel = StageMisoSceneModel.getSceneModel(model);
|
||||||
|
|
||||||
|
// wipe out the objects that need to go
|
||||||
|
if (removed != null) {
|
||||||
|
for each (var rmElement :ObjectInfo in removed) {
|
||||||
|
mmodel.removeObject(rmElement);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// add the new objects
|
||||||
|
if (added != null) {
|
||||||
|
for each (var addElement :ObjectInfo in added) {
|
||||||
|
mmodel.addObject(addElement);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// from interface Streamable
|
||||||
|
override public function readObject (ins :ObjectInputStream) :void
|
||||||
|
{
|
||||||
|
super.readObject(ins);
|
||||||
|
added = ins.readObject(TypedArray);
|
||||||
|
removed = ins.readObject(TypedArray);
|
||||||
|
}
|
||||||
|
|
||||||
|
// from interface Streamable
|
||||||
|
override public function writeObject (out :ObjectOutputStream) :void
|
||||||
|
{
|
||||||
|
super.writeObject(out);
|
||||||
|
out.writeObject(added);
|
||||||
|
out.writeObject(removed);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,121 @@
|
|||||||
|
//
|
||||||
|
// $Id: StageLocation.java 889 2010-01-13 18:41:00Z ray $
|
||||||
|
//
|
||||||
|
// Vilya library - tools for developing networked games
|
||||||
|
// Copyright (C) 2002-2010 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.stage.data {
|
||||||
|
|
||||||
|
import com.threerings.util.ClassUtil;
|
||||||
|
import com.threerings.util.DirectionCodes;
|
||||||
|
import com.threerings.util.DirectionUtil;
|
||||||
|
import com.threerings.util.Hashable;
|
||||||
|
|
||||||
|
import com.threerings.io.SimpleStreamableObject;
|
||||||
|
import com.threerings.io.ObjectInputStream;
|
||||||
|
import com.threerings.io.ObjectOutputStream;
|
||||||
|
|
||||||
|
import com.threerings.stage.data.StageLocation;
|
||||||
|
import com.threerings.whirled.spot.data.Location;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contains information on a scene occupant's position and orientation.
|
||||||
|
*/
|
||||||
|
public class StageLocation extends SimpleStreamableObject
|
||||||
|
implements Location, Hashable
|
||||||
|
{
|
||||||
|
/** The user's x position (interpreted by the display system). */
|
||||||
|
public var x :int;
|
||||||
|
|
||||||
|
/** The user's y position (interpreted by the display system). */
|
||||||
|
public var y :int;
|
||||||
|
|
||||||
|
/** The user's orientation (defined by {@link DirectionCodes}). */
|
||||||
|
public var orient :int;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Computes a reasonable hashcode for location instances.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public function hashCode () :int
|
||||||
|
{
|
||||||
|
return x ^ y;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function clone () :Object
|
||||||
|
{
|
||||||
|
return (ClassUtil.newInstance(this) as StageLocation);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Location equality is determined by coordinates.
|
||||||
|
*/
|
||||||
|
public function equals (other :Object) :Boolean
|
||||||
|
{
|
||||||
|
if (other is StageLocation) {
|
||||||
|
var that :StageLocation = StageLocation(other);
|
||||||
|
return (this.x == that.x) && (this.y == that.y);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** {@link Object#toString} helper function. */
|
||||||
|
public function orientToString () :String
|
||||||
|
{
|
||||||
|
return DirectionUtil.toShortString(orient);
|
||||||
|
}
|
||||||
|
|
||||||
|
// documentation inherited from interface Location
|
||||||
|
public function getOpposite () :Location
|
||||||
|
{
|
||||||
|
var opp :StageLocation = StageLocation(clone());
|
||||||
|
opp.orient = DirectionUtil.getOpposite(orient);
|
||||||
|
return opp;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Location equivalence means that the coordinates and orientation are
|
||||||
|
* the same.
|
||||||
|
*/
|
||||||
|
public function equivalent (oloc :Location) :Boolean
|
||||||
|
{
|
||||||
|
return equals(oloc) && (orient == (StageLocation(oloc)).orient);
|
||||||
|
}
|
||||||
|
|
||||||
|
// from interface Streamable
|
||||||
|
override public function readObject (ins :ObjectInputStream) :void
|
||||||
|
{
|
||||||
|
super.readObject(ins);
|
||||||
|
x = ins.readInt();
|
||||||
|
y = ins.readInt();
|
||||||
|
orient = ins.readByte();
|
||||||
|
}
|
||||||
|
|
||||||
|
// from interface Streamable
|
||||||
|
override public function writeObject (out :ObjectOutputStream) :void
|
||||||
|
{
|
||||||
|
super.writeObject(out);
|
||||||
|
out.writeInt(x);
|
||||||
|
out.writeInt(y);
|
||||||
|
out.writeByte(orient);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,84 @@
|
|||||||
|
//
|
||||||
|
// $Id: StageMisoSceneModel.java 890 2010-01-13 18:52:23Z dhoover $
|
||||||
|
//
|
||||||
|
// Vilya library - tools for developing networked games
|
||||||
|
// Copyright (C) 2002-2010 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.stage.data {
|
||||||
|
|
||||||
|
import com.threerings.miso.data.SparseMisoSceneModel;
|
||||||
|
import com.threerings.whirled.data.AuxModel;
|
||||||
|
import com.threerings.whirled.data.SceneModel;
|
||||||
|
import com.threerings.io.ObjectInputStream;
|
||||||
|
import com.threerings.io.ObjectOutputStream;
|
||||||
|
import com.threerings.miso.data.SparseMisoSceneModel_Section;
|
||||||
|
import com.threerings.stage.data.StageMisoSceneModel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extends the {@link SparseMisoSceneModel} with the necessary interface
|
||||||
|
* to wire it up to the Whirled auxiliary model system.
|
||||||
|
*/
|
||||||
|
public class StageMisoSceneModel extends SparseMisoSceneModel
|
||||||
|
implements AuxModel
|
||||||
|
{
|
||||||
|
/** The width (in tiles) of a scene section. */
|
||||||
|
public static const SECTION_WIDTH :int = 9;
|
||||||
|
|
||||||
|
/** The height (in tiles) of a scene section. */
|
||||||
|
public static const SECTION_HEIGHT :int = 9;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Locates and returns the {@link StageMisoSceneModel} among the
|
||||||
|
* auxiliary scene models associated with the supplied scene model.
|
||||||
|
* <code>null</code> is returned if no miso scene model could be
|
||||||
|
* found.
|
||||||
|
*/
|
||||||
|
public static function getSceneModel (model :SceneModel) :StageMisoSceneModel
|
||||||
|
{
|
||||||
|
for each (var auxModel :AuxModel in model.auxModels) {
|
||||||
|
if (auxModel is StageMisoSceneModel) {
|
||||||
|
return StageMisoSceneModel(auxModel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
override public function clone () :Object
|
||||||
|
{
|
||||||
|
return StageMisoSceneModel(super.clone());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the section identified by the specified key, or null if no
|
||||||
|
* section exists for that key.
|
||||||
|
*/
|
||||||
|
public function getSectionByKey (key :int) :SparseMisoSceneModel_Section
|
||||||
|
{
|
||||||
|
return _sections.get(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the section key for the specified tile coordinate.
|
||||||
|
*/
|
||||||
|
public function getSectionKey (x :int, y :int) :int
|
||||||
|
{
|
||||||
|
return key(x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
//
|
||||||
|
// $Id: StageOccupantInfo.java 887 2010-01-05 22:12:02Z dhoover $
|
||||||
|
//
|
||||||
|
// Vilya library - tools for developing networked games
|
||||||
|
// Copyright (C) 2002-2010 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.stage.data {
|
||||||
|
|
||||||
|
import com.threerings.io.ObjectInputStream;
|
||||||
|
import com.threerings.io.ObjectOutputStream;
|
||||||
|
|
||||||
|
import com.threerings.crowd.data.OccupantInfo;
|
||||||
|
import com.threerings.crowd.data.BodyObject;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extends the standard occupant info with stage specific business.
|
||||||
|
*/
|
||||||
|
public class StageOccupantInfo extends OccupantInfo
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Should return true if the occupant in question is available to be
|
||||||
|
* clustered with, false if they are "busy". This means that a user
|
||||||
|
* can click on them and start a chat circle.
|
||||||
|
*/
|
||||||
|
public function isClusterable () :Boolean
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
//
|
||||||
|
// $Id: StageSceneConfig.java 887 2010-01-05 22:12:02Z dhoover $
|
||||||
|
//
|
||||||
|
// Vilya library - tools for developing networked games
|
||||||
|
// Copyright (C) 2002-2010 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.stage.data {
|
||||||
|
|
||||||
|
import com.threerings.crowd.data.PlaceConfig;
|
||||||
|
import com.threerings.io.ObjectInputStream;
|
||||||
|
import com.threerings.io.ObjectOutputStream;
|
||||||
|
import com.threerings.stage.client.StageSceneController;
|
||||||
|
import com.threerings.crowd.client.PlaceController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Place configuration for the main isometric scenes in Stage.
|
||||||
|
*/
|
||||||
|
public class StageSceneConfig extends PlaceConfig
|
||||||
|
{
|
||||||
|
override public function createController () :PlaceController
|
||||||
|
{
|
||||||
|
return new StageSceneController();
|
||||||
|
}
|
||||||
|
|
||||||
|
override public function getManagerClassName () :String
|
||||||
|
{
|
||||||
|
return "com.threerings.stage.server.StageSceneManager";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,125 @@
|
|||||||
|
//
|
||||||
|
// $Id: StageSceneModel.java 887 2010-01-05 22:12:02Z dhoover $
|
||||||
|
//
|
||||||
|
// Vilya library - tools for developing networked games
|
||||||
|
// Copyright (C) 2002-2010 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.stage.data {
|
||||||
|
|
||||||
|
import com.threerings.io.ObjectInputStream;
|
||||||
|
import com.threerings.io.ObjectOutputStream;
|
||||||
|
|
||||||
|
import com.threerings.stage.data.StageSceneModel;
|
||||||
|
import com.threerings.util.StreamableHashMap;
|
||||||
|
import com.threerings.whirled.spot.data.SpotSceneModel;
|
||||||
|
import com.threerings.whirled.data.SceneModel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extends the basic scene model with the notion of a scene type and
|
||||||
|
* incorporates the necessary auxiliary models used by the Stage system.
|
||||||
|
*/
|
||||||
|
public class StageSceneModel extends SceneModel
|
||||||
|
{
|
||||||
|
/** A scene type code. */
|
||||||
|
public static const WORLD :String = "world";
|
||||||
|
|
||||||
|
/** This scene's type which is a string identifier used to later
|
||||||
|
* construct a specific controller to handle this scene. */
|
||||||
|
public var type :String;
|
||||||
|
|
||||||
|
/** The zone id to which this scene belongs. */
|
||||||
|
public var zoneId :int;
|
||||||
|
|
||||||
|
/** If non-null, contains default colorizations to use for objects
|
||||||
|
* that do not have colorizations defined. */
|
||||||
|
public var defaultColors :StreamableHashMap;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates and returns a blank scene model.
|
||||||
|
*/
|
||||||
|
public static function blankStageSceneModel () :StageSceneModel
|
||||||
|
{
|
||||||
|
var model :StageSceneModel = new StageSceneModel();
|
||||||
|
populateBlankStageSceneModel(model);
|
||||||
|
return model;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the default colorId to use for a specified colorization
|
||||||
|
* classId, or -1 to clear the default for that colorization.
|
||||||
|
*/
|
||||||
|
public function setDefaultColor (classId :int, colorId :int) :void
|
||||||
|
{
|
||||||
|
if (colorId == -1) {
|
||||||
|
if (defaultColors != null) {
|
||||||
|
defaultColors.remove(classId);
|
||||||
|
if (defaultColors.size() == 0) {
|
||||||
|
defaultColors = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
if (defaultColors == null) {
|
||||||
|
defaultColors = new StreamableHashMap();
|
||||||
|
}
|
||||||
|
defaultColors.put(classId, colorId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the default color to use for the specified colorization
|
||||||
|
* classId, or -1 if no default is set for that colorization.
|
||||||
|
*/
|
||||||
|
public function getDefaultColor (classId :int) :int
|
||||||
|
{
|
||||||
|
if (defaultColors != null) {
|
||||||
|
return defaultColors.get(classId);
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// from interface Streamable
|
||||||
|
override public function readObject (ins :ObjectInputStream) :void
|
||||||
|
{
|
||||||
|
super.readObject(ins);
|
||||||
|
type = ins.readField(String);
|
||||||
|
zoneId = ins.readInt();
|
||||||
|
defaultColors = ins.readObject(StreamableHashMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
// from interface Streamable
|
||||||
|
override public function writeObject (out :ObjectOutputStream) :void
|
||||||
|
{
|
||||||
|
super.writeObject(out);
|
||||||
|
out.writeField(type);
|
||||||
|
out.writeInt(zoneId);
|
||||||
|
out.writeObject(defaultColors);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Populates a blank scene model with blank values.
|
||||||
|
*/
|
||||||
|
protected static function populateBlankStageSceneModel (model :StageSceneModel) :void
|
||||||
|
{
|
||||||
|
populateBlankSceneModel(model);
|
||||||
|
model.addAuxModel(new SpotSceneModel());
|
||||||
|
model.addAuxModel(new StageMisoSceneModel());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package com.threerings.stage.util {
|
||||||
|
|
||||||
|
import com.threerings.miso.util.MisoContext;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A context that provides for the myriad requirements of the Stage system.
|
||||||
|
* This is currently just a stub.
|
||||||
|
*/
|
||||||
|
public interface StageContext extends MisoContext
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user