* @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(){
},
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){
}
});
+
+
+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) );
+}