public class BaseModPlugin extends java.lang.Object implements ModPlugin
While having a ModPlugin for your mod is not strictly necessary, it serves as an entry point for all kinds of useful things, such as faction initialization, adding custom scripts and picking AI plugins.
You need to instruct the game to load your implementation of this class by e.g. adding it to your mod_info.json: "modPlugin":"my.package.name.MyModBasePlugin"
| Constructor and Description |
|---|
BaseModPlugin() |
| Modifier and Type | Method and Description |
|---|---|
void |
afterGameSave()
Called after a game is saved.
|
void |
beforeGameSave()
Called before a game is saved.
|
void |
configureXStream(com.thoughtworks.xstream.XStream x) |
void |
onAboutToLinkCodexEntries() |
void |
onAboutToStartGeneratingCodex() |
void |
onApplicationLoad()
Called after all the core loading has finished and all the scripts have finished being compiled.
|
void |
onCodexDataGenerated() |
void |
onDevModeF8Reload()
Called after F8 is pressed in combat while in devMode.
|
void |
onEnabled(boolean wasEnabledBefore)
Called before onGameLoad() and only if this mod was not previously enabled for the loaded saved game, or if this is
a new game.
|
void |
onGameLoad(boolean newGame)
Called after a game has been loaded.
|
void |
onGameSaveFailed()
Called if saving the game failed for some reason, such as running out of memory.
|
void |
onNewGame()
Called when a new game is being created.
|
void |
onNewGameAfterEconomyLoad()
Called after the economy is loaded from economy.json and the initial steps are taken.
|
void |
onNewGameAfterProcGen() |
void |
onNewGameAfterTimePass()
After the new game has stepped through its initial 2 months.
|
PluginPick<ShipAIPlugin> |
pickDroneAI(ShipAPI drone,
ShipAPI mothership,
DroneLauncherShipSystemAPI system)
Called to pick drone AI implementation.
|
PluginPick<MissileAIPlugin> |
pickMissileAI(MissileAPI missile,
ShipAPI launchingShip)
Called to pick missile AI implementation.
|
PluginPick<ShipAIPlugin> |
pickShipAI(FleetMemberAPI member,
ShipAPI ship)
Called to pick an AI implementation for a specific ship.
|
PluginPick<AutofireAIPlugin> |
pickWeaponAutofireAI(WeaponAPI weapon)
Called to pick an AI implementation for a specific weapon.
|
public BaseModPlugin()
public void afterGameSave()
Example:
Global.getSector().getListenerManager().addListener(new MyListener());
afterGameSave in interface ModPluginpublic void beforeGameSave()
Example:
while (Global.getSector().getListenerManager().hasListenerOfClass(MyListener.class)){
Global.getSector().getListenerManager().removeListenerOfClass(MyListener.class);
}
beforeGameSave in interface ModPluginpublic void onGameSaveFailed()
onGameSaveFailed in interface ModPluginpublic void onApplicationLoad() throws java.lang.Exception
onApplicationLoad in interface ModPluginjava.lang.Exceptionpublic void onEnabled(boolean wasEnabledBefore)
public void onGameLoad(boolean newGame)
In here, you should do all kinds of initialization logic, such as adding transient scripts, registering campaign plugins, adding custom sensor ghosts etc.
onGameLoad in interface ModPluginnewGame - if true, a new campaign has just been started. Sector generation logic should only
be executed if this is true.public void onNewGame()
public void onNewGameAfterEconomyLoad()
onNewGameAfterEconomyLoad in interface ModPluginpublic PluginPick<ShipAIPlugin> pickShipAI(FleetMemberAPI member, ShipAPI ship)
Example:
if(ship.getVariant().getHullVariantId().equals("myVariantId")){
return new PluginPick(new MyAi(), CampaignPlugin.PickPriority.MOD_GENERAL)
}
return null;
pickShipAI in interface ModPluginmember - fleetMemeber of the ship in question. Can be used to inform your decision if/which AI to chooseship - the ship in questionpublic PluginPick<AutofireAIPlugin> pickWeaponAutofireAI(WeaponAPI weapon)
Example:
if(weapon.getId().equals("myWeaponId")){
return new PluginPick<>(new MyAi(), CampaignPlugin.PickPriority.MOD_GENERAL);
}
return null;
pickWeaponAutofireAI in interface ModPluginweapon - the weapon in questionpublic PluginPick<ShipAIPlugin> pickDroneAI(ShipAPI drone, ShipAPI mothership, DroneLauncherShipSystemAPI system)
ModPluginpickDroneAI in interface ModPluginsystem - use getSpecJson() to get at the system spec, if needed.public PluginPick<MissileAIPlugin> pickMissileAI(MissileAPI missile, ShipAPI launchingShip)
Example:
if(missile.getProjectileSpecId().equals("myMissileProjId")){
return new PluginPick<>(new MyAi(), CampaignPlugin.PickPriority.MOD_GENERAL);
}
return null;
pickMissileAI in interface ModPluginmissile - the missile in question. This is usually the main deciding factor.launchingShip - the ship that launched the missile. This can usually be ignoredpublic void onNewGameAfterTimePass()
onNewGameAfterTimePass in interface ModPluginpublic void configureXStream(com.thoughtworks.xstream.XStream x)
configureXStream in interface ModPluginpublic void onNewGameAfterProcGen()
onNewGameAfterProcGen in interface ModPluginpublic void onDevModeF8Reload()
onDevModeF8Reload in interface ModPluginpublic void onAboutToStartGeneratingCodex()
onAboutToStartGeneratingCodex in interface ModPluginpublic void onAboutToLinkCodexEntries()
onAboutToLinkCodexEntries in interface ModPluginpublic void onCodexDataGenerated()
onCodexDataGenerated in interface ModPlugin