public double getTonnage(Entity entity) { return getTonnage(entity, Entity.LOC_NONE); }
@Override public boolean needsFixing() { return (shotsNeeded < 0) || ((shotsNeeded > 0) && (type.getTonnage(null) <= Math.ceil(bayAvailableCapacity()))); }
@Override public int getFullShots() { return (int) Math.floor(capacity * ((AmmoType) type).getShots() / type.getTonnage(null)); }
private int getFullShots() { return (int) Math.floor(capacity * ((AmmoType) type).getShots() / type.getTonnage(null)); }
@Override public int getBaseTime() { if (isSalvaging()) { return 120; } else { //Capital Missiles take a flat 60m per missile per errata if (type.hasFlag(AmmoType.F_CAP_MISSILE)) { return 60; } return (int) Math.ceil(15 * type.getTonnage(null)); } }
@Override public double getTonnage() { return getCurrentShots() * type.getTonnage(null) / ((AmmoType) type).getShots(); }
private Map<String, Object> formatManipulatorRow(int mountLoc, Mounted manipulator) { final Map<String, Object> retVal = new HashMap<>(); retVal.put("locName", BattleArmor.getBaMountLocAbbr(mountLoc)); if (null == manipulator) { retVal.put("eqName", Messages.getString("TROView.None")); retVal.put("eqMass", 0); } else { String name = manipulator.getName(); if (name.contains("[")) { name = name.replaceAll(".*\\[", "").replaceAll("\\].*", ""); } retVal.put("eqName", name); retVal.put("eqMass", manipulator.getType().getTonnage(null) * 1000); } return retVal; }
public double getUnusedCapacity() { return capacity - Math.ceil(getCurrentShots() * type.getTonnage(null) / ((AmmoType) type).getShots()); }
/** * Adds ammo data used by large craft */ protected void addAmmo() { final Map<String, List<Mounted>> ammoByType = aero.getAmmo().stream() .collect(Collectors.groupingBy(m -> m.getType().getName())); final List<Map<String, Object>> ammo = new ArrayList<>(); for (final List<Mounted> aList : ammoByType.values()) { final Map<String, Object> ammoEntry = new HashMap<>(); ammoEntry.put("name", aList.get(0).getType().getName().replaceAll("\\s+Ammo", "")); ammoEntry.put("shots", aList.stream().mapToInt(Mounted::getUsableShotsLeft).sum()); ammoEntry.put("tonnage", aList.stream().mapToDouble(m -> m.getType().getTonnage(aero)).sum()); ammo.add(ammoEntry); } setModelData("ammo", ammo); }
@Override public void setUnit(Unit u) { super.setUnit(u); if(null != unit) { equipTonnage = type.getTonnage(unit.getEntity()); } }
@Override public void setUnit(Unit u) { super.setUnit(u); if(null != unit) { equipTonnage = type.getTonnage(unit.getEntity()); } }
@Override public IAcquisitionWork getAcquisitionWork() { int shots = 1; if (type instanceof AmmoType) { shots = ((AmmoType)type).getShots() * (int) Math.floor(getUnusedCapacity() / type.getTonnage(null)); } return new AmmoStorage(1, type, shots, campaign); }
/** * @return the tonnage of additional mounted communications equipment */ public int getExtraCommGearTons() { int i = 0; for (Mounted mounted : miscList) { if (mounted.getType().hasFlag(MiscType.F_COMMUNICATIONS) && !mounted.isInoperable()) { i += mounted.getType().getTonnage(this); } } return i; }
public boolean hasActiveFieldArtillery() { boolean hasArtillery = false; double smallestGun = 100.0; for(Mounted wpn : getWeaponList()) { if(wpn.getLocation() != LOC_FIELD_GUNS) { continue; } if(wpn.getType().hasFlag(WeaponType.F_ARTILLERY)) { hasArtillery = true; if(wpn.getType().getTonnage(this) < smallestGun) { smallestGun = wpn.getType().getTonnage(this); } } } //you must have enough men to fire at least the smallest piece return hasArtillery && (getShootingStrength() >= smallestGun); }
equipTonnage = type.getTonnage(null); } catch(NullPointerException ex) { MekHQ.getLogger().error(BattleArmorAmmoBin.class, "restore", ex);
public EquipmentPart(int tonnage, EquipmentType et, int equipNum, boolean omniPodded, Campaign c) { super(tonnage, omniPodded, c); this.type =et; if(null != type) { this.name = type.getName(); this.typeName = type.getInternalName(); } if (equipNum != -1) { this.equipmentNum = equipNum; } else { equipmentNum = -1; } if(null != type) { try { equipTonnage = type.getTonnage(null); } catch(NullPointerException ex) { MekHQ.getLogger().error(EquipmentPart.class, "EquipmentPart", ex); } } }
@Override public double getWeightHeatSinks() { boolean hasCompact = false; double compactHsTons = 0; for (Mounted misc : mech.getMisc()) { if (misc.getType().hasFlag(MiscType.F_COMPACT_HEAT_SINK)) { hasCompact = true; compactHsTons += misc.getType().getTonnage(mech); } } if (hasCompact) { return compactHsTons - (engine.getWeightFreeEngineHeatSinks() * 1.5f); } else { return mech.heatSinks() - engine.getWeightFreeEngineHeatSinks(); } }
/** * Additional crew requirements for vehicles and aerospace vessels for certain types of * equipment. */ public static int equipmentCrewRequirements(EquipmentType eq) { if (eq instanceof MiscType) { if (eq.hasFlag(MiscType.F_MASH) || eq.hasFlag(MiscType.F_MASH_EXTRA) || eq.hasFlag(MiscType.F_MOBILE_FIELD_BASE)) { return 5; } if (eq.hasFlag(MiscType.F_FIELD_KITCHEN)) { return 3; } if (eq.hasFlag(MiscType.F_COMMUNICATIONS)) { return (int) eq.getTonnage(null); } if (eq.hasFlag(MiscType.F_MOBILE_HPG)) { // Mobile HPG has crew requirement of 10; ground-mobile has requirement of 1. return eq.hasFlag(MiscType.F_TANK_EQUIPMENT)? 1 : 10; } } return 0; }
public double getTankWeightDualTurret() { double weight = 0; // For omni vees, the base chassis sets a turret weight if (tank.isOmni() && tank.getBaseChassisTurret2Weight() >= 0) { weight = tank.getBaseChassisTurret2Weight(); } else { // For non-omnis, count up the weight of eq in the turret for (Mounted m : tank.getEquipment()) { if ((m.getLocation() == tank.getLocTurret2()) && !(m.getType() instanceof AmmoType)) { weight += m.getType().getTonnage(tank); } } // Turrets weight 10% of the weight of weapons in them weight = weight / 10.0f; } return TestEntity.ceilMaxHalf(weight, getWeightCeilingTurret()); }
public double getTankWeightTurret() { double weight = 0; // For omni vees, the base chassis sets a turret weight if (tank.isOmni() && tank.getBaseChassisTurretWeight() >= 0) { weight = tank.getBaseChassisTurretWeight(); } else { // For non-omnis, count up the weight of eq in the turret for (Mounted m : tank.getEquipment()) { if ((m.getLocation() == tank.getLocTurret()) && !(m.getType() instanceof AmmoType)) { weight += m.getType().getTonnage(tank); } } // Turrets weight 10% of the weight of weapons in them weight = weight / 10.0f; } if (tank.isSupportVehicle()) { if (getEntity().getWeight() < 5) { return TestEntity.ceil(weight, Ceil.KILO); } else { return TestEntity.ceil(weight, Ceil.HALFTON); } } else { return TestEntity.ceilMaxHalf(weight, getWeightCeilingTurret()); } }