001package com.fs.starfarer.api.campaign.events; 002 003import java.awt.Color; 004import java.util.List; 005import java.util.Map; 006 007import com.fs.starfarer.api.campaign.InteractionDialogAPI; 008import com.fs.starfarer.api.campaign.comm.MessagePriority; 009import com.fs.starfarer.api.campaign.econ.CommodityOnMarketAPI; 010import com.fs.starfarer.api.campaign.econ.MarketAPI; 011import com.fs.starfarer.api.campaign.rules.MemoryAPI; 012import com.fs.starfarer.api.impl.campaign.rulecmd.CallEvent.CallableEvent; 013import com.fs.starfarer.api.util.Misc.Token; 014 015 016public interface CampaignEventPlugin extends CallableEvent { 017 018 //public static final String SUBJECT = "cep_subject"; 019 020 public static enum CampaignEventCategory { 021 EVENT, 022 BOUNTY, 023 MISSION, 024 DO_NOT_SHOW_IN_MESSAGE_FILTER, 025 } 026 027 public static interface PriceUpdatePlugin { 028 public static enum PriceType { 029 CHEAP, 030 EXPENSIVE, 031 NORMAL, 032 } 033 034 MarketAPI getMarket(); 035 CommodityOnMarketAPI getCommodity(); 036 float getSupplyPrice(); 037 float getDemandPrice(); 038 PriceType getType(); 039 long getTimestamp(); 040 void updateType(); 041 float getDemand(); 042 float getAvailable(); 043 int getRoundedPriceForDisplay(); 044 } 045 046 047 048 /** 049 * Unique ID for this instance of the event. 050 * @return 051 */ 052 String getId(); 053 054 /** 055 * Called when the EventProbability for this event is accessed. 056 * Doesn't mean the event will actually happen. 057 * @param eventType 058 * @param eventTarget 059 */ 060 void init(String eventType, CampaignEventTarget eventTarget); 061 062 063 /** 064 * Called when this instance of the event is removed from the event manager (either due to event being over, 065 * or due to event probability dropping to 0). 066 */ 067 void cleanup(); 068 069 070 /** 071 * The probability that the event had of happening, set right before startEvent() is called. 072 * Set to 1 by events started using CampaignEventManagerAPI.startEvent(). 073 * @param p 074 */ 075 void setProbability(float p); 076 077 /** 078 * Called when the event starts. 079 */ 080 void startEvent(); 081 082 void advance(float amount); 083 boolean isDone(); 084 085 CampaignEventTarget getEventTarget(); 086 String getEventType(); 087 088 089 /** 090 * Token values for filling out descriptions from reports.csv. 091 * @return 092 */ 093 Map<String, String> getTokenReplacements(); 094 095 /** 096 * Since multiple reports (possibly from different channels) are possible per stage: 097 * 1) All reports must have the highlighted text occur in the same order, which is the order 098 * this method returns them in, and 099 * 2) Not all highlights have to occur in every report. 100 * @param stageId 101 * @return 102 */ 103 String[] getHighlights(String stageId); 104 105 /** 106 * Since multiple reports (possibly from different channels) are possible per stage: 107 * 1) All reports must have the highlighted text occur in the same order, which is the order 108 * this method returns them in, and 109 * 2) Not all highlights have to occur in every report. 110 * @param stageId 111 * @return 112 */ 113 Color[] getHighlightColors(String stageId); 114 115 116 /** 117 * event_stage for when the event is possible, but hasn't happened yet. 118 * @return 119 */ 120 String getStageIdForPossible(); 121 122 123 /** 124 * Message priority for the "event is possible" report. 125 * @return 126 */ 127 MessagePriority getWarningWhenPossiblePriority(); 128 129 130 /** 131 * event_stage for when the event is likely, but hasn't happened yet. 132 * @return 133 */ 134 String getStageIdForLikely(); 135 136 /** 137 * Message priority for the "event is likely" report. 138 * @return 139 */ 140 MessagePriority getWarningWhenLikelyPriority(); 141 142 143 /** 144 * Only called when an event is started via CampaignEventManagerAPI.startEvent(). 145 * @param param 146 */ 147 void setParam(Object param); 148 149 /** 150 * DO NOT USE, DOES NOT WORK. 151 * 152 * Should always return false. 153 * 154 * @return 155 */ 156 @Deprecated boolean allowMultipleOngoingForSameTarget(); 157 158 String getEventName(); 159 boolean useEventNameAsId(); 160 161 CampaignEventCategory getEventCategory(); 162 163 List<String> getRelatedCommodities(); 164 List<PriceUpdatePlugin> getPriceUpdates(); 165 166 /** 167 * Will be called by SectorAPI.reportEventStage(). Can change between calls. 168 * 169 * The priority for icons is: 170 * 1) Icon configured in reports.csv for the specific report 171 * 2) Return value of this method 172 * 3) Event's icon (via getEventIcon() and then from events.json) 173 * 4) Channel's icon, if message isn't related to an event or the event has no icon. 174 * 175 * @return 176 */ 177 String getCurrentMessageIcon(); 178 179 180 /** 181 * The larger image in the message detail. 182 * @return 183 */ 184 String getCurrentImage(); 185 186 187 /** 188 * Override for the "image" normally specified in events.json. Small. 189 * @return 190 */ 191 String getEventIcon(); 192 193 194 /** 195 * If true, messages for an ongoing event will be shown in the intel UI even if 196 * they don't meet the "last week/month/cycle" criteria. 197 * @return 198 */ 199 boolean showAllMessagesIfOngoing(); 200 201 202 /** 203 * Called by the CallEvent command (called from rules.csv). 204 * @param memoryMap 205 * @param params 206 */ 207 boolean callEvent(String ruleId, InteractionDialogAPI dialog, List<Token> params, Map<String, MemoryAPI> memoryMap); 208 209 MemoryAPI getMemory(); 210 211 boolean showLatestMessageIfOngoing(); 212} 213 214 215 216