Advertisement
Originem

Untitled

Sep 6th, 2019
683
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5.07 KB | None | 0 0
  1. package data.scripts.utils;
  2.  
  3. import com.fs.starfarer.api.Global;
  4. import com.fs.starfarer.api.combat.BaseHullMod;
  5. import com.fs.starfarer.api.combat.ShipAPI;
  6. import com.fs.starfarer.api.combat.WeaponAPI;
  7. import com.fs.starfarer.api.loading.FighterWingSpecAPI;
  8. import com.fs.starfarer.api.loading.WeaponSpecAPI;
  9. import com.fs.starfarer.api.ui.TooltipMakerAPI;
  10. import com.fs.starfarer.api.util.Misc;
  11. import data.scripts.utils.fobs.StringLib;
  12.  
  13. import java.awt.*;
  14. import java.util.ArrayList;
  15. import java.util.HashMap;
  16. import java.util.List;
  17. import java.util.Map;
  18.  
  19. public class FighterDevChecker extends BaseHullMod {
  20.     private static final Color DAMAGE_COLOR = new Color(255, 220, 100);
  21.     private static final Color WEAPON_NAME_COLOR = new Color(100, 220, 200);
  22.     private static final StringLib.I18nSection i18n = new StringLib.I18nSection("hullMod", "fdc", true);
  23.  
  24.     @Override
  25.     public void addPostDescriptionSection(TooltipMakerAPI tooltip, ShipAPI.HullSize hullSize, ShipAPI ship, float width, boolean isForModSpec) {
  26.         if (ship == null) return;
  27.         if (isForModSpec) return;
  28.         float pad = 10f;
  29.         List<FighterWingSpecAPI> wingSpecs = new ArrayList<>();
  30.         for (String wingId : ship.getVariant().getWings()) {
  31.             FighterWingSpecAPI spec = Global.getSettings().getFighterWingSpec(wingId);
  32.             if (spec != null && !wingSpecs.contains(spec)) {
  33.                 wingSpecs.add(spec);
  34.             }
  35.         }
  36.  
  37.         for (FighterWingSpecAPI spec : wingSpecs) {
  38.             int fighterNum = spec.getNumFighters();
  39.             tooltip.setParaOrbitronLarge();
  40.             tooltip.addPara(spec.getWingName(), Misc.getHighlightColor(), pad);
  41.             tooltip.setParaFontDefault();
  42.             tooltip.addPara("Number:" + fighterNum, Misc.getHighlightColor(), 0f);
  43.             Map<WeaponSpecAPI, Integer> weaponSpecToAmountMap = new HashMap<>();
  44.             for (String slotId : spec.getVariant().getFittedWeaponSlots()) {
  45.                 WeaponSpecAPI weaponSpec = spec.getVariant().getWeaponSpec(slotId);
  46.                 if (spec.getVariant().getSlot(slotId).isDecorative()) continue;
  47.                 if (!weaponSpecToAmountMap.containsKey(weaponSpec)) {
  48.                     weaponSpecToAmountMap.put(weaponSpec, 1);
  49.                 } else {
  50.                     weaponSpecToAmountMap.put(weaponSpec, weaponSpecToAmountMap.get(weaponSpec) + 1);
  51.                 }
  52.             }
  53.             for (Map.Entry<WeaponSpecAPI, Integer> entry : weaponSpecToAmountMap.entrySet()) {
  54.                 WeaponSpecAPI weaponSpec = entry.getKey();
  55.                 int weaponNum = entry.getValue();
  56.                 tooltip.addPara(weaponSpec.getWeaponName() + " x " + weaponNum, WEAPON_NAME_COLOR, pad);
  57.                 List<String> description = new ArrayList<>();
  58.                 description.add(i18n.format("wt") + ":" + weaponSpec.getType().getDisplayName());
  59.                 description.add(i18n.format("dt") + ":" + weaponSpec.getDamageType().getDisplayName());
  60.                 description.add("DPS:" + weaponSpec.getDerivedStats().getDps());
  61.                 description.add("FPS:" + weaponSpec.getDerivedStats().getFluxPerSecond());
  62.                 float dph = weaponSpec.getDerivedStats().getDamagePerShot();
  63.                 description.add("DPH:" + dph);
  64.                 description.add("FPH:" + weaponSpec.getDerivedStats().getFluxPerDam() * weaponSpec.getDerivedStats().getDamagePerShot());
  65.                 int burstSize = weaponSpec.getBurstSize();
  66.                 description.add("BurstSize:" + burstSize);
  67.                 if (weaponSpec.usesAmmo()) {
  68.                     description.add(i18n.format("ammo") + ":" + weaponSpec.getMaxAmmo());
  69.                     description.add(i18n.format("ammog") + ":" + weaponSpec.getAmmoPerSecond());
  70.                 }
  71.                 tooltip.addPara(Misc.getAndJoined(description), 0f);
  72.  
  73.                 tooltip.addPara(i18n.format("wwi"), Misc.getGrayColor(), pad);
  74.                 if (!weaponSpec.isBeam()) {
  75.                     tooltip.addPara("%s " + (int) dph + "x" + burstSize + "x" + weaponNum + "x" + fighterNum + "=" + dph * burstSize * weaponNum * fighterNum, pad * 0.5f, DAMAGE_COLOR, i18n.format("dpr") + ":");
  76.                     if (weaponSpec.getType() == WeaponAPI.WeaponType.MISSILE) {
  77.                         tooltip.addPara(i18n.format("dprw"), Misc.getGrayColor(), 0f);
  78.                     }
  79.                 } else {
  80.                     if (weaponSpec.getDerivedStats().getBurstDamage() > 0) {
  81.                         tooltip.addPara("%s " + weaponSpec.getDerivedStats().getBurstDamage() + "x" + weaponNum + "x" + fighterNum + "=" + weaponSpec.getDerivedStats().getBurstDamage() * weaponNum * fighterNum, pad * 0.5f, DAMAGE_COLOR, i18n.format("bbd") + ":");
  82.                     } else {
  83.                         tooltip.addPara("%s " + weaponSpec.getDerivedStats().getDps() + "x" + weaponNum + "x" + fighterNum + "=" + weaponSpec.getDerivedStats().getDps() * weaponNum * fighterNum, pad * 0.5f, DAMAGE_COLOR, i18n.format("bbs") + ":");
  84.  
  85.                     }
  86.                 }
  87.             }
  88.         }
  89.     }
  90. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement