Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package data.scripts.utils;
- import com.fs.starfarer.api.Global;
- import com.fs.starfarer.api.combat.BaseHullMod;
- import com.fs.starfarer.api.combat.ShipAPI;
- import com.fs.starfarer.api.combat.WeaponAPI;
- import com.fs.starfarer.api.loading.FighterWingSpecAPI;
- import com.fs.starfarer.api.loading.WeaponSpecAPI;
- import com.fs.starfarer.api.ui.TooltipMakerAPI;
- import com.fs.starfarer.api.util.Misc;
- import data.scripts.utils.fobs.StringLib;
- import java.awt.*;
- import java.util.ArrayList;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Map;
- public class FighterDevChecker extends BaseHullMod {
- private static final Color DAMAGE_COLOR = new Color(255, 220, 100);
- private static final Color WEAPON_NAME_COLOR = new Color(100, 220, 200);
- private static final StringLib.I18nSection i18n = new StringLib.I18nSection("hullMod", "fdc", true);
- @Override
- public void addPostDescriptionSection(TooltipMakerAPI tooltip, ShipAPI.HullSize hullSize, ShipAPI ship, float width, boolean isForModSpec) {
- if (ship == null) return;
- if (isForModSpec) return;
- float pad = 10f;
- List<FighterWingSpecAPI> wingSpecs = new ArrayList<>();
- for (String wingId : ship.getVariant().getWings()) {
- FighterWingSpecAPI spec = Global.getSettings().getFighterWingSpec(wingId);
- if (spec != null && !wingSpecs.contains(spec)) {
- wingSpecs.add(spec);
- }
- }
- for (FighterWingSpecAPI spec : wingSpecs) {
- int fighterNum = spec.getNumFighters();
- tooltip.setParaOrbitronLarge();
- tooltip.addPara(spec.getWingName(), Misc.getHighlightColor(), pad);
- tooltip.setParaFontDefault();
- tooltip.addPara("Number:" + fighterNum, Misc.getHighlightColor(), 0f);
- Map<WeaponSpecAPI, Integer> weaponSpecToAmountMap = new HashMap<>();
- for (String slotId : spec.getVariant().getFittedWeaponSlots()) {
- WeaponSpecAPI weaponSpec = spec.getVariant().getWeaponSpec(slotId);
- if (spec.getVariant().getSlot(slotId).isDecorative()) continue;
- if (!weaponSpecToAmountMap.containsKey(weaponSpec)) {
- weaponSpecToAmountMap.put(weaponSpec, 1);
- } else {
- weaponSpecToAmountMap.put(weaponSpec, weaponSpecToAmountMap.get(weaponSpec) + 1);
- }
- }
- for (Map.Entry<WeaponSpecAPI, Integer> entry : weaponSpecToAmountMap.entrySet()) {
- WeaponSpecAPI weaponSpec = entry.getKey();
- int weaponNum = entry.getValue();
- tooltip.addPara(weaponSpec.getWeaponName() + " x " + weaponNum, WEAPON_NAME_COLOR, pad);
- List<String> description = new ArrayList<>();
- description.add(i18n.format("wt") + ":" + weaponSpec.getType().getDisplayName());
- description.add(i18n.format("dt") + ":" + weaponSpec.getDamageType().getDisplayName());
- description.add("DPS:" + weaponSpec.getDerivedStats().getDps());
- description.add("FPS:" + weaponSpec.getDerivedStats().getFluxPerSecond());
- float dph = weaponSpec.getDerivedStats().getDamagePerShot();
- description.add("DPH:" + dph);
- description.add("FPH:" + weaponSpec.getDerivedStats().getFluxPerDam() * weaponSpec.getDerivedStats().getDamagePerShot());
- int burstSize = weaponSpec.getBurstSize();
- description.add("BurstSize:" + burstSize);
- if (weaponSpec.usesAmmo()) {
- description.add(i18n.format("ammo") + ":" + weaponSpec.getMaxAmmo());
- description.add(i18n.format("ammog") + ":" + weaponSpec.getAmmoPerSecond());
- }
- tooltip.addPara(Misc.getAndJoined(description), 0f);
- tooltip.addPara(i18n.format("wwi"), Misc.getGrayColor(), pad);
- if (!weaponSpec.isBeam()) {
- tooltip.addPara("%s " + (int) dph + "x" + burstSize + "x" + weaponNum + "x" + fighterNum + "=" + dph * burstSize * weaponNum * fighterNum, pad * 0.5f, DAMAGE_COLOR, i18n.format("dpr") + ":");
- if (weaponSpec.getType() == WeaponAPI.WeaponType.MISSILE) {
- tooltip.addPara(i18n.format("dprw"), Misc.getGrayColor(), 0f);
- }
- } else {
- if (weaponSpec.getDerivedStats().getBurstDamage() > 0) {
- tooltip.addPara("%s " + weaponSpec.getDerivedStats().getBurstDamage() + "x" + weaponNum + "x" + fighterNum + "=" + weaponSpec.getDerivedStats().getBurstDamage() * weaponNum * fighterNum, pad * 0.5f, DAMAGE_COLOR, i18n.format("bbd") + ":");
- } else {
- tooltip.addPara("%s " + weaponSpec.getDerivedStats().getDps() + "x" + weaponNum + "x" + fighterNum + "=" + weaponSpec.getDerivedStats().getDps() * weaponNum * fighterNum, pad * 0.5f, DAMAGE_COLOR, i18n.format("bbs") + ":");
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement