001package com.fs.starfarer.api.impl.hullmods; 002 003import com.fs.starfarer.api.combat.BaseHullMod; 004import com.fs.starfarer.api.combat.MutableShipStatsAPI; 005import com.fs.starfarer.api.combat.ShipAPI; 006import com.fs.starfarer.api.combat.ShipAPI.HullSize; 007import com.fs.starfarer.api.impl.campaign.ids.HullMods; 008import com.fs.starfarer.api.impl.campaign.ids.Stats; 009import com.fs.starfarer.api.util.Misc; 010 011public class RecoveryShuttles extends BaseHullMod { 012 013 public static float CREW_LOSS_MULT = 0.25f; 014 015 public static float SMOD_CREW_LOSS_MULT = 0.05f; 016 017 018 public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id) { 019 boolean sMod = isSMod(stats); 020 float mult = CREW_LOSS_MULT; 021 if (sMod) mult = SMOD_CREW_LOSS_MULT; 022 stats.getDynamic().getStat(Stats.FIGHTER_CREW_LOSS_MULT).modifyMult(id, mult); 023 } 024 025 public String getSModDescriptionParam(int index, HullSize hullSize) { 026 if (index == 0) return "" + (int) ((1f - SMOD_CREW_LOSS_MULT) * 100f) + "%"; 027 return null; 028 } 029 public String getDescriptionParam(int index, HullSize hullSize) { 030 if (index == 0) return "" + (int) ((1f - CREW_LOSS_MULT) * 100f) + "%"; 031 return null; 032 } 033 034 public boolean isApplicableToShip(ShipAPI ship) { 035 if (Misc.isAutomated(ship.getVariant())) return false; 036 037 if (ship.getVariant().hasHullMod(HullMods.CONVERTED_HANGAR)) return true; 038 039 //int bays = (int) ship.getMutableStats().getNumFighterBays().getBaseValue(); 040 int bays = (int) ship.getMutableStats().getNumFighterBays().getModifiedValue(); 041// if (ship != null && ship.getVariant().getHullSpec().getBuiltInWings().size() >= bays) { 042// return false; 043// } 044 return ship != null && bays > 0; 045 } 046 047 public String getUnapplicableReason(ShipAPI ship) { 048 if (ship != null && Misc.isAutomated(ship.getVariant())) { 049 return "Can not be installed on automated ships"; 050 } 051 return "Ship does not have fighter bays"; 052 } 053} 054 055 056 057