Projectiles no longer block pathing calculations.
authordsc <david.schoonover@gmail.com>
Tue, 11 Jan 2011 07:57:49 +0000 (23:57 -0800)
committerdsc <david.schoonover@gmail.com>
Tue, 11 Jan 2011 07:57:49 +0000 (23:57 -0800)
src/tanks/map/pathing/map-pathing.cjs
src/tanks/map/pathing/map-searching.cjs

index 6d189ba..b60503a 100644 (file)
@@ -234,8 +234,8 @@ Y.subclass('Square', new Vec(0,0), {
      * @private
      */
     _filterBlocked : function filterBlocked(v, r){
-        return (v.blocking === BoundsType.BLOCKING  && !v.isBoundary)
-            || (v.blocking === BoundsType.IRREGULAR && v.testCollide(this.agent,this,null) ); // FIXME: hm. calc bbox?
+        return ( v.blocking === BoundsType.BLOCKING  && !(v.isBoundary || v.isProjectile) )
+            || ( v.blocking === BoundsType.IRREGULAR && v.testCollide(this.agent,this,null) ); // FIXME: hm. calc bbox?
     },
     
     getNeighbors : function getNeighbors(){
index f96a082..db8ca8e 100644 (file)
@@ -34,27 +34,15 @@ Y.core.extend(Map.fn, {
     },
     
     findNearBullets : function findNearBullets(me, ticks){
-        return this.findNearLike(me, ticks, this._nearBulletFilter);
-    },
-    _nearBulletFilter : function nearBulletFilter(agent){
-        return agent.isProjectile;
+        return this.findNearLike(me, ticks, nearBulletFilter);
     },
     
     findNearEnemies : function findNearEnemies(me, ticks){
-        return this.findNearLike(me, ticks, this._nearEnemyFilter);
-    },
-    _nearEnemyFilter : function nearEnemyFilter(agent){
-        var me = this; // Runs in the context of the 'me' unit; @see this.findNearLike()
-        return agent.isCombatant && agent.align !== me.align;
+        return this.findNearLike(me, ticks, nearEnemyFilter);
     },
     
     findNearEnemiesInSight : function findNearEnemiesInSight(me, ticks){
-        return this.findNearLike(me, ticks, this._nearEnemyInSightFilter);
-    },
-    _nearEnemyInSightFilter : function nearEnemyInSightFilter(agent){
-        var me = this; // Runs in the context of the 'me' unit; @see this.findNearLike()
-        return ( agent.align !== me.align && agent.isCombatant && 
-                 new Trajectory(me, me.loc, agent.loc).canSee(agent) );
+        return this.findNearLike(me, ticks, nearEnemyInSightFilter);
     },
     
     closestOf : function closestOf(me, agents){
@@ -87,3 +75,19 @@ Y.core.extend(Map.fn, {
     }
     
 });
+
+
+function nearBulletFilter(agent){ 
+    return agent.isProjectile;
+}
+
+function nearEnemyFilter(agent){
+    var me = this; // Runs in the context of the 'me' unit; @see this.findNearLike()
+    return agent.isCombatant && agent.align !== me.align;
+}
+
+function nearEnemyInSightFilter(agent){
+    var me = this; // Runs in the context of the 'me' unit; @see this.findNearLike()
+    return ( agent.align !== me.align && agent.isCombatant && 
+             new Trajectory(me, me.loc, agent.loc).canSee(agent) );
+}