MagicAchievementManager

Manages and tracks achievements.

An achievement is made from a spec, which is used to create the achievement class with the code to detect the achievement conditions.

To add an achievement, add it to the magic_achievements.csv file in your mod's data/config folder. Alternatively, call addAchievementSpecs in your mod plugin's onGameLoad() method.

Then, create a class that extends MagicAchievement and implement the detection logic. You will need to call setComplete() and then saveChanges() to complete the achievement.

Constructors

Link copied to clipboard
constructor()

Functions

Link copied to clipboard
Use this to create achievements that are not defined in magic_achievements.csv.
Link copied to clipboard
open fun afterGameSave()
Calls all achievements' afterGameSave() method.
Link copied to clipboard
Link copied to clipboard
open fun beforeGameSave()
Calls all achievements' beforeGameSave() method.
Link copied to clipboard
open fun completeAchievement(achievementClass: Class<out MagicAchievement>)
open fun completeAchievement(specId: String)
Link copied to clipboard
open fun generateAchievementsFromSpec(specs: Map<String, MagicAchievementSpec>): Map<String, MagicAchievement>
Creates achievements from the given specs, creates the script instances from the class name, and returns them.
Link copied to clipboard
open fun getAchievement(specId: String): MagicAchievement
Link copied to clipboard
open fun getIntel(): MagicAchievementIntel
Link copied to clipboard
Reads achievement specs from CSV files in mods and returns them.
Link copied to clipboard
open fun initIntel()
Link copied to clipboard
Loads achievements (so that any that track stuff outside the campaign are started).
Link copied to clipboard
open fun onGameLoad()
(Re)loads achievements (so that any that track stuff outside the campaign are started).
Link copied to clipboard
open fun playSoundEffect(achievement: MagicAchievement)
You shouldn't need to call this.
Link copied to clipboard
open fun reloadAchievements(isSaveGameLoaded: Boolean)
Unloads all current achievements from the sector and reloads them from files.
Link copied to clipboard
open fun removeAchievementSpec(specId: String)
Link copied to clipboard
open fun resetAchievementToSpec(achievement: MagicAchievement)
Resets the achievement passed in to the spec.
Link copied to clipboard
open fun setAchievementsEnabled(areAchievementsEnabled: Boolean, isSaveLoaded: Boolean)
Sets whether achievements are enabled or not.

Properties

Link copied to clipboard
val achievements: Map<String, MagicAchievement>
Link copied to clipboard
Set of achievement IDs that have thrown an error in their advanceInCombat method.
Link copied to clipboard
Set of achievement IDs that have thrown an error in their advance method.
Link copied to clipboard
Loaded once at launch and not again.
Link copied to clipboard