001package com.fs.starfarer.api.campaign; 002 003import com.fs.starfarer.api.PluginPick; 004import com.fs.starfarer.api.campaign.ai.AbilityAIPlugin; 005import com.fs.starfarer.api.campaign.ai.AssignmentModulePlugin; 006import com.fs.starfarer.api.campaign.ai.ModularFleetAIAPI; 007import com.fs.starfarer.api.campaign.ai.NavigationModulePlugin; 008import com.fs.starfarer.api.campaign.ai.StrategicModulePlugin; 009import com.fs.starfarer.api.campaign.ai.TacticalModulePlugin; 010import com.fs.starfarer.api.campaign.econ.ImmigrationPlugin; 011import com.fs.starfarer.api.campaign.econ.MarketAPI; 012import com.fs.starfarer.api.campaign.rules.MemoryAPI; 013import com.fs.starfarer.api.characters.AbilityPlugin; 014import com.fs.starfarer.api.characters.PersonAPI; 015import com.fs.starfarer.api.fleet.FleetMemberAPI; 016import com.fs.starfarer.api.plugins.AutofitPlugin; 017 018 019public interface CampaignPlugin { 020 021 public static enum PickPriority { 022 /** 023 * Lowest priority. Should only be used by core code, a modded plugin with this priority may not end up being used 024 * anywhere, as what gets picked when multiple plugins have the same priority is undefined. 025 */ 026 CORE_GENERAL, 027 028 /** 029 * Should be used by mods for wholesale replacement of campaign features. 030 */ 031 MOD_GENERAL, 032 033 /** 034 * Should only be used by core code. 035 */ 036 CORE_SET, 037 038 /** 039 * For a plugin that handles a set of circumstances. For example "interaction with all jungle worlds". 040 * Overrides any _GENERAL prioritiy implementations (i.e. "interaction with all planets"). 041 * Is overriden by _SPECIFIC priority ("interaction with this particular planet"). 042 */ 043 MOD_SET, 044 045 /** 046 * Should be used by core code only for specific encounters. For example, a "special" planet or fleet 047 * could have their own dialog, and the priority of this would override a mod that replaces the general interactions 048 * with all planets or fleets. 049 */ 050 CORE_SPECIFIC, 051 052 /** 053 * Should be used by mods for specific encounters, that is, encounters that aren't handled by 054 * any of the _GENERAL and _SET priority plugins. For example, if a specific fleet has a special encounter dialog, it would be 055 * returned using this priority. 056 */ 057 MOD_SPECIFIC, 058 059 /** 060 * Absolute highest priority; shouldn't be used without good reason. 061 * A mod compilation might use this to resolve conflicts introduced by mods it contains. 062 */ 063 HIGHEST, 064 065 } 066 067 /** 068 * Used for unregistering plugins, should be unique. 069 * Can be null, but shouldn't. If not null, the game will ensure that only one copy of the 070 * plugin can be registered - new registrations will override prior ones. 071 * @return 072 */ 073 String getId(); 074 075 /** 076 * If the plugin is transient, its data won't be included in save games and it needs to be re-added to 077 * the game every time (in ModPlugin.onGameLoad()). 078 * 079 * If a plugin is not transient, its data is saved and it can be added in ModPlugin.onNewGame(). 080 * 081 * Plugins should be transient unless they need to save data, to improve the ability to add/remove mods 082 * from an existing game. 083 * 084 * @return 085 */ 086 boolean isTransient(); 087 088 089 /** 090 * Returns the dialog plugin to be used to drive the interaction dialog for the particular entity. 091 * 092 * Return null if this CampaignPlugin implementation doesn't provide one. 093 * 094 * @param interactionTarget 095 * @return 096 */ 097 PluginPick<InteractionDialogPlugin> pickInteractionDialogPlugin(SectorEntityToken interactionTarget); 098 099 100 /** 101 * Used for: 102 * - interaction dialogs created by clicking on a comm message action icon 103 * 104 * Return null if this CampaignPlugin implementation doesn't provide a dialog for the above use case(s). 105 * 106 * @param interactionTarget 107 * @return 108 */ 109 PluginPick<InteractionDialogPlugin> pickInteractionDialogPlugin(Object param, SectorEntityToken interactionTarget); 110 111 112 /** 113 * Returns a plugin that is used to generate the battlefield. Mods could use this to create a custom 114 * battlefield for a special opponent, for example, without having to override the core 115 * BattleCreationPlugin implementation. 116 * 117 * Return null if this CampaignPlugin implementation doesn't provide one. 118 * @param opponent 119 * @return 120 */ 121 PluginPick<BattleCreationPlugin> pickBattleCreationPlugin(SectorEntityToken opponent); 122 123 124 /** 125 * Returns a plugin used to quickly resolve a battle outcome. 126 * 127 * 128 * Return null if this CampaignPlugin implementation doesn't provide one. 129 * @param one 130 * @param two 131 * @return 132 */ 133 PluginPick<BattleAutoresolverPlugin> pickBattleAutoresolverPlugin(BattleAPI battle); 134 135 136 PluginPick<ReputationActionResponsePlugin> pickReputationActionResponsePlugin(Object action, String factionId); 137 PluginPick<ReputationActionResponsePlugin> pickReputationActionResponsePlugin(Object action, PersonAPI person); 138 139 140 /** 141 * Update the "this is known by the entity about the world" facts. 142 * Any variables set here should have an expiration time of 0, since 143 * this method will be called every time the getMemory() method is called. 144 * 145 * Having facts not expire would clutter up the memory. 146 * 147 * Mod-added facts should have their variable names use a mod-specific prefix to 148 * avoid conflicts. 149 * 150 * @param memory 151 */ 152 void updateEntityFacts(SectorEntityToken entity, MemoryAPI memory); 153 void updatePersonFacts(PersonAPI person, MemoryAPI memory); 154 void updateFactionFacts(FactionAPI faction, MemoryAPI memory); 155 void updateGlobalFacts(MemoryAPI memory); 156 void updatePlayerFacts(MemoryAPI memory); 157 void updateMarketFacts(MarketAPI market, MemoryAPI memory); 158 159 160 161 162 163 164 /** 165 * See ModularFleetAIAPI documentation for details. 166 * @param fleet 167 * @param ai 168 * @return 169 */ 170 PluginPick<AssignmentModulePlugin> pickAssignmentAIModule(CampaignFleetAPI fleet, ModularFleetAIAPI ai); 171 172 /** 173 * See ModularFleetAIAPI documentation for details. 174 * @param fleet 175 * @param ai 176 * @return 177 */ 178 PluginPick<StrategicModulePlugin> pickStrategicAIModule(CampaignFleetAPI fleet, ModularFleetAIAPI ai); 179 180 /** 181 * See ModularFleetAIAPI documentation for details. 182 * @param fleet 183 * @param ai 184 * @return 185 */ 186 PluginPick<TacticalModulePlugin> pickTacticalAIModule(CampaignFleetAPI fleet, ModularFleetAIAPI ai); 187 188 /** 189 * See ModularFleetAIAPI documentation for details. 190 * @param fleet 191 * @param ai 192 * @return 193 */ 194 PluginPick<NavigationModulePlugin> pickNavigationAIModule(CampaignFleetAPI fleet, ModularFleetAIAPI ai); 195 196 197 198 /** 199 * AI for campaign abilities - transponder, go dark, emergency burn, etc. 200 * @param ability 201 * @return 202 */ 203 PluginPick<AbilityAIPlugin> pickAbilityAI(AbilityPlugin ability, ModularFleetAIAPI ai); 204 205 206 PluginPick<FleetStubConverterPlugin> pickStubConverter(FleetStubAPI stub); 207 PluginPick<FleetStubConverterPlugin> pickStubConverter(CampaignFleetAPI fleet); 208 209 210 /** 211 * member will be null when picking plugin to assign idle officers from fleet screen. 212 * Only used for autofit in the refit screen. For NPC fleets, see: DefaultFleetInflater. 213 * @param member 214 * @return 215 */ 216 PluginPick<AutofitPlugin> pickAutofitPlugin(FleetMemberAPI member); 217 218 PluginPick<InteractionDialogPlugin> pickRespawnPlugin(); 219 220 PluginPick<ImmigrationPlugin> pickImmigrationPlugin(MarketAPI market); 221 222 PluginPick<AICoreAdminPlugin> pickAICoreAdminPlugin(String commodityId); 223 PluginPick<AICoreOfficerPlugin> pickAICoreOfficerPlugin(String commodityId); 224 225 PluginPick<FleetInflater> pickFleetInflater(CampaignFleetAPI fleet, Object params); 226 227} 228 229 230 231 232 233 234 235