protected void hitTarget(boolean hit, Player owner, Selectable target) {
   if (hit) damageTarget(target);
   AttackScanFilter filter = new AttackScanFilter(owner, MAX_BOUNDS_LENGTH);
   owner.getWorld().getUnitGrid().scan(filter, target.getGridX(), target.getGridY());
   Selectable s = filter.removeTarget();
   if (s != null && owner.getWorld().getRandom().nextFloat() > .5f) {
     setTarget(s);
   } else super.hitTarget(hit, owner, target);
 }
Example #2
0
 private void visitSelectable(
     ModelVisitor visitor,
     Selectable selectable,
     float z_offset,
     float selection_radius,
     float selection_height) {
   boolean in_view =
       !picking
           || (selectable.isEnabled()
               && (visible_override
                   || pickingInFrustum(
                       selectable,
                       camera.getFrustum(),
                       z_offset,
                       selection_radius,
                       selection_height)));
   if (in_view) {
     Player owner = selectable.getOwnerNoCheck();
     boolean point_on_map =
         !local_player.isEnemy(owner)
             || (!owner.teamHasBuilding()
                 && PeerHub.getFreeQuitTimeLeft(local_player.getWorld()) < 0f);
     ModelState state = getCachedState(visitor, selectable, z_offset);
     int sort_status = addToRenderList(state, point_on_map);
     if (!picking && selectable.isEnabled() && sort_status == SpriteSorter.DETAIL_POLYGON) {
       SelectableShadowRenderer shadow_renderer =
           (SelectableShadowRenderer)
               render_queues.getShadowRenderer(
                   selectable.getTemplate().getSelectableShadowRenderer());
       if (isHovered(selectable) || isSelected(selectable)) {
         shadow_renderer.addToSelectionList(state);
       } else {
         shadow_renderer.addToShadowList(state);
       }
     }
   }
 }
Example #3
0
 private float getVisuallyCorrectHeight(float x_f, float y_f) {
   int patch_level = landscape_renderer.getPatchLevelFromCoordinates(x_f, y_f).getLevel();
   return local_player.getWorld().getHeightMap().computeInterpolatedHeight(patch_level, x_f, y_f);
 }