Added code to allow object visitors to visit a specific section.
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@2986 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: SparseMisoSceneModel.java,v 1.11 2004/02/25 14:43:57 mdb Exp $
|
||||
// $Id: SparseMisoSceneModel.java,v 1.12 2004/03/30 01:30:38 eric Exp $
|
||||
|
||||
package com.threerings.miso.data;
|
||||
|
||||
@@ -259,6 +259,18 @@ public class SparseMisoSceneModel extends MisoSceneModel
|
||||
visitObjects(visitor, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Visit all the objects in the section at the specified cords.
|
||||
*/
|
||||
public void visitObjects (int x, int y, ObjectVisitor visitor)
|
||||
{
|
||||
Section sect = getSection(x, y, false);
|
||||
if (sect == null) {
|
||||
return;
|
||||
}
|
||||
visitSection(sect, visitor, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Informs the supplied visitor of each object in this scene.
|
||||
*
|
||||
@@ -269,18 +281,28 @@ public class SparseMisoSceneModel extends MisoSceneModel
|
||||
{
|
||||
for (Iterator iter = getSections(); iter.hasNext(); ) {
|
||||
Section sect = (Section)iter.next();
|
||||
for (int oo = 0; oo < sect.objectInfo.length; oo++) {
|
||||
ObjectInfo oinfo = sect.objectInfo[oo];
|
||||
visitor.visit(oinfo);
|
||||
}
|
||||
if (!interestingOnly) {
|
||||
ObjectInfo info = new ObjectInfo();
|
||||
for (int oo = 0; oo < sect.objectTileIds.length; oo++) {
|
||||
info.tileId = sect.objectTileIds[oo];
|
||||
info.x = sect.objectXs[oo];
|
||||
info.y = sect.objectYs[oo];
|
||||
visitor.visit(info);
|
||||
}
|
||||
visitSection(sect, visitor, interestingOnly);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Visit all the objects (or just interesting if specified) in the
|
||||
* specified section.
|
||||
*/
|
||||
protected void visitSection (Section sect, ObjectVisitor visitor,
|
||||
boolean interestingOnly)
|
||||
{
|
||||
for (int oo = 0; oo < sect.objectInfo.length; oo++) {
|
||||
ObjectInfo oinfo = sect.objectInfo[oo];
|
||||
visitor.visit(oinfo);
|
||||
}
|
||||
if (!interestingOnly) {
|
||||
ObjectInfo info = new ObjectInfo();
|
||||
for (int oo = 0; oo < sect.objectTileIds.length; oo++) {
|
||||
info.tileId = sect.objectTileIds[oo];
|
||||
info.x = sect.objectXs[oo];
|
||||
info.y = sect.objectYs[oo];
|
||||
visitor.visit(info);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user