Let the game manager know when the simulant is ready for the game to
begin. Give the simulant body objects their correct username. Cleaned up logging. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@838 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: SimulatorManager.java,v 1.1 2001/12/19 09:32:02 shaper Exp $
|
// $Id: SimulatorManager.java,v 1.2 2001/12/19 10:02:53 shaper Exp $
|
||||||
|
|
||||||
package com.threerings.micasa.simulator.server;
|
package com.threerings.micasa.simulator.server;
|
||||||
|
|
||||||
@@ -8,6 +8,7 @@ import java.util.ArrayList;
|
|||||||
import com.samskivert.util.Config;
|
import com.samskivert.util.Config;
|
||||||
|
|
||||||
import com.threerings.presents.dobj.DObject;
|
import com.threerings.presents.dobj.DObject;
|
||||||
|
import com.threerings.presents.dobj.MessageEvent;
|
||||||
import com.threerings.presents.dobj.ObjectAccessException;
|
import com.threerings.presents.dobj.ObjectAccessException;
|
||||||
import com.threerings.presents.dobj.Subscriber;
|
import com.threerings.presents.dobj.Subscriber;
|
||||||
import com.threerings.presents.server.InvocationManager;
|
import com.threerings.presents.server.InvocationManager;
|
||||||
@@ -20,6 +21,7 @@ import com.threerings.crowd.server.PlaceManager;
|
|||||||
import com.threerings.crowd.server.PlaceRegistry;
|
import com.threerings.crowd.server.PlaceRegistry;
|
||||||
import com.threerings.crowd.server.PlaceRegistry.CreationObserver;
|
import com.threerings.crowd.server.PlaceRegistry.CreationObserver;
|
||||||
|
|
||||||
|
import com.threerings.parlor.game.GameCodes;
|
||||||
import com.threerings.parlor.game.GameConfig;
|
import com.threerings.parlor.game.GameConfig;
|
||||||
import com.threerings.parlor.game.GameManager;
|
import com.threerings.parlor.game.GameManager;
|
||||||
import com.threerings.parlor.game.GameObject;
|
import com.threerings.parlor.game.GameObject;
|
||||||
@@ -32,7 +34,8 @@ import com.threerings.micasa.simulator.client.SimulatorCodes;
|
|||||||
* The simulator manager is responsible for handling the simulator
|
* The simulator manager is responsible for handling the simulator
|
||||||
* services on the server side.
|
* services on the server side.
|
||||||
*/
|
*/
|
||||||
public class SimulatorManager implements SimulatorCodes
|
public class SimulatorManager
|
||||||
|
implements GameCodes, SimulatorCodes
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Initializes the simulator manager manager. This should be called by
|
* Initializes the simulator manager manager. This should be called by
|
||||||
@@ -101,9 +104,6 @@ public class SimulatorManager implements SimulatorCodes
|
|||||||
// documentation inherited
|
// documentation inherited
|
||||||
public void placeCreated (PlaceObject place, PlaceManager pmgr)
|
public void placeCreated (PlaceObject place, PlaceManager pmgr)
|
||||||
{
|
{
|
||||||
Log.info("Simulator provider notified of place creation " +
|
|
||||||
"[place=" + place + "].");
|
|
||||||
|
|
||||||
// cast the place to the game object for the game we're creating
|
// cast the place to the game object for the game we're creating
|
||||||
_gobj = (GameObject)place;
|
_gobj = (GameObject)place;
|
||||||
|
|
||||||
@@ -112,11 +112,9 @@ public class SimulatorManager implements SimulatorCodes
|
|||||||
Subscriber sub = new Subscriber() {
|
Subscriber sub = new Subscriber() {
|
||||||
public void objectAvailable (DObject object)
|
public void objectAvailable (DObject object)
|
||||||
{
|
{
|
||||||
Log.info("Simulant body object is available.");
|
|
||||||
|
|
||||||
// set up the simulant's body object
|
// set up the simulant's body object
|
||||||
BodyObject bobj = (BodyObject)object;
|
BodyObject bobj = (BodyObject)object;
|
||||||
bobj.username = "simulant" + _sims.size();
|
bobj.username = "simulant" + (_sims.size() + 1);
|
||||||
|
|
||||||
// hold onto it for later game creation
|
// hold onto it for later game creation
|
||||||
_sims.add(bobj);
|
_sims.add(bobj);
|
||||||
@@ -130,9 +128,8 @@ public class SimulatorManager implements SimulatorCodes
|
|||||||
public void requestFailed (
|
public void requestFailed (
|
||||||
int oid, ObjectAccessException cause)
|
int oid, ObjectAccessException cause)
|
||||||
{
|
{
|
||||||
Log.warning("Unable to create simulant object " +
|
Log.warning("Unable to create simulant body object " +
|
||||||
"[class=" + _simClass +
|
"[error=" + cause + "].");
|
||||||
", error=" + cause + "].");
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -156,7 +153,7 @@ public class SimulatorManager implements SimulatorCodes
|
|||||||
try {
|
try {
|
||||||
sim = (Simulant)Class.forName(_simClass).newInstance();
|
sim = (Simulant)Class.forName(_simClass).newInstance();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.warning("Can't create simulant " +
|
Log.warning("Unable to create simulant " +
|
||||||
"[class=" + _simClass + "].");
|
"[class=" + _simClass + "].");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -177,6 +174,12 @@ public class SimulatorManager implements SimulatorCodes
|
|||||||
"[e=" + e + "].");
|
"[e=" + e + "].");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// let the game manager know that the simulant's ready
|
||||||
|
MessageEvent mevt = new MessageEvent(
|
||||||
|
_gobj.getOid(), PLAYER_READY_NOTIFICATION, null);
|
||||||
|
mevt.setSourceOid(bobj.getOid());
|
||||||
|
SimulatorServer.omgr.postEvent(mevt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user