protected void updateSearchlight() { setSearchlightEnabled((ce() != null) && (target != null) && ce().isUsingSpotlight() && ce().getCrew().isActive() && !ce().isHidden() && SearchlightAttackAction.isPossible(clientgui.getClient() .getGame(), cen, target, null) && !((ce() instanceof Tank) && (((Tank) ce()).getStunnedTurns() > 0))); }
/** * Sets the aiming mode, depending on the target and the attacker. * Against immobile mechs, targeting computer aiming mode will be used * if turned on. (This is a hack, but it's the resolution suggested by * the bug submitter, and I don't think it's half bad. */ public void setAimingMode() { boolean allowAim; // TC against a mech allowAim = ((this.firingDisplay.target != null) && (this.firingDisplay.ce() != null) && this.firingDisplay.ce().hasAimModeTargComp() && ((this.firingDisplay.target instanceof Mech) || (this.firingDisplay.target instanceof Tank) || (this.firingDisplay.target instanceof BattleArmor) || (this.firingDisplay.target instanceof Protomech))); if (allowAim) { aimingMode = IAimingModes.AIM_MODE_TARG_COMP; return; } // immobile mech or gun emplacement allowAim = ((this.firingDisplay.target != null) && ((this.firingDisplay.target.isImmobile() && ((this.firingDisplay.target instanceof Mech) || (this.firingDisplay.target instanceof Tank))) || (this.firingDisplay.target instanceof GunEmplacement))); if (allowAim) { aimingMode = IAimingModes.AIM_MODE_IMMOBILE; return; } aimingMode = IAimingModes.AIM_MODE_NONE; }
/** * clear turret */ private void doClearTurret() { String title = Messages.getString("FiringDisplay.ClearTurret.title"); //$NON-NLS-1$ String body = Messages.getString("FiringDisplay.ClearTurret.message"); //$NON-NLS-1$ if (!clientgui.doYesNoDialog(title, body)) { return; } if ((((attacks.size() == 0) && (ce() instanceof Tank) && (((Tank) ce()) .isTurretJammed(((Tank) ce()).getLocTurret()))) || ((Tank) ce()) .isTurretJammed(((Tank) ce()).getLocTurret2()))) { UnjamTurretAction uta = new UnjamTurretAction(ce().getId()); attacks.add(uta); ready(); } }
/** * A VTOL or LAM in airmech mode making a bombing or strafing attack already has the target set * during the movement phase. */ void updateVTOLGroundTarget() { clientgui.bv.clearStrafingCoords(); target(null); isStrafing = false; strafingCoords.clear(); if (ce().isBomber() && ((IBomber)ce()).isVTOLBombing()) { target(((IBomber)ce()).getVTOLBombTarget()); clientgui.bv.addStrafingCoords(target.getPosition()); } else if ((ce() instanceof VTOL) && ((VTOL)ce()).getStrafingCoords().size() > 0) { strafingCoords.addAll(((VTOL)ce()).getStrafingCoords()); strafingCoords.forEach(c -> clientgui.bv.addStrafingCoords(c)); isStrafing = true; } }
/** * Refreshes all displays. */ protected void refreshAll() { if (ce() == null) { return; } clientgui.bv.redrawEntity(ce()); clientgui.mechD.displayEntity(ce()); clientgui.mechD.showPanel("weapons"); //$NON-NLS-1$ clientgui.mechD.wPan.selectFirstWeapon(); if (ce().isMakingVTOLGroundAttack()) { this.updateVTOLGroundTarget(); } updateTarget(); }
/** * Torso twist in the proper direction. */ void torsoTwist(Coords twistTarget) { int direction = ce().getFacing(); if (twistTarget != null) { direction = ce().clipSecondaryFacing( ce().getPosition().direction(twistTarget)); } if (direction != ce().getSecondaryFacing()) { clearAttacks(); attacks.addElement(new TorsoTwistAction(cen, direction)); ce().setSecondaryFacing(direction); refreshAll(); } }
/** * update for change of arms-flipping status * * @param armsFlipped */ void updateFlipArms(boolean armsFlipped) { if (ce() == null) { return; } if (armsFlipped == ce().getArmsFlipped()) { return; } twisting = false; torsoTwist(null); clearAttacks(); ce().setArmsFlipped(armsFlipped); attacks.addElement(new FlipArmsAction(cen, armsFlipped)); updateTarget(); refreshAll(); }
/** * Torso twist to the left or right * * @param twistDir An <code>int</code> specifying wether we're twisting left or * right, 0 if we're twisting to the left, 1 if to the right. */ void torsoTwist(int twistDir) { int direction = ce().getSecondaryFacing(); if (twistDir == 0) { clearAttacks(); direction = ce().clipSecondaryFacing((direction + 5) % 6); attacks.addElement(new TorsoTwistAction(cen, direction)); ce().setSecondaryFacing(direction); refreshAll(); } else if (twistDir == 1) { clearAttacks(); direction = ce().clipSecondaryFacing((direction + 7) % 6); attacks.addElement(new TorsoTwistAction(cen, direction)); ce().setSecondaryFacing(direction); refreshAll(); } }
/** * removes the last action */ protected void removeLastFiring() { if (!attacks.isEmpty()) { Object o = attacks.lastElement(); if (o instanceof WeaponAttackAction) { WeaponAttackAction waa = (WeaponAttackAction) o; ce().getEquipment(waa.getWeaponId()).setUsedThisRound(false); attacks.removeElement(o); clientgui.mechD.wPan.displayMech(ce()); clientgui.getClient().getGame().removeAction(o); clientgui.bv.refreshAttacks(); clientgui.minimap.drawMap(); } } }
/** * The entity spends the rest of its turn finding a club */ private void findClub() { if (ce() == null) { return; } // comfirm this action String title = Messages.getString("FiringDisplay.FindClubDialog.title"); //$NON-NLS-1$ String body = Messages .getString("FiringDisplay.FindClubDialog.message"); //$NON-NLS-1$ if (!clientgui.doYesNoDialog(title, body)) { return; } attacks.removeAllElements(); attacks.addElement(new FindClubAction(cen)); ready(); }
/** * Removes temp attacks from the game and board */ protected void removeTempAttacks() { // remove temporary attacks from game & board clientgui.getClient().getGame().removeActionsFor(cen); clientgui.bv.removeAttacksFor(ce()); }
/** * Called Shots - changes the current called shots selection */ protected void changeCalled() { int wn = clientgui.mechD.wPan.getSelectedWeaponNum(); // Do nothing we have no unit selected. if (ce() == null) { return; } Mounted m = ce().getEquipment(wn); if ((m == null)) { return; } // send change to the server m.getCalledShot().switchCalledShot(); clientgui.getClient().sendCalledShotChange(cen, wn); updateTarget(); clientgui.mechD.wPan.displayMech(ce()); clientgui.mechD.wPan.selectWeapon(wn); }
@Override public void clear() { if (clientgui.getClient().isMyTurn()) { setStatusBarText(Messages .getString("FiringDisplay.its_your_turn")); //$NON-NLS-1$ } if ((target instanceof Entity) && Compute.isGroundToAir(ce(), target)) { ((Entity)target).setPlayerPickedPassThrough(cen, null); } if ((ce() != null) && !ce().isMakingVTOLGroundAttack()) { target(null); } clearAttacks(); clientgui.getBoardView().select(null); clientgui.getBoardView().cursor(null); refreshAll(); }