Use new LocationManager. Some injection in SimulationManager.
git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@618 c613c5cb-e716-0410-b11b-feb51c14d237
This commit is contained in:
@@ -21,16 +21,18 @@
|
||||
|
||||
package com.threerings.micasa.simulator.server;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
import com.samskivert.util.ResultListener;
|
||||
|
||||
import com.threerings.micasa.server.MiCasaServer;
|
||||
|
||||
/**
|
||||
* A simple simulator server implementation that extends the MiCasa server and provides no special
|
||||
* functionality.
|
||||
* A simple simulator server implementation that extends the MiCasa server.
|
||||
*/
|
||||
@Singleton
|
||||
public class SimpleServer extends MiCasaServer
|
||||
implements SimulatorServer
|
||||
{
|
||||
@@ -39,13 +41,12 @@ public class SimpleServer extends MiCasaServer
|
||||
{
|
||||
init(injector); // do our standard initialization
|
||||
|
||||
// create the simulator manager
|
||||
SimulatorManager simmgr = new SimulatorManager();
|
||||
simmgr.init(invmgr, plreg, clmgr, omgr, this);
|
||||
|
||||
if (obs != null) {
|
||||
// let the initialization observer know that we've started up
|
||||
obs.requestCompleted(this);
|
||||
}
|
||||
}
|
||||
|
||||
// cause the simulator manager to be created
|
||||
@Inject protected SimulatorManager _simmgr;
|
||||
}
|
||||
|
||||
@@ -23,6 +23,8 @@ package com.threerings.micasa.simulator.server;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
import com.threerings.util.Name;
|
||||
|
||||
import com.threerings.presents.data.ClientObject;
|
||||
@@ -34,6 +36,7 @@ import com.threerings.presents.server.InvocationManager;
|
||||
|
||||
import com.threerings.crowd.data.BodyObject;
|
||||
import com.threerings.crowd.data.PlaceObject;
|
||||
import com.threerings.crowd.server.LocationManager;
|
||||
import com.threerings.crowd.server.PlaceManager;
|
||||
import com.threerings.crowd.server.PlaceRegistry;
|
||||
|
||||
@@ -47,27 +50,14 @@ import static com.threerings.micasa.Log.log;
|
||||
/**
|
||||
* The simulator manager is responsible for handling the simulator services on the server side.
|
||||
*/
|
||||
@Singleton
|
||||
public class SimulatorManager
|
||||
{
|
||||
/**
|
||||
* Initializes the simulator manager manager. This should be called by the server that is
|
||||
* making use of the simulator services on the single instance of simulator manager that it has
|
||||
* created.
|
||||
*
|
||||
* @param invmgr a reference to the invocation manager in use by this server.
|
||||
*/
|
||||
public void init (InvocationManager invmgr, PlaceRegistry plreg, ClientManager clmgr,
|
||||
RootDObjectManager omgr, SimulatorServer simserv)
|
||||
@Inject public SimulatorManager (InvocationManager invmgr)
|
||||
{
|
||||
// register our simulator provider
|
||||
SimulatorProvider sprov = new SimulatorProvider(this);
|
||||
invmgr.registerDispatcher(new SimulatorDispatcher(sprov), InvocationCodes.GLOBAL_GROUP);
|
||||
|
||||
// keep these for later
|
||||
_plreg = plreg;
|
||||
_clmgr = clmgr;
|
||||
_omgr = omgr;
|
||||
_simserv = simserv;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -174,7 +164,7 @@ public class SimulatorManager
|
||||
// move the simulant into the game room since they have no location director to
|
||||
// move them automagically
|
||||
try {
|
||||
_plreg.locprov.moveTo(bobj, _gobj.getOid());
|
||||
_locman.moveTo(bobj, _gobj.getOid());
|
||||
} catch (Exception e) {
|
||||
log.warning("Failed to move simulant into room " +
|
||||
"[e=" + e + "].");
|
||||
@@ -206,10 +196,10 @@ public class SimulatorManager
|
||||
}
|
||||
|
||||
// needed for general operation
|
||||
protected PlaceRegistry _plreg;
|
||||
protected ClientManager _clmgr;
|
||||
protected RootDObjectManager _omgr;
|
||||
protected SimulatorServer _simserv;
|
||||
@Inject protected PlaceRegistry _plreg;
|
||||
@Inject protected ClientManager _clmgr;
|
||||
@Inject protected RootDObjectManager _omgr;
|
||||
@Inject protected LocationManager _locman;
|
||||
|
||||
/** The default skill level for AI players. */
|
||||
protected static final byte DEFAULT_SKILL = 50;
|
||||
|
||||
@@ -50,7 +50,7 @@ public class SceneMoveHandler extends AbstractSceneMoveHandler
|
||||
{
|
||||
// move to location associated with this scene
|
||||
int ploid = scmgr.getPlaceObject().getOid();
|
||||
PlaceConfig config = CrowdServer.plreg.locprov.moveTo(_body, ploid);
|
||||
PlaceConfig config = CrowdServer.locman.moveTo(_body, ploid);
|
||||
|
||||
// check to see if they need a newer version of the scene data
|
||||
SceneService.SceneMoveListener listener = (SceneService.SceneMoveListener)_listener;
|
||||
|
||||
@@ -197,7 +197,7 @@ public class SceneRegistry
|
||||
public void moveBody (BodyObject source, int sceneId)
|
||||
{
|
||||
// first remove them from their old place
|
||||
CrowdServer.plreg.locprov.leaveOccupiedPlace(source);
|
||||
CrowdServer.locman.leaveOccupiedPlace(source);
|
||||
|
||||
// then send a forced move notification
|
||||
SceneSender.forcedMove(source, sceneId);
|
||||
@@ -210,7 +210,7 @@ public class SceneRegistry
|
||||
public void leaveOccupiedScene (BodyObject source)
|
||||
{
|
||||
// remove them from their occupied place (clears out scene info as well)
|
||||
CrowdServer.plreg.locprov.leaveOccupiedPlace(source);
|
||||
CrowdServer.locman.leaveOccupiedPlace(source);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -85,7 +85,7 @@ public class ZoneMoveHandler extends AbstractSceneMoveHandler
|
||||
{
|
||||
// move to the place object associated with this scene
|
||||
int ploid = scmgr.getPlaceObject().getOid();
|
||||
PlaceConfig config = WhirledServer.plreg.locprov.moveTo(_body, ploid);
|
||||
PlaceConfig config = WhirledServer.locman.moveTo(_body, ploid);
|
||||
|
||||
// now that we've moved, we can update the user object with the new scene and zone ids
|
||||
_body.startTransaction();
|
||||
|
||||
@@ -25,7 +25,7 @@ import com.samskivert.util.HashIntMap;
|
||||
|
||||
import com.threerings.presents.server.InvocationManager;
|
||||
|
||||
import com.threerings.crowd.server.PlaceRegistry;
|
||||
import com.threerings.crowd.server.LocationManager;
|
||||
import com.threerings.whirled.server.SceneRegistry;
|
||||
|
||||
import com.threerings.whirled.zone.data.ZoneCodes;
|
||||
@@ -45,10 +45,10 @@ public class ZoneRegistry
|
||||
/**
|
||||
* Creates a zone manager with the supplied configuration.
|
||||
*/
|
||||
public ZoneRegistry (InvocationManager invmgr, PlaceRegistry plreg, SceneRegistry screg)
|
||||
public ZoneRegistry (InvocationManager invmgr, LocationManager locman, SceneRegistry screg)
|
||||
{
|
||||
// create a zone provider and register it with the invocation services
|
||||
zoneprov = new ZoneProvider(plreg.locprov, this, screg);
|
||||
zoneprov = new ZoneProvider(locman, this, screg);
|
||||
invmgr.registerDispatcher(new ZoneDispatcher(zoneprov), ZoneCodes.WHIRLED_GROUP);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user