001package com.fs.starfarer.api;
002
003import com.fs.starfarer.api.combat.AutofireAIPlugin;
004import com.fs.starfarer.api.combat.DroneLauncherShipSystemAPI;
005import com.fs.starfarer.api.combat.MissileAIPlugin;
006import com.fs.starfarer.api.combat.MissileAPI;
007import com.fs.starfarer.api.combat.ShipAIPlugin;
008import com.fs.starfarer.api.combat.ShipAPI;
009import com.fs.starfarer.api.combat.WeaponAPI;
010import com.fs.starfarer.api.fleet.FleetMemberAPI;
011import com.thoughtworks.xstream.XStream;
012
013/**
014 * <b>NOTE: Instead of implementing this interface, extend BaseModPlugin instead.</b> 
015 * 
016 * A new instance of a mod's modPlugin class will be created when the game starts.
017 * 
018 * @author Alex Mosolov
019 *
020 * Copyright 2012 Fractal Softworks, LLC
021 */
022public interface ModPlugin {
023
024        /**
025         * Called after all the core loading has finished and all the scripts have finished being compiled.
026         * Gives the mod an opportunity to load its own data using the relevant SettingsAPI methods.
027         * 
028         * @throws Exception
029         */
030        void onApplicationLoad() throws Exception;
031        
032        /**
033         * Called when a new game is being created. This is the preferred way to generate the contents of the Sector,
034         * and is meant to replace generators.csv (which remains used for backwards compatibility).
035         */
036        void onNewGame();
037        
038        /**
039         * Called before onGameLoad() and only if this mod was not previously enabled for the loaded saved game, or if this is
040         * a new game.
041         * @param wasEnabledBefore true if the mod was enabled for this saved game at some point in the past, though not immediately prior (or this method wouldn't be called at all).
042         */
043        void onEnabled(boolean wasEnabledBefore);
044        
045        /**
046         * Called after a game has been loaded. Also called when a new game is created, after the onNewGame() plugins for all the
047         * mods have been called.
048         */
049        void onGameLoad(boolean newGame);
050        
051        /**
052         * Called before a game is saved.
053         */
054        void beforeGameSave();
055        
056        /**
057         * Called after a game is saved.
058         */
059        void afterGameSave();
060        
061        
062        /**
063         * Called if saving the game failed for some reason, such as running out of memory.
064         */
065        void onGameSaveFailed();
066        
067        void onNewGameAfterProcGen();
068        
069        /**
070         * Called after the economy is loaded from economy.json and the initial steps are taken.
071         * At this point, calling get getMarket() on entities will return the proper market.
072         * The sequence of calls is:
073         * onNewGame(); // can add markets to the economy here programmatically
074         * //load economy and step it
075         * onNewGameAfterEconomyLoad();
076         */
077        void onNewGameAfterEconomyLoad();
078        
079        
080        /**
081         * After the new game has stepped through its initial 2 months.
082         */
083        void onNewGameAfterTimePass();
084        
085        
086        
087        /**
088         * Called after F8 is pressed in combat while in devMode.
089         * Note: the game becomes potentially unstable after an F8-dev mode reload. That is,
090         * crashes may occur that would not have occured otherwise and are not indicative of bugs.
091         */
092        void onDevModeF8Reload();
093        
094        /**
095         * Called to pick an AI implementation for a specific ship. Here instead of in CampaignPlugin to support custom
096         * AI for missions.
097         * 
098         * @param member Can be null.
099         * @param ship Can not be null. Could be a ship or a fighter.
100         * @return null, or a custom AI implementation.
101         */
102        PluginPick<ShipAIPlugin> pickShipAI(FleetMemberAPI member, ShipAPI ship);
103        
104        /**
105         * Called to pick an AI implementation for a specific weapon.
106         * @param weapon
107         * @return
108         */
109        PluginPick<AutofireAIPlugin> pickWeaponAutofireAI(WeaponAPI weapon);
110        
111        
112        /**
113         * Called to pick drone AI implementation.
114         * @param drone
115         * @param mothership
116         * @param system use getSpecJson() to get at the system spec, if needed.
117         * @return
118         */
119        PluginPick<ShipAIPlugin> pickDroneAI(ShipAPI drone, ShipAPI mothership, DroneLauncherShipSystemAPI system);
120        
121        
122        /**
123         * Called to pick missile AI implementation.
124         * @param drone
125         * @param launchingShip
126         * @return
127         */
128        PluginPick<MissileAIPlugin> pickMissileAI(MissileAPI missile, ShipAPI launchingShip);
129
130        
131        
132        void configureXStream(XStream x);
133
134        void onAboutToStartGeneratingCodex();
135        void onAboutToLinkCodexEntries();
136        void onCodexDataGenerated();
137}
138
139
140
141
142
143
144
145
146