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.Stats; 008 009public class FragileSubsystems extends BaseHullMod { 010 011 public static final float PEAK_PENALTY_PERCENT = 30f; 012 public static final float DEGRADE_INCREASE_PERCENT = 30f; 013 014 015 public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id) { 016 float effect = stats.getDynamic().getValue(Stats.DMOD_EFFECT_MULT); 017 018 stats.getPeakCRDuration().modifyMult(id, 1f - (PEAK_PENALTY_PERCENT * effect) / 100f); 019 stats.getCRLossPerSecondPercent().modifyPercent(id, DEGRADE_INCREASE_PERCENT * effect); 020 CompromisedStructure.modifyCost(hullSize, stats, id); 021 } 022 023 public String getDescriptionParam(int index, HullSize hullSize, ShipAPI ship) { 024 float effect = 1f; 025 if (ship != null) effect = ship.getMutableStats().getDynamic().getValue(Stats.DMOD_EFFECT_MULT); 026 027 if (index == 0) return "" + (int) Math.round(PEAK_PENALTY_PERCENT * effect) + "%"; 028 if (index == 1) return "" + (int) Math.round(DEGRADE_INCREASE_PERCENT * effect) + "%"; 029 if (index >= 2) return CompromisedStructure.getCostDescParam(index, 2); 030 return null; 031 } 032 033 public boolean isApplicableToShip(ShipAPI ship) { 034 return ship != null && (ship.getHullSpec().getNoCRLossTime() < 10000 || ship.getHullSpec().getCRLossPerSecond(ship.getMutableStats()) > 0); 035 } 036 037 public String getUnapplicableReason(ShipAPI ship) { 038 return "Ship does not suffer from CR degradation"; 039 } 040} 041 042 043 044