Package com.threerings.whirled.spot.data

Examples of com.threerings.whirled.spot.data.SceneLocation


        if (allowPortals && _plocs.contains(new Point(tx, ty))) {
            return true;
        }

        // if they are already standing on this tile, allow it
        SceneLocation cloc = _ssobj.occupantLocs.get(Integer.valueOf(source.getOid()));
        if (cloc != null) {
            StageLocation sloc = (StageLocation) cloc.loc;
            if (MisoUtil.fullToTile(sloc.x) == tx &&
                    MisoUtil.fullToTile(sloc.y) == ty) {
//                Log.info("Allowing adjust [who=" + source.who () +
View Full Code Here


        tx = MisoUtil.fullToTile(sloc.x);
        ty = MisoUtil.fullToTile(sloc.y);
        _loners.put(body.getOid(), new Rectangle(tx, ty, 1, 1));

        return new SceneLocation(sloc, body.getOid());
    }
View Full Code Here

        Cluster cl = clrec.getCluster();
        if (clrec.size() == 1) {
            // if we're adding our first player, assign initial dimensions
            // to the cluster
            cl.width = 1; cl.height = 1;
            SceneLocation loc = locationForBody(bodyOid);
            if (loc == null) {
                log.warning("Foreign body added to cluster [clrec=" + clrec +
                            ", body=" + body.who() + "].");
                cl.x = 10; cl.y = 10;
            } else {
View Full Code Here

    }

    /** Helper function for {@link #bodyAdded}. */
    protected void positionBody (Cluster cl, int bodyOid, List<SceneLocation> locs)
    {
        SceneLocation sloc = _ssobj.occupantLocs.get(Integer.valueOf(bodyOid));
        if (sloc == null) {
            BodyObject user = (BodyObject)_omgr.getObject(bodyOid);
            String who = (user == null) ? ("" + bodyOid) : user.who();
            log.warning("Can't position locationless user " +
                        "[where=" + where() + ", cluster=" + cl +
                        ", boid=" + who + "].");
            return;
        }

        SceneLocation cloc = getClosestLoc(locs, sloc);
//         Log.info("Maybe moving " + bodyOid + " from " + sloc +
//                  " to " + cloc +
//                  " (avail=" + StringUtil.toString(locs) + ").");
        if (cloc != null && !cloc.loc.equivalent(sloc.loc)) {
            cloc.bodyOid = bodyOid;
View Full Code Here

     */
    protected static SceneLocation getClosestLoc (
        List<SceneLocation>locs, SceneLocation optimalLocation)
    {
        StageLocation loc = (StageLocation) optimalLocation.loc;
        SceneLocation cloc = null;
        float cdist = Integer.MAX_VALUE;
        int cidx = -1;
        for (int ii = 0, ll = locs.size(); ii < ll; ii++) {
            SceneLocation tloc = locs.get(ii);
            StageLocation sl = (StageLocation) tloc.loc;
            float tdist = MathUtil.distance(loc.x, loc.y, sl.x, sl.y);
            if (tdist < cdist) {
                cloc = tloc;
                cdist = tdist;
View Full Code Here

     * @param entry the portal referenced by the from portal's targetPortalId or the scene's
     * default entrance if the from portal did not exist or had no target portal.
     */
    protected SceneLocation computeEnteringLocation (BodyObject body, Portal from, Portal entry)
    {
        return new SceneLocation(entry.getOppLocation(), body.getOid());
    }
View Full Code Here

    /**
     * Updates the location of the specified body.
     */
    protected void updateLocation (BodyObject source, Location loc)
    {
        SceneLocation sloc = new SceneLocation(loc, source.getOid());
        if (!_ssobj.occupantLocs.contains(sloc)) {
            // complain if they don't already have a location configured
            log.warning("Changing loc for occupant without previous loc",
                "where", where(), "who", source.who(), "nloc", loc, new Exception());
            _ssobj.addToOccupantLocs(sloc);
View Full Code Here

        // cluster
        if (cluster.width == 1) {
            StageLocation loc = new StageLocation(
                MisoUtil.toFull(cluster.x, 2), MisoUtil.toFull(cluster.y, 2),
                (byte)DirectionCodes.SOUTHWEST);
            list.add(new SceneLocation(loc, 0));
            return list;
        }

        double radius = (double)fwid/2;
        int clidx = cluster.width-2;
        if (clidx >= CLUSTER_METRICS.length/2 || clidx < 0) {
            log.warning("Requested locs from invalid cluster " + cluster + ".", new Exception());
            return list;
        }

        for (double angle = CLUSTER_METRICS[clidx*2]; angle < Math.PI*2;
             angle += CLUSTER_METRICS[clidx*2+1]) {
            int sx = cx + (int)Math.round(Math.cos(angle) * radius);
            int sy = cy + (int)Math.round(Math.sin(angle) * radius);

            // obtain the orientation facing toward the center
            int orient = 2*(int)(Math.round(angle/(Math.PI/4))%8);
            orient = DirectionUtil.rotateCW(DirectionCodes.SOUTH, orient);
            orient = DirectionUtil.getOpposite(orient);

            // convert them back to full coordinates for the location
            int tx = MathUtil.floorDiv(sx, _metrics.finegran);
            sx = MisoUtil.toFull(tx, sx-(tx*_metrics.finegran));
            int ty = MathUtil.floorDiv(sy, _metrics.finegran);
            sy = MisoUtil.toFull(ty, sy-(ty*_metrics.finegran));
            StageLocation loc = new StageLocation(sx, sy, (byte) orient);
            list.add(new SceneLocation(loc, 0));
        }

        return list;
    }
View Full Code Here

TOP

Related Classes of com.threerings.whirled.spot.data.SceneLocation

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.