Clean up occupant info creation and whatnot. Now we have a nice calldown method
bodyWillEnter() where the PlaceManager can do whatever they want when the body enters, before or after the occupant info creation process. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@5579 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -128,15 +128,12 @@ public class LocationManager
|
|||||||
// remove them from any previous location
|
// remove them from any previous location
|
||||||
leaveOccupiedPlace(source);
|
leaveOccupiedPlace(source);
|
||||||
|
|
||||||
// generate a new occinfo record (which will add it to the target location)
|
// let the place manager know that we're coming in
|
||||||
pmgr.buildOccupantInfo(source);
|
pmgr.bodyWillEnter(source);
|
||||||
|
|
||||||
// set the body's new location
|
// let the body object know that it's going in
|
||||||
source.willEnterPlace(place, plobj);
|
source.willEnterPlace(place, plobj);
|
||||||
|
|
||||||
// add the body oid to the place object's occupant list
|
|
||||||
plobj.addToOccupants(bodoid);
|
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
source.commitTransaction();
|
source.commitTransaction();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -312,32 +312,21 @@ public class PlaceManager
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds an {@link OccupantInfo} record for the specified body object and inserts it into our
|
* This is called to inform the manager that a body is on the way in.
|
||||||
* place object. This is called by the location services when a body enters a place. If a
|
|
||||||
* derived class wishes to perform custom actions when an occupant is being inserted into a
|
|
||||||
* room, they should override {@link #insertOccupantInfo}, if they want to react to a body
|
|
||||||
* having entered, they should override {@link #bodyEntered}.
|
|
||||||
*/
|
*/
|
||||||
public OccupantInfo buildOccupantInfo (BodyObject body)
|
public void bodyWillEnter (BodyObject body)
|
||||||
{
|
{
|
||||||
try {
|
// create a new occupant info instance
|
||||||
// create a new occupant info instance
|
OccupantInfo info = body.createOccupantInfo(_plobj);
|
||||||
OccupantInfo info = body.createOccupantInfo(_plobj);
|
|
||||||
|
|
||||||
// insert the occupant info into our canonical table; this is done in a method so that
|
// insert the occupant info into our canonical table
|
||||||
// derived classes
|
_occInfo.put(info.getBodyOid(), info);
|
||||||
insertOccupantInfo(info, body);
|
|
||||||
|
|
||||||
// clone the canonical copy and insert it into the DSet
|
// clone the canonical copy and insert it into the DSet
|
||||||
_plobj.addToOccupantInfo((OccupantInfo)info.clone());
|
_plobj.addToOccupantInfo((OccupantInfo)info.clone());
|
||||||
|
|
||||||
return info;
|
// add the body oid to our place object's occupant list
|
||||||
|
_plobj.addToOccupants(body.getOid());
|
||||||
} catch (Exception e) {
|
|
||||||
log.warning("Failure building occupant info [where=" + where() +
|
|
||||||
", body=" + body + "].", e);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -538,16 +527,6 @@ public class PlaceManager
|
|||||||
cancelShutdowner();
|
cancelShutdowner();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Called when an occupant is being added to this place. This will be before the call to {@link
|
|
||||||
* #bodyEntered} and gives the derived class a chance to set up additional information about
|
|
||||||
* the occupant that might not be tracked in the occupant info.
|
|
||||||
*/
|
|
||||||
protected void insertOccupantInfo (OccupantInfo info, BodyObject body)
|
|
||||||
{
|
|
||||||
_occInfo.put(info.getBodyOid(), info);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a body object enters this place.
|
* Called when a body object enters this place.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user