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);
 }
Beispiel #2
0
 private static boolean pickingInFrustum(
     Selectable selectable,
     float[][] frustum,
     float z_offset,
     float selection_radius,
     float selection_height) {
   picking_selection_box.setBounds(
       -selection_radius + selectable.getPositionX(),
       selection_radius + selectable.getPositionX(),
       -selection_radius + selectable.getPositionY(),
       selection_radius + selectable.getPositionY(),
       z_offset,
       z_offset + selection_height);
   return RenderTools.inFrustum(picking_selection_box, frustum) >= RenderTools.IN_FRUSTUM;
 }
Beispiel #3
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);
       }
     }
   }
 }