001package com.fs.starfarer.api.combat;
002
003import java.awt.Color;
004
005import com.fs.starfarer.api.campaign.CampaignUIAPI.CoreUITradeMode;
006import com.fs.starfarer.api.campaign.CargoStackAPI;
007import com.fs.starfarer.api.campaign.econ.MarketAPI;
008import com.fs.starfarer.api.combat.ShipAPI.HullSize;
009import com.fs.starfarer.api.fleet.FleetMemberAPI;
010import com.fs.starfarer.api.loading.HullModSpecAPI;
011import com.fs.starfarer.api.ui.TooltipMakerAPI;
012
013/**
014 * Note: the effect class is instantiated once per application session.
015 * Storing campaign data in data members of an implementing class is a bad idea (will likely cause memory leaks),
016 * use SectorAPI.getPersistentData() instead.
017 * @author Alex Mosolov
018 *
019 * Copyright 2015 Fractal Softworks, LLC
020 */
021public interface HullModEffect {
022        void init(HullModSpecAPI spec);
023        void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id);
024        
025        /**
026         * Effects applied here should NOT affect ship stats as this does not get called from the campaign.
027         * Apply stat changes in applyEffectsBeforeShipCreation() instead, as that does affect the campaign.
028         * @param ship
029         * @param id
030         */
031        void applyEffectsAfterShipCreation(ShipAPI ship, String id);
032        String getDescriptionParam(int index, HullSize hullSize);
033        String getDescriptionParam(int index, HullSize hullSize, ShipAPI ship);
034
035        void applyEffectsToFighterSpawnedByShip(ShipAPI fighter, ShipAPI ship, String id);
036        
037        boolean isApplicableToShip(ShipAPI ship);
038        
039        String getUnapplicableReason(ShipAPI ship);
040        
041        /**
042         * Ship may be null from autofit.
043         * @param ship
044         * @param marketOrNull
045         * @param mode
046         * @return
047         */
048        boolean canBeAddedOrRemovedNow(ShipAPI ship, MarketAPI marketOrNull, CoreUITradeMode mode);
049        String getCanNotBeInstalledNowReason(ShipAPI ship, MarketAPI marketOrNull, CoreUITradeMode mode);
050        
051        
052        /**
053         * Not called while paused.
054         * But, called when the fleet data needs to be re-synced,
055         * with amount=0 (such as if, say, a fleet member is moved around.
056         * in the fleet screen.)
057         * @param member
058         * @param amount
059         */
060        void advanceInCampaign(FleetMemberAPI member, float amount);
061        
062        /**
063         * Not called while paused.
064         * @param ship
065         * @param amount
066         */
067        void advanceInCombat(ShipAPI ship, float amount);
068        
069        /**
070         * Hullmods that return true here should only ever be built-in, as cost changes aren't handled when
071         * these mods can be added or removed to/from the variant.
072         * @return
073         */
074        boolean affectsOPCosts();
075        
076        
077        /**
078         * ship may be null, will be for modspecs. hullsize will always be CAPITAL_SHIP for modspecs.
079         * @param hullSize
080         * @param ship
081         * @param isForModSpec
082         * @return
083         */
084        boolean shouldAddDescriptionToTooltip(HullSize hullSize, ShipAPI ship, boolean isForModSpec);
085        
086        /**
087         * ship may be null, will be for modspecs. hullsize will always be CAPITAL_SHIP for modspecs.
088         * @param tooltip
089         * @param hullSize
090         * @param ship
091         * @param width
092         * @param isForModSpec
093         */
094        void addPostDescriptionSection(TooltipMakerAPI tooltip, HullSize hullSize, ShipAPI ship, float width, boolean isForModSpec);
095        
096
097        Color getBorderColor();
098        Color getNameColor();
099        
100        /**
101         * Sort order within the mod's display category. Not used when category == 4, since then
102         * the order is determined by the order in which the player added the hullmods.
103         * @return
104         */
105        int getDisplaySortOrder();
106        /**
107         * Should return 0 to 4; -1 for "use default".
108         * The default categories are:
109         *      0: built-in mods in the base hull
110         *      1: perma-mods that are not story point mods
111         *      2: d-mods
112         *      3: mods built in via story points
113         *      4: regular mods
114         * 
115         * @return
116         */
117        int getDisplayCategoryIndex();
118        
119        boolean hasSModEffectSection(HullSize hullSize, ShipAPI ship, boolean isForModSpec);
120        void addSModSection(TooltipMakerAPI tooltip, HullSize hullSize, ShipAPI ship, float width, boolean isForModSpec, boolean isForBuildInList);
121        void addSModEffectSection(TooltipMakerAPI tooltip, HullSize hullSize, ShipAPI ship, float width,
122                        boolean isForModSpec, boolean isForBuildInList);
123        boolean hasSModEffect();
124        
125        
126        void addRequiredItemSection(TooltipMakerAPI tooltip, 
127                        FleetMemberAPI member, ShipVariantAPI currentVariant, MarketAPI dockedAt,
128                        float width, boolean isForModSpec);
129        
130        String getSModDescriptionParam(int index, HullSize hullSize);
131        String getSModDescriptionParam(int index, HullSize hullSize, ShipAPI ship);
132        
133        float getTooltipWidth();
134        boolean isSModEffectAPenalty();
135        
136        boolean showInRefitScreenModPickerFor(ShipAPI ship);
137
138        
139        default CargoStackAPI getRequiredItem() {
140                return null;
141        }
142        
143        /**
144         * Only called once. Not called again if the ship is removed and then added back to the engine.
145         */
146        default void applyEffectsAfterShipAddedToCombatEngine(ShipAPI ship, String id) {
147        }
148}
149
150
151
152
153
154
155
156
157
158