Serious scene surgery.
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@344 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: ClusterUtil.java,v 1.1 2001/08/14 21:29:40 shaper Exp $
|
||||
// $Id: ClusterUtil.java,v 1.2 2001/09/21 02:30:35 mdb Exp $
|
||||
|
||||
package com.threerings.miso.scene.util;
|
||||
|
||||
@@ -22,12 +22,14 @@ public class ClusterUtil
|
||||
* @param clusters the cluster list.
|
||||
* @param loc the location.
|
||||
*/
|
||||
public static int getClusterIndex (ArrayList clusters, Location loc)
|
||||
public static int getClusterIndex (Cluster[] clusters, Location loc)
|
||||
{
|
||||
int size = clusters.size();
|
||||
int size = clusters.length;
|
||||
for (int ii = 0; ii < size; ii++) {
|
||||
Cluster cluster = (Cluster)clusters.get(ii);
|
||||
if (cluster.contains(loc)) return ii;
|
||||
Cluster cluster = clusters[ii];
|
||||
if (cluster.contains(loc)) {
|
||||
return ii;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
@@ -35,7 +37,7 @@ public class ClusterUtil
|
||||
/**
|
||||
* Remove the given location from its cluster, if any.
|
||||
*
|
||||
* @param clusters the cluster list.
|
||||
* @param clusters the cluster array.
|
||||
* @param loc the location.
|
||||
*/
|
||||
public static void remove (ArrayList clusters, Location loc)
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
//
|
||||
// $Id: MisoSceneUtil.java,v 1.1 2001/09/21 02:30:35 mdb Exp $
|
||||
|
||||
package com.threerings.miso.scene.util;
|
||||
|
||||
import com.threerings.miso.scene.*;
|
||||
|
||||
/**
|
||||
* Miso scene related utility functions and information.
|
||||
*/
|
||||
public class MisoSceneUtil
|
||||
{
|
||||
/** String translations of each tile layer name. */
|
||||
public static final String[] XLATE_LAYERS = { "Base", "Fringe", "Object" };
|
||||
|
||||
/**
|
||||
* Return the location object at the given full coordinates, or null
|
||||
* if no location is currently present at that location.
|
||||
*
|
||||
* @param scene the scene whose locations should be searched.
|
||||
* @param x the full x-position coordinate.
|
||||
* @param y the full y-position coordinate.
|
||||
*
|
||||
* @return the location object.
|
||||
*/
|
||||
public static Location getLocation (MisoScene scene, int x, int y)
|
||||
{
|
||||
Location[] locs = scene.getLocations();
|
||||
int size = locs.length;
|
||||
for (int ii = 0; ii < size; ii++) {
|
||||
Location loc = locs[ii];
|
||||
if (loc.x == x && loc.y == y) {
|
||||
return loc;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the portal with the given name, or null if the portal isn't
|
||||
* found in the portal list.
|
||||
*
|
||||
* @param scene the scene whose portals should be searched.
|
||||
* @param name the portal name.
|
||||
*
|
||||
* @return the portal object.
|
||||
*/
|
||||
public static Portal getPortal (MisoScene scene, String name)
|
||||
{
|
||||
Portal[] portals = scene.getPortals();
|
||||
int size = portals.length;
|
||||
for (int ii = 0; ii < size; ii++) {
|
||||
Portal portal = portals[ii];
|
||||
if (portal.name.equals(name)) {
|
||||
return portal;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the cluster index number the given location is in, or -1
|
||||
* if the location is not in any cluster.
|
||||
*
|
||||
* @param scene the containing scene.
|
||||
* @param loc the location.
|
||||
*
|
||||
* @return the cluster index or -1 if the location is not in any
|
||||
* cluster.
|
||||
*/
|
||||
public static int getClusterIndex (MisoScene scene, Location loc)
|
||||
{
|
||||
return ClusterUtil.getClusterIndex(scene.getClusters(), loc);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user