private final Bullet setFireImpl(double power) { if (Double.isNaN(power)) { println("SYSTEM: You cannot call fire(NaN)"); return null; } if (getGunHeatImpl() > 0 || getEnergyImpl() == 0) { return null; } power = min(getEnergyImpl(), min(max(power, Rules.MIN_BULLET_POWER), Rules.MAX_BULLET_POWER)); Bullet bullet; BulletCommand wrapper; Event currentTopEvent = eventManager.getCurrentTopEvent(); nextBulletId++; if (currentTopEvent != null && currentTopEvent.getTime() == status.getTime() && !statics.isAdvancedRobot() && status.getGunHeadingRadians() == status.getRadarHeadingRadians() && ScannedRobotEvent.class.isAssignableFrom(currentTopEvent.getClass())) { // this is angle assisted bullet ScannedRobotEvent e = (ScannedRobotEvent) currentTopEvent; double fireAssistAngle = Utils.normalAbsoluteAngle(status.getHeadingRadians() + e.getBearingRadians()); bullet = new Bullet( fireAssistAngle, getX(), getY(), power, statics.getName(), null, true, nextBulletId); wrapper = new BulletCommand(power, true, fireAssistAngle, nextBulletId); } else { // this is normal bullet bullet = new Bullet( status.getGunHeadingRadians(), getX(), getY(), power, statics.getName(), null, true, nextBulletId); wrapper = new BulletCommand(power, false, 0, nextBulletId); } firedEnergy += power; firedHeat += Rules.getGunHeat(power); commands.getBullets().add(wrapper); bullets.put(nextBulletId, bullet); return bullet; }
public double getGunHeading() { getCall(); return status.getGunHeadingRadians(); }