From 49e688735871d875257f871e84b905e4cc9e545b Mon Sep 17 00:00:00 2001 From: Mike Thomas Date: Tue, 10 Aug 2010 03:59:48 +0000 Subject: [PATCH] A few bits I'd marked as part of the pathing overhaul that I can just get now. git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@946 c613c5cb-e716-0410-b11b-feb51c14d237 --- .../stage/client/CrowdStageScenePanel.as | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/as/com/threerings/stage/client/CrowdStageScenePanel.as b/src/as/com/threerings/stage/client/CrowdStageScenePanel.as index 5e87bf45..97505ab4 100644 --- a/src/as/com/threerings/stage/client/CrowdStageScenePanel.as +++ b/src/as/com/threerings/stage/client/CrowdStageScenePanel.as @@ -20,6 +20,7 @@ package com.threerings.stage.client { import flash.geom.Point; +import flash.geom.Rectangle; import flash.events.MouseEvent; @@ -71,6 +72,8 @@ public class CrowdStageScenePanel extends StageScenePanel _proxrad = int(Math.max(_proxrad, Math.sqrt(_isoView.size.x*_isoView.size.x + _isoView.size.y*_isoView.size.y))); recomputeProximate(); + + _vbounds = new Rectangle(0, 0, _isoView.size.x, _isoView.size.y); } override public function willEnterPlace (plObj :PlaceObject) :void @@ -285,7 +288,7 @@ public class CrowdStageScenePanel extends StageScenePanel if (!isProximateToLoc(nloc)) { if (sprite != null) { // if they are visible, walk them to their new location - if (true/*TODO Path _vbounds.intersects(sprite.getBounds())*/) { + if (_vbounds.intersects(sprite.screenBounds)) { moveSpriteToLoc(sprite, nloc.loc); } // now queue them up for removal on arrival as appropriate @@ -357,6 +360,8 @@ public class CrowdStageScenePanel extends StageScenePanel { var cx :int = sprite.x; var cy :int = sprite.y; + var nx :int = MisoUtil.fullToTile(loc.x); + var ny :int = MisoUtil.fullToTile(loc.y); // if this panel is not yet showing, warp the sprite directly if (!visible) { @@ -367,8 +372,8 @@ public class CrowdStageScenePanel extends StageScenePanel // if the source and destination are both offscreen, warp the // sprite to where they are going - // TODO Path boolean endsOff = !_vbounds.contains(nx, ny); - if (false /*TODO Path!_vbounds.intersects(sprite.getBounds()) && endsOff*/) { + var endsOff :Boolean = !_vbounds.contains(nx, ny); + if (!_vbounds.intersects(sprite.screenBounds) && endsOff) { sprite.cancelMove(); sprite.placeAtLoc(loc); return true; @@ -376,12 +381,12 @@ public class CrowdStageScenePanel extends StageScenePanel // if we are obviously warping (i.e. we moved a great distance), // just blink into position and attempt to do so cleanly - //TODO Path int dx = Math.abs(nx - (_vbounds.x + _vbounds.width/2)); - //TODO Path int dy = Math.abs(ny - (_vbounds.y + _vbounds.height/2)); - if (sprite == _selfSprite/*TODO Path (dx > 2*_vbounds.width || dy > 2*_vbounds.height) && - (sprite == _selfSprite)*/) { - //TODO Path log.info("Warp-a-saurus! " + StringUtil.toString(_vbounds) + - //TODO Path " -> " + StringUtil.toCoordsString(loc.x, loc.y)); + var dx :int = Math.abs(nx - (_vbounds.x + _vbounds.width/2)); + var dy :int = Math.abs(ny - (_vbounds.y + _vbounds.height/2)); + if ((dx > 2*_vbounds.width || dy > 2*_vbounds.height) && + (sprite == _selfSprite)) { + log.info("Warp-a-saurus! " + StringUtil.toString(_vbounds) + + " -> " + StringUtil.toCoordsString(loc.x, loc.y)); sprite.cancelMove(); sprite.placeAtLoc(loc); @@ -695,6 +700,8 @@ public class CrowdStageScenePanel extends StageScenePanel protected var _scObj :StageSceneObject; + protected var _vbounds :Rectangle; + /** Our sprite path velocity. */ // if we had more frames, maybe we could only update their // location when their frame changed. Alas, we do not.