Class BaseToggleAbility
java.lang.Object
com.fs.starfarer.api.impl.campaign.abilities.BaseAbilityPlugin
com.fs.starfarer.api.impl.campaign.abilities.BaseToggleAbility
- All Implemented Interfaces:
AbilityPlugin
,EveryFrameScript
- Direct Known Subclasses:
GoDarkAbility
,GraviticScanAbility
,SustainedBurnAbility
,ToggleAbilityWithCost
,TransponderAbility
Ability that can be toggled on and off.
(Why use methods to pass in sound ids etc instead of passing them in to a constructor?
Mainly so they don't need to go into the save file as they would if they were
stored in member variables.)
- Author:
- Alex Mosolov Copyright 2015 Fractal Softworks, LLC
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected float
protected boolean
protected float
protected boolean
Fields inherited from class com.fs.starfarer.api.impl.campaign.abilities.BaseAbilityPlugin
disableFrames, entity, id, PLAY_UI_SOUNDS_IN_WORLD_SOURCES, spec
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
activate()
Programmatic way to activate the ability.protected abstract void
protected void
addIncompatibleToTooltip
(TooltipMakerAPI tooltip, boolean expanded) void
advance
(float amount) Use SectorAPI.getClock() to convert to campaign days.protected abstract void
applyEffect
(float amount, float level) Will be called once when level is 0 and consistently when level >0.void
cleanup()
After this method is called, it should be possible to remove the ability from the entity without any after-effects.protected abstract void
void
Toggleable or interruptable abilities should implement this method so that other abilities may turn them off or interrupt them if needed.protected abstract void
float
float
float
0 at start of cooldown, 1 at end.float
float
float
float
getLevel()
float
float
float
float
float
0 at start of progress, 1 at end.boolean
boolean
isActive()
Whether a toggle-style ability is turned on.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.boolean
void
setCooldownLeft
(float cooldownLeft) boolean
boolean
Methods inherited from class com.fs.starfarer.api.impl.campaign.abilities.BaseAbilityPlugin
addIncompatibleToTooltip, createTooltip, disableIncompatible, fleetJoinedBattle, fleetLeftBattle, fleetOpenedMarket, forceDisable, getActivationText, getActiveColor, getActiveLayers, getCooldownColor, getDeactivationText, getEntity, getFleet, getId, getInterruptedList, getLoopSoundUI, getLoopSoundWorld, getModId, getOffSoundUI, getOffSoundWorld, getOnSoundUI, getOnSoundWorld, getProgressColor, getSpec, getSpriteName, getTooltipWidth, hasTooltip, init, interruptIncompatible, isActiveOrInProgress, isCompatible, isCooldownRenderingAdditive, isDone, isInProgress, isOnCooldown, isTooltipExpandable, readResolve, render, showCooldownIndicator
-
Field Details
-
turnedOn
protected boolean turnedOn -
cooldownLeft
protected float cooldownLeft -
isActivateCooldown
protected boolean isActivateCooldown -
level
protected float level
-
-
Constructor Details
-
BaseToggleAbility
public BaseToggleAbility()
-
-
Method Details
-
getLoopSoundUIVolume
public float getLoopSoundUIVolume()- Overrides:
getLoopSoundUIVolume
in classBaseAbilityPlugin
-
getLoopSoundUIPitch
public float getLoopSoundUIPitch()- Overrides:
getLoopSoundUIPitch
in classBaseAbilityPlugin
-
getLoopSoundWorldVolume
public float getLoopSoundWorldVolume()- Overrides:
getLoopSoundWorldVolume
in classBaseAbilityPlugin
-
getLoopSoundWorldPitch
public float getLoopSoundWorldPitch()- Overrides:
getLoopSoundWorldPitch
in classBaseAbilityPlugin
-
getActivateCooldownDays
public float getActivateCooldownDays() -
getDeactivateCooldownDays
public float getDeactivateCooldownDays() -
getActivationDays
public float getActivationDays() -
getDeactivationDays
public float getDeactivationDays() -
activateImpl
protected abstract void activateImpl() -
applyEffect
protected abstract void applyEffect(float amount, float level) Will be called once when level is 0 and consistently when level >0.- Parameters:
level
-
-
deactivateImpl
protected abstract void deactivateImpl() -
cleanupImpl
protected abstract void cleanupImpl() -
getCooldownLeft
public float getCooldownLeft()- Specified by:
getCooldownLeft
in interfaceAbilityPlugin
- Specified by:
getCooldownLeft
in classBaseAbilityPlugin
-
setCooldownLeft
public void setCooldownLeft(float cooldownLeft) - Specified by:
setCooldownLeft
in interfaceAbilityPlugin
- Specified by:
setCooldownLeft
in classBaseAbilityPlugin
-
advance
public void advance(float amount) Description copied from interface:EveryFrameScript
Use SectorAPI.getClock() to convert to campaign days.- Specified by:
advance
in interfaceEveryFrameScript
- Overrides:
advance
in classBaseAbilityPlugin
- Parameters:
amount
- seconds elapsed during the last frame.
-
addIncompatibleToTooltip
-
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
- Overrides:
isUsable
in classBaseAbilityPlugin
- Returns:
-
getCooldownFraction
public float getCooldownFraction()Description copied from interface:AbilityPlugin
0 at start of cooldown, 1 at end.- Specified by:
getCooldownFraction
in interfaceAbilityPlugin
- Overrides:
getCooldownFraction
in classBaseAbilityPlugin
- Returns:
-
getProgressFraction
public float getProgressFraction()Description copied from interface:AbilityPlugin
0 at start of progress, 1 at end.- Specified by:
getProgressFraction
in interfaceAbilityPlugin
- Overrides:
getProgressFraction
in classBaseAbilityPlugin
- Returns:
-
showProgressIndicator
public boolean showProgressIndicator()- Specified by:
showProgressIndicator
in interfaceAbilityPlugin
- Overrides:
showProgressIndicator
in classBaseAbilityPlugin
-
showActiveIndicator
public boolean showActiveIndicator()- Specified by:
showActiveIndicator
in interfaceAbilityPlugin
- Overrides:
showActiveIndicator
in classBaseAbilityPlugin
-
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
- Overrides:
pressButton
in classBaseAbilityPlugin
-
activate
public void activate()Description copied from interface:AbilityPlugin
Programmatic way to activate the ability. Expected behavior: if (!isActiveOrInProgress()) {} - Specified by:
activate
in interfaceAbilityPlugin
- Overrides:
activate
in classBaseAbilityPlugin
-
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
- Overrides:
deactivate
in classBaseAbilityPlugin
-
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
- Overrides:
cleanup
in classBaseAbilityPlugin
-
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
- Overrides:
isActive
in classBaseAbilityPlugin
- Returns:
-
hasCustomButtonPressSounds
public boolean hasCustomButtonPressSounds()- Specified by:
hasCustomButtonPressSounds
in interfaceAbilityPlugin
- Overrides:
hasCustomButtonPressSounds
in classBaseAbilityPlugin
-
runWhilePaused
public boolean runWhilePaused()- Specified by:
runWhilePaused
in interfaceEveryFrameScript
- Overrides:
runWhilePaused
in classBaseAbilityPlugin
- Returns:
- whether advance() should be called while the campaign engine is paused.
-
getLevel
public float getLevel()- Specified by:
getLevel
in interfaceAbilityPlugin
- Overrides:
getLevel
in classBaseAbilityPlugin
-