Allow the BodyObject to play along when we enter and leave a place.
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@5108 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -129,11 +129,34 @@ public class BodyObject extends ClientObject
|
||||
* Creates a blank occupant info instance that will used to publish information about the
|
||||
* various bodies occupying a place.
|
||||
*/
|
||||
public OccupantInfo createOccupantInfo (PlaceObject placeObject)
|
||||
public OccupantInfo createOccupantInfo (PlaceObject plobj)
|
||||
{
|
||||
return new OccupantInfo(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when this body is about to enter the specified place. Configures our {@link
|
||||
* #location} field.
|
||||
*
|
||||
* @param place the identifying information for the place we are entering.
|
||||
* @param plobj the distributed object for the place we are entering.
|
||||
*/
|
||||
public void willEnterPlace (Place place, PlaceObject plobj)
|
||||
{
|
||||
setLocation(place);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when this body has left its occupied place. Clears our {@link #location} field.
|
||||
*
|
||||
* @param plobj the distributed object for the place we just departed. This might be null if
|
||||
* the place object has been destroyed.
|
||||
*/
|
||||
public void didLeavePlace (PlaceObject plobj)
|
||||
{
|
||||
setLocation(null);
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
public void applyToListeners (ListenerOp op)
|
||||
{
|
||||
|
||||
@@ -144,7 +144,7 @@ public class LocationProvider
|
||||
pmgr.buildOccupantInfo(source);
|
||||
|
||||
// set the body's new location
|
||||
source.setLocation(place);
|
||||
source.willEnterPlace(place, plobj);
|
||||
|
||||
// add the body oid to the place object's occupant list
|
||||
plobj.addToOccupants(bodoid);
|
||||
@@ -179,19 +179,20 @@ public class LocationProvider
|
||||
}
|
||||
|
||||
// remove them from the occupant list
|
||||
PlaceObject plobj = null;
|
||||
try {
|
||||
PlaceObject pold = (PlaceObject)_omgr.getObject(oldloc.placeOid);
|
||||
if (pold != null) {
|
||||
plobj = (PlaceObject)_omgr.getObject(oldloc.placeOid);
|
||||
if (plobj != null) {
|
||||
Integer key = Integer.valueOf(bodoid);
|
||||
pold.startTransaction();
|
||||
plobj.startTransaction();
|
||||
try {
|
||||
// remove their occupant info (which is keyed on oid)
|
||||
pold.removeFromOccupantInfo(key);
|
||||
plobj.removeFromOccupantInfo(key);
|
||||
// and remove them from the occupant list
|
||||
pold.removeFromOccupants(bodoid);
|
||||
plobj.removeFromOccupants(bodoid);
|
||||
|
||||
} finally {
|
||||
pold.commitTransaction();
|
||||
plobj.commitTransaction();
|
||||
}
|
||||
|
||||
} else {
|
||||
@@ -205,7 +206,7 @@ public class LocationProvider
|
||||
}
|
||||
|
||||
// clear out their location
|
||||
source.setLocation(null);
|
||||
source.didLeavePlace(plobj);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user