Added PlaceManager.applyToOccupants(), and a generic useful OccupantOp.
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@1869 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -0,0 +1,18 @@
|
|||||||
|
//
|
||||||
|
// $Id: OccupantOp.java,v 1.1 2002/10/31 01:12:08 shaper Exp $
|
||||||
|
|
||||||
|
package com.threerings.crowd.server;
|
||||||
|
|
||||||
|
import com.threerings.crowd.data.OccupantInfo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An operation to be applied to all occupants in a location that may
|
||||||
|
* contain occupants, e.g., a {@link PlaceManager}.
|
||||||
|
*/
|
||||||
|
public interface OccupantOp
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Called with the occupant info for each occupant in the location.
|
||||||
|
*/
|
||||||
|
public void apply (OccupantInfo info);
|
||||||
|
}
|
||||||
@@ -1,10 +1,11 @@
|
|||||||
//
|
//
|
||||||
// $Id: PlaceManager.java,v 1.39 2002/10/26 02:40:30 shaper Exp $
|
// $Id: PlaceManager.java,v 1.40 2002/10/31 01:12:08 shaper Exp $
|
||||||
|
|
||||||
package com.threerings.crowd.server;
|
package com.threerings.crowd.server;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import com.samskivert.util.HashIntMap;
|
import com.samskivert.util.HashIntMap;
|
||||||
@@ -102,6 +103,20 @@ public class PlaceManager
|
|||||||
return (OccupantInfo)_occInfo.get(bodyOid);
|
return (OccupantInfo)_occInfo.get(bodyOid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Applies the supplied occupant operation to each occupant currently
|
||||||
|
* present in this place.
|
||||||
|
*/
|
||||||
|
public void applyToOccupants (OccupantOp op)
|
||||||
|
{
|
||||||
|
if (_plobj != null) {
|
||||||
|
Iterator iter = _plobj.occupantInfo.entries();
|
||||||
|
while (iter.hasNext()) {
|
||||||
|
op.apply((OccupantInfo)iter.next());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the occupant info for this room occupant. <em>Note:</em>
|
* Updates the occupant info for this room occupant. <em>Note:</em>
|
||||||
* This must be used rather than setting the occupant info directly to
|
* This must be used rather than setting the occupant info directly to
|
||||||
|
|||||||
Reference in New Issue
Block a user