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
|
* Creates a blank occupant info instance that will used to publish information about the
|
||||||
* various bodies occupying a place.
|
* various bodies occupying a place.
|
||||||
*/
|
*/
|
||||||
public OccupantInfo createOccupantInfo (PlaceObject placeObject)
|
public OccupantInfo createOccupantInfo (PlaceObject plobj)
|
||||||
{
|
{
|
||||||
return new OccupantInfo(this);
|
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
|
// documentation inherited
|
||||||
public void applyToListeners (ListenerOp op)
|
public void applyToListeners (ListenerOp op)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -144,7 +144,7 @@ public class LocationProvider
|
|||||||
pmgr.buildOccupantInfo(source);
|
pmgr.buildOccupantInfo(source);
|
||||||
|
|
||||||
// set the body's new location
|
// set the body's new location
|
||||||
source.setLocation(place);
|
source.willEnterPlace(place, plobj);
|
||||||
|
|
||||||
// add the body oid to the place object's occupant list
|
// add the body oid to the place object's occupant list
|
||||||
plobj.addToOccupants(bodoid);
|
plobj.addToOccupants(bodoid);
|
||||||
@@ -179,19 +179,20 @@ public class LocationProvider
|
|||||||
}
|
}
|
||||||
|
|
||||||
// remove them from the occupant list
|
// remove them from the occupant list
|
||||||
|
PlaceObject plobj = null;
|
||||||
try {
|
try {
|
||||||
PlaceObject pold = (PlaceObject)_omgr.getObject(oldloc.placeOid);
|
plobj = (PlaceObject)_omgr.getObject(oldloc.placeOid);
|
||||||
if (pold != null) {
|
if (plobj != null) {
|
||||||
Integer key = Integer.valueOf(bodoid);
|
Integer key = Integer.valueOf(bodoid);
|
||||||
pold.startTransaction();
|
plobj.startTransaction();
|
||||||
try {
|
try {
|
||||||
// remove their occupant info (which is keyed on oid)
|
// remove their occupant info (which is keyed on oid)
|
||||||
pold.removeFromOccupantInfo(key);
|
plobj.removeFromOccupantInfo(key);
|
||||||
// and remove them from the occupant list
|
// and remove them from the occupant list
|
||||||
pold.removeFromOccupants(bodoid);
|
plobj.removeFromOccupants(bodoid);
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
pold.commitTransaction();
|
plobj.commitTransaction();
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@@ -205,7 +206,7 @@ public class LocationProvider
|
|||||||
}
|
}
|
||||||
|
|
||||||
// clear out their location
|
// clear out their location
|
||||||
source.setLocation(null);
|
source.didLeavePlace(plobj);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user