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.ShieldAPI.ShieldType;
006import com.fs.starfarer.api.combat.ShipAPI;
007import com.fs.starfarer.api.combat.ShipAPI.HullSize;
008import com.fs.starfarer.api.impl.campaign.ids.HullMods;
009
010public class ShieldShunt extends BaseHullMod {
011
012        //public static float EMP_RESISTANCE = 50f;
013        //public static float VENT_RATE_BONUS = 50f;
014        public static float ARMOR_BONUS = 15f;
015        public static float SMOD_ARMOR_BONUS = 15f;
016        
017        
018        public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id) {
019                boolean sMod = isSMod(stats);
020                
021                //stats.getVentRateMult().modifyPercent(id, VENT_RATE_BONUS);
022                stats.getArmorBonus().modifyPercent(id, ARMOR_BONUS + (sMod ? SMOD_ARMOR_BONUS : 0));
023                //stats.getEmpDamageTakenMult().modifyMult(id, 1f - EMP_RESISTANCE * 0.01f);
024        }
025        
026        @Override
027        public void applyEffectsAfterShipCreation(ShipAPI ship, String id) {
028                ship.setShield(ShieldType.NONE, 0f, 1f, 1f);
029        }
030
031
032        public String getDescriptionParam(int index, HullSize hullSize) {
033                //if (index == 0) return "" + (int) EMP_RESISTANCE + "%";
034                //if (index == 0) return "" + (int) VENT_RATE_BONUS + "%";
035                if (index == 0) return "" + (int) ARMOR_BONUS + "%";
036                return null;
037        }
038
039        public boolean isApplicableToShip(ShipAPI ship) {
040                if (ship.getVariant().getHullSpec().getShieldType() == ShieldType.NONE && 
041                                !ship.getVariant().hasHullMod("frontshield")) return false;
042                if (ship.getVariant().hasHullMod(HullMods.SHIELD_SHUNT)) return true;
043                if (ship.getVariant().hasHullMod(HullMods.MAKESHIFT_GENERATOR)) return false;
044                return ship != null && ship.getShield() != null;
045        }
046        
047        public String getUnapplicableReason(ShipAPI ship) {
048                if (ship.getVariant().hasHullMod(HullMods.MAKESHIFT_GENERATOR)) {
049                        return "Incompatible with Makeshift Shield Generator";
050                }
051                return "Ship has no shields";
052        }
053        
054        public String getSModDescriptionParam(int index, HullSize hullSize) {
055                if (index == 0) return "" + (int) SMOD_ARMOR_BONUS + "%";
056                return null;
057        }
058        
059        public boolean hasSModEffect() {
060                // breaks something if it can be built in - I think something to do with preconditions for
061                // shield-related hullmods; not 100% sure on details but sure there was a problem -am
062                // Ah! The issue was being able to build it in and then some kind of order-of-operations with
063                // Makeshift Shield Generator. Made those incompatible. -am
064                return true;
065        }
066        
067}
068
069
070
071
072
073
074
075
076