Class BaseAbilityPlugin
java.lang.Object
com.fs.starfarer.api.impl.campaign.abilities.BaseAbilityPlugin
- All Implemented Interfaces:
AbilityPlugin
,EveryFrameScript
- Direct Known Subclasses:
BaseDurationAbility
,BaseToggleAbility
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected int
protected SectorEntityToken
protected String
static boolean
protected AbilitySpecAPI
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
activate()
Programmatic way to activate the ability.protected void
addIncompatibleToTooltip
(TooltipMakerAPI tooltip, String desc, String descShort, boolean expanded) void
advance
(float amount) Use SectorAPI.getClock() to convert to campaign days.void
cleanup()
After this method is called, it should be possible to remove the ability from the entity without any after-effects.void
createTooltip
(TooltipMakerAPI tooltip, boolean expanded) Will be called every frame the tooltip is shown, so the tooltip can be dynamic.void
Toggleable or interruptable abilities should implement this method so that other abilities may turn them off or interrupt them if needed.protected void
void
fleetJoinedBattle
(BattleAPI battle) void
fleetLeftBattle
(BattleAPI battle, boolean engagedInHostilities) void
fleetOpenedMarket
(MarketAPI market) Only called for the player fleet.void
Make this ability unusable for 1-2 frames after this call.protected String
float
0 at start of cooldown, 1 at end.abstract float
protected String
getFleet()
getId()
float
getLevel()
float
float
float
float
getModId()
float
0 at start of progress, 1 at end.getSpec()
float
boolean
boolean
void
init
(String id, SectorEntityToken entity) protected void
boolean
isActive()
Whether a toggle-style ability is turned on.boolean
Should return (isActive() || getProgressFraction() > 0).boolean
isCompatible
(AbilityPlugin other) boolean
boolean
isDone()
boolean
boolean
boolean
boolean
isUsable()
Whether the ability can be activated / the UI button corresponding to it is enabled.void
Called from the UI when the button for this ability is pressed.protected Object
void
render
(CampaignEngineLayers layer, ViewportAPI viewport) boolean
abstract void
setCooldownLeft
(float days) boolean
boolean
boolean
-
Field Details
-
PLAY_UI_SOUNDS_IN_WORLD_SOURCES
public static boolean PLAY_UI_SOUNDS_IN_WORLD_SOURCES -
entity
-
id
-
disableFrames
protected int disableFrames -
spec
-
-
Constructor Details
-
BaseAbilityPlugin
public BaseAbilityPlugin()
-
-
Method Details
-
init
- Specified by:
init
in interfaceAbilityPlugin
-
readResolve
-
getOnSoundUI
-
getOnSoundWorld
-
getOffSoundUI
-
getOffSoundWorld
-
getLoopSoundUI
-
getLoopSoundUIVolume
public float getLoopSoundUIVolume() -
getLoopSoundUIPitch
public float getLoopSoundUIPitch() -
getLoopSoundWorld
-
getLoopSoundWorldVolume
public float getLoopSoundWorldVolume() -
getLoopSoundWorldPitch
public float getLoopSoundWorldPitch() -
interruptIncompatible
protected void interruptIncompatible() -
disableIncompatible
protected void disableIncompatible() -
isCompatible
-
addIncompatibleToTooltip
protected void addIncompatibleToTooltip(TooltipMakerAPI tooltip, String desc, String descShort, boolean expanded) -
getInterruptedList
-
getModId
-
getFleet
-
getEntity
- Specified by:
getEntity
in interfaceAbilityPlugin
-
getId
- Specified by:
getId
in interfaceAbilityPlugin
-
advance
public void advance(float amount) Description copied from interface:EveryFrameScript
Use SectorAPI.getClock() to convert to campaign days.- Specified by:
advance
in interfaceEveryFrameScript
- Parameters:
amount
- seconds elapsed during the last frame.
-
isDone
public boolean isDone()- Specified by:
isDone
in interfaceEveryFrameScript
- Returns:
- true when the script is finished and can be cleaned up by the engine.
-
runWhilePaused
public boolean runWhilePaused()- Specified by:
runWhilePaused
in interfaceEveryFrameScript
- Returns:
- whether advance() should be called while the campaign engine is paused.
-
showActiveIndicator
public boolean showActiveIndicator()- Specified by:
showActiveIndicator
in interfaceAbilityPlugin
-
isUsable
public boolean isUsable()Description copied from interface:AbilityPlugin
Whether the ability can be activated / the UI button corresponding to it is enabled.- Specified by:
isUsable
in interfaceAbilityPlugin
- Returns:
-
forceDisable
public void forceDisable()Description copied from interface:AbilityPlugin
Make this ability unusable for 1-2 frames after this call.- Specified by:
forceDisable
in interfaceAbilityPlugin
-
getCooldownFraction
public float getCooldownFraction()Description copied from interface:AbilityPlugin
0 at start of cooldown, 1 at end.- Specified by:
getCooldownFraction
in interfaceAbilityPlugin
- Returns:
-
hasCustomButtonPressSounds
public boolean hasCustomButtonPressSounds()- Specified by:
hasCustomButtonPressSounds
in interfaceAbilityPlugin
-
hasTooltip
public boolean hasTooltip()- Specified by:
hasTooltip
in interfaceAbilityPlugin
-
createTooltip
Description copied from interface:AbilityPlugin
Will be called every frame the tooltip is shown, so the tooltip can be dynamic.- Specified by:
createTooltip
in interfaceAbilityPlugin
-
isTooltipExpandable
public boolean isTooltipExpandable()- Specified by:
isTooltipExpandable
in interfaceAbilityPlugin
-
getTooltipWidth
public float getTooltipWidth()- Specified by:
getTooltipWidth
in interfaceAbilityPlugin
-
pressButton
public void pressButton()Description copied from interface:AbilityPlugin
Called from the UI when the button for this ability is pressed. Should not be called by the AI for other ability-using fleets, for example.- Specified by:
pressButton
in interfaceAbilityPlugin
-
getSpriteName
- Specified by:
getSpriteName
in interfaceAbilityPlugin
-
activate
public void activate()Description copied from interface:AbilityPlugin
Programmatic way to activate the ability. Expected behavior: if (!isActiveOrInProgress()) {} - Specified by:
activate
in interfaceAbilityPlugin
-
deactivate
public void deactivate()Description copied from interface:AbilityPlugin
Toggleable or interruptable abilities should implement this method so that other abilities may turn them off or interrupt them if needed. Expected behavior: if (isActiveOrInProgress()) {} - Specified by:
deactivate
in interfaceAbilityPlugin
-
getCooldownColor
- Specified by:
getCooldownColor
in interfaceAbilityPlugin
-
getProgressColor
- Specified by:
getProgressColor
in interfaceAbilityPlugin
-
getActiveColor
- Specified by:
getActiveColor
in interfaceAbilityPlugin
-
getProgressFraction
public float getProgressFraction()Description copied from interface:AbilityPlugin
0 at start of progress, 1 at end.- Specified by:
getProgressFraction
in interfaceAbilityPlugin
- Returns:
-
isActive
public boolean isActive()Description copied from interface:AbilityPlugin
Whether a toggle-style ability is turned on. Duration abilities will always return false here; use isInProgress() to get their status.- Specified by:
isActive
in interfaceAbilityPlugin
- Returns:
-
isActiveOrInProgress
public boolean isActiveOrInProgress()Description copied from interface:AbilityPlugin
Should return (isActive() || getProgressFraction() > 0).- Specified by:
isActiveOrInProgress
in interfaceAbilityPlugin
- Returns:
-
isInProgress
public boolean isInProgress()- Specified by:
isInProgress
in interfaceAbilityPlugin
-
showCooldownIndicator
public boolean showCooldownIndicator()- Specified by:
showCooldownIndicator
in interfaceAbilityPlugin
-
showProgressIndicator
public boolean showProgressIndicator()- Specified by:
showProgressIndicator
in interfaceAbilityPlugin
-
isOnCooldown
public boolean isOnCooldown()- Specified by:
isOnCooldown
in interfaceAbilityPlugin
-
cleanup
public void cleanup()Description copied from interface:AbilityPlugin
After this method is called, it should be possible to remove the ability from the entity without any after-effects.- Specified by:
cleanup
in interfaceAbilityPlugin
-
isCooldownRenderingAdditive
public boolean isCooldownRenderingAdditive()- Specified by:
isCooldownRenderingAdditive
in interfaceAbilityPlugin
-
setCooldownLeft
public abstract void setCooldownLeft(float days) - Specified by:
setCooldownLeft
in interfaceAbilityPlugin
-
getCooldownLeft
public abstract float getCooldownLeft()- Specified by:
getCooldownLeft
in interfaceAbilityPlugin
-
getActivationText
-
getDeactivationText
-
fleetJoinedBattle
- Specified by:
fleetJoinedBattle
in interfaceAbilityPlugin
-
fleetLeftBattle
- Specified by:
fleetLeftBattle
in interfaceAbilityPlugin
-
fleetOpenedMarket
Description copied from interface:AbilityPlugin
Only called for the player fleet.- Specified by:
fleetOpenedMarket
in interfaceAbilityPlugin
-
getSpec
- Specified by:
getSpec
in interfaceAbilityPlugin
-
getActiveLayers
- Specified by:
getActiveLayers
in interfaceAbilityPlugin
-
render
- Specified by:
render
in interfaceAbilityPlugin
-
getLevel
public float getLevel()- Specified by:
getLevel
in interfaceAbilityPlugin
-