1package com.fs.starfarer.api.impl.campaign.intel.events;
4import java.util.Random;
6import com.fs.starfarer.api.Global;
7import com.fs.starfarer.api.campaign.CampaignFleetAPI;
8import com.fs.starfarer.api.campaign.StarSystemAPI;
9import com.fs.starfarer.api.campaign.comm.IntelInfoPlugin.ListInfoMode;
10import com.fs.starfarer.api.campaign.econ.MarketAPI;
11import com.fs.starfarer.api.impl.campaign.ids.Factions;
12import com.fs.starfarer.api.impl.campaign.ids.Stats;
13import com.fs.starfarer.api.impl.campaign.intel.events.BaseEventIntel.EventStageData;
14import com.fs.starfarer.api.impl.campaign.intel.events.HostileActivityEventIntel.HAERandomEventData;
15import com.fs.starfarer.api.impl.campaign.intel.events.HostileActivityEventIntel.Stage;
16import com.fs.starfarer.api.impl.campaign.intel.group.FGRaidAction.FGRaidType;
17import com.fs.starfarer.api.impl.campaign.intel.group.FleetGroupIntel;
18import com.fs.starfarer.api.impl.campaign.intel.group.FleetGroupIntel.FGIEventListener;
19import com.fs.starfarer.api.impl.campaign.intel.group.GenericRaidFGI;
20import com.fs.starfarer.api.impl.campaign.intel.group.GenericRaidFGI.GenericRaidParams;
21import com.fs.starfarer.api.impl.campaign.missions.FleetCreatorMission.FleetStyle;
22import com.fs.starfarer.api.impl.campaign.missions.hub.HubMissionWithTriggers.ComplicationRepImpact;
23import com.fs.starfarer.api.impl.campaign.rulecmd.salvage.MarketCMD.BombardType;
24import com.fs.starfarer.api.ui.LabelAPI;
25import com.fs.starfarer.api.ui.TooltipMakerAPI;
26import com.fs.starfarer.api.ui.TooltipMakerAPI.TooltipCreator;
27import com.fs.starfarer.api.util.Misc;
28import com.fs.starfarer.api.util.WeightedRandomPicker;
31 implements FGIEventListener {
54 return Misc.getGrayColor();
56 return Global.
getSector().getFaction(Factions.REMNANTS).getBaseUIColor();
61 public void createTooltip(TooltipMakerAPI tooltip,
boolean expanded, Object tooltipParam) {
63 tooltip.addPara(
"Remnant fleets have been sighted in your space.", opad);
74 return super.getProgress(
intel);
79 return Misc.getGrayColor();
81 return Global.
getSector().getFaction(Factions.REMNANTS).getBaseUIColor();
90 public CampaignFleetAPI
createFleet(StarSystemAPI system, Random random) {
132 ListInfoMode mode,
boolean isUpdate, Color tc,
float initPad) {
133 Color c =
Global.
getSector().getFaction(Factions.REMNANTS).getBaseUIColor();
134 info.addPara(
"Impending Remnant attack", initPad, tc, c,
"Remnant");
138 ListInfoMode mode,
boolean isUpdate, Color tc,
float initPad) {
139 info.addPara(
"Remnant attack averted", tc, initPad);
148 Color c =
Global.
getSector().getFaction(Factions.REMNANTS).getBaseUIColor();
150 if (!(stage.rollData instanceof HAERandomEventData))
return;
151 HAERandomEventData data = (HAERandomEventData) stage.rollData;
152 if (!(data.custom instanceof MarketAPI))
return;
154 MarketAPI target = (MarketAPI) data.custom;
156 Color h = Misc.getHighlightColor();
157 info.addPara(
"There are signs of activity at a Remnant Nexus in your system. Intel evaluates "
158 +
"a high probability of an attack fleet being assembled to saturation-bombard " +
159 target.getName() +
".",
160 small, Misc.getNegativeHighlightColor(),
"saturation-bombard");
162 LabelAPI label = info.addPara(
"Defeating the attack fleet would only put off the problem, "
163 +
"but destroying the Remnant Nexus will end the threat for good.",
165 label.setHighlight(
"Remnant Nexus",
"end the threat");
166 label.setHighlightColors(
168 Misc.getPositiveHighlightColor());
171 stage.beginResetReqList(info,
true,
"crisis", opad);
172 info.addPara(
"The %s is destroyed", 0f, c,
"Remnant Nexus");
173 stage.endResetReqList(info,
false,
"crisis", -1, -1);
184 if (stage.id == Stage.HA_EVENT) {
191 if (system ==
null)
return null;
195 for (CampaignFleetAPI fleet : system.getFleets()) {
196 if (!fleet.isStationMode())
continue;
197 if (!Factions.REMNANTS.equals(fleet.getFaction().getId()))
continue;
206 if (stage.id == Stage.HA_EVENT) {
209 if (target ==
null || target.getStarSystem() ==
null)
return 0f;
212 if (nexus ==
null)
return 0f;
222 if (target ==
null)
return;
224 HAERandomEventData data =
new HAERandomEventData(
this, stage);
225 data.custom = target;
226 stage.rollData = data;
232 if (target ==
null || target.getStarSystem() ==
null)
return false;
235 if (nexus ==
null)
return false;
237 stage.rollData =
null;
245 for (StarSystemAPI system : Misc.getPlayerSystems(
false)) {
248 for (MarketAPI curr : Misc.getMarketsInLocation(system, Factions.PLAYER)) {
249 picker.add(curr, curr.getSize() * curr.getSize() * curr.getSize());
253 return picker.pick();
269 super.advance(amount);
272 if (stage !=
null && stage.rollData instanceof HAERandomEventData &&
273 ((HAERandomEventData)stage.rollData).factor ==
this) {
275 HAERandomEventData data = (HAERandomEventData) stage.rollData;
276 if (data.custom instanceof MarketAPI) {
277 MarketAPI target = (MarketAPI) data.custom;
288 public boolean startAttack(CampaignFleetAPI nexus, MarketAPI target, StarSystemAPI system, EventStageData stage, Random random) {
291 GenericRaidParams params =
new GenericRaidParams(
new Random(random.nextLong()),
true);
293 params.makeFleetsHostile =
true;
294 params.remnant =
true;
296 params.factionId = nexus.getFaction().getId();
299 fake.setPrimaryEntity(nexus);
300 fake.setFactionId(params.factionId);
301 fake.getStats().getDynamic().getMod(Stats.FLEET_QUALITY_MOD).modifyFlat(
302 "nexus_" + nexus.getId(), 1f);
306 params.source = fake;
308 params.prepDays = 0f;
309 params.payloadDays = 27f + 7f * random.nextFloat();
311 params.raidParams.where = system;
312 params.raidParams.type = FGRaidType.SEQUENTIAL;
313 params.raidParams.tryToCaptureObjectives =
false;
314 params.raidParams.allowedTargets.add(target);
315 params.raidParams.allowNonHostileTargets =
true;
316 params.raidParams.setBombardment(BombardType.SATURATION);
317 params.forcesNoun =
"remnant forces";
319 params.style = FleetStyle.STANDARD;
320 params.repImpact = ComplicationRepImpact.FULL;
324 float fleetSizeMult = 1f;
325 boolean damaged = nexus.getMemoryWithoutUpdate().getBoolean(
"$damagedStation");
327 fleetSizeMult = 0.5f;
330 float totalDifficulty = fleetSizeMult * 50f;
332 totalDifficulty -= 10;
333 params.fleetSizes.add(10);
335 while (totalDifficulty > 0) {
339 int diff = min + random.nextInt(max - min + 1);
341 params.fleetSizes.add(diff);
342 totalDifficulty -= diff;
350 GenericRaidFGI raid =
new GenericRaidFGI(params);
351 raid.setListener(
this);
static FactoryAPI getFactory()
static SectorAPI getSector()
void sendUpdateIfPlayerHasIntel(Object listInfoParam, TextPanelAPI textPanel)
void addBorder(TooltipMakerAPI info, Color c)
EventStageData getDataFor(Object stageId)
Random getRandomizedStageRandom()
TooltipCreator getDefaultEventTooltip(final String title, final HostileActivityEventIntel intel, final EventStageData stage)
HostileActivityEventIntel intel
int getProgress(BaseEventIntel intel)
void rollEvent(HostileActivityEventIntel intel, EventStageData stage)
static CampaignFleetAPI getRemnantNexus(StarSystemAPI system)
boolean shouldShow(BaseEventIntel intel)
void notifyFactorRemoved()
boolean startAttack(CampaignFleetAPI nexus, MarketAPI target, StarSystemAPI system, EventStageData stage, Random random)
String getNameForThreatList(boolean first)
void addBulletPointForEventReset(HostileActivityEventIntel intel, EventStageData stage, TooltipMakerAPI info, ListInfoMode mode, boolean isUpdate, Color tc, float initPad)
TooltipCreator getMainRowTooltip(BaseEventIntel intel)
int getMaxNumFleets(StarSystemAPI system)
Color getNameColor(float mag)
float getEventFrequency(HostileActivityEventIntel intel, EventStageData stage)
String getDesc(BaseEventIntel intel)
boolean fireEvent(HostileActivityEventIntel intel, EventStageData stage)
MarketAPI findAttackTarget(HostileActivityEventIntel intel, EventStageData stage)
CampaignFleetAPI createFleet(StarSystemAPI system, Random random)
TooltipCreator getStageTooltipImpl(final HostileActivityEventIntel intel, final EventStageData stage)
Color getDescColor(BaseEventIntel intel)
void addStageDescriptionForEvent(HostileActivityEventIntel intel, EventStageData stage, TooltipMakerAPI info)
void addBulletPointForEvent(HostileActivityEventIntel intel, EventStageData stage, TooltipMakerAPI info, ListInfoMode mode, boolean isUpdate, Color tc, float initPad)
String getProgressStr(BaseEventIntel intel)
RemnantHostileActivityFactor(HostileActivityEventIntel intel)
void reportFGIAborted(FleetGroupIntel intel)
void advance(float amount)
String getEventStageIcon(HostileActivityEventIntel intel, EventStageData stage)
MarketAPI createMarket(String id, String name, int size)