001/**
002 * 
003 */
004package com.fs.starfarer.api.characters;
005
006import java.awt.Color;
007import java.util.EnumSet;
008
009import com.fs.starfarer.api.campaign.BattleAPI;
010import com.fs.starfarer.api.campaign.CampaignEngineLayers;
011import com.fs.starfarer.api.campaign.SectorEntityToken;
012import com.fs.starfarer.api.campaign.econ.MarketAPI;
013import com.fs.starfarer.api.combat.ViewportAPI;
014import com.fs.starfarer.api.loading.AbilitySpecAPI;
015import com.fs.starfarer.api.ui.TooltipMakerAPI;
016
017
018public interface AbilityPlugin {
019        void init(String id, SectorEntityToken entity);
020        
021        /**
022         * Called from the UI when the button for this ability is pressed. Should not be called by the AI for
023         * other ability-using fleets, for example.
024         */
025        void pressButton();
026        
027        
028        /**
029         * Programmatic way to activate the ability.
030         * 
031         * Expected behavior:
032         * if (!isActiveOrInProgress()) {
033         *   <activate ability>
034         * }
035         */
036        void activate();
037        
038        /**
039         * Toggleable or interruptable abilities should implement this method so
040         * that other abilities may turn them off or interrupt them if needed.
041         * 
042         * Expected behavior:
043         * if (isActiveOrInProgress()) {
044         *   <deactivate ability>
045         * }
046         * 
047         */
048        void deactivate();
049        
050        
051        /**
052         * After this method is called, it should be possible to remove the ability
053         * from the entity without any after-effects. 
054         */
055        void cleanup();
056        
057        
058        boolean showActiveIndicator();
059        boolean showProgressIndicator();
060        boolean showCooldownIndicator();
061        
062        /**
063         * Whether the ability can be activated / the UI button corresponding to it is enabled.
064         * @return
065         */
066        boolean isUsable();
067        
068        /**
069         * Whether a toggle-style ability is turned on. Duration abilities will always return false here;
070         * use isInProgress() to get their status.
071         * @return
072         */
073        boolean isActive();
074        
075        
076        boolean isInProgress();
077        boolean isOnCooldown();
078        
079        /**
080         * Should return (isActive() || getProgressFraction() > 0).
081         * @return
082         */
083        boolean isActiveOrInProgress();
084        
085        /**
086         * 0 at start of cooldown, 1 at end.
087         * @return
088         */
089        float getCooldownFraction();
090        
091        /**
092         * 0 at start of progress, 1 at end.
093         * @return
094         */
095        float getProgressFraction();
096        
097        Color getProgressColor();
098        Color getActiveColor();
099        Color getCooldownColor();
100        
101        boolean isCooldownRenderingAdditive();
102        
103        boolean hasCustomButtonPressSounds();
104        
105        String getSpriteName();
106        SectorEntityToken getEntity();
107        String getId();
108        
109        
110        /**
111         * Will be called every frame the tooltip is shown, so the tooltip can be dynamic.
112         * @param tooltip
113         * @param expanded 
114         */
115        void createTooltip(TooltipMakerAPI tooltip, boolean expanded);
116        boolean hasTooltip();
117        boolean isTooltipExpandable();
118        float getTooltipWidth();
119
120        
121        
122        /**
123         * Make this ability unusable for 1-2 frames after this call.
124         */
125        void forceDisable();
126        
127        
128        void fleetJoinedBattle(BattleAPI battle);
129        void fleetLeftBattle(BattleAPI battle, boolean engagedInHostilities);
130        
131        /**
132         * Only called for the player fleet.
133         * @param market
134         */
135        void fleetOpenedMarket(MarketAPI market);
136
137        AbilitySpecAPI getSpec();
138        
139        
140        void render(CampaignEngineLayers layer, ViewportAPI viewport);
141        EnumSet<CampaignEngineLayers> getActiveLayers();
142
143        void setCooldownLeft(float days);
144
145        float getCooldownLeft();
146
147        float getLevel();
148        
149        
150}
151
152