1package com.fs.starfarer.api.impl.campaign.intel.inspection;
4import java.util.ArrayList;
6import java.util.Random;
9import org.lwjgl.input.Keyboard;
11import com.fs.starfarer.api.Global;
12import com.fs.starfarer.api.campaign.CampaignFleetAPI;
13import com.fs.starfarer.api.campaign.FactionAPI;
14import com.fs.starfarer.api.campaign.ReputationActionResponsePlugin.ReputationAdjustmentResult;
15import com.fs.starfarer.api.campaign.SectorEntityToken;
16import com.fs.starfarer.api.campaign.econ.Industry;
17import com.fs.starfarer.api.campaign.econ.MarketAPI;
18import com.fs.starfarer.api.characters.PersonAPI;
19import com.fs.starfarer.api.impl.campaign.CoreReputationPlugin;
20import com.fs.starfarer.api.impl.campaign.CoreReputationPlugin.CustomRepImpact;
21import com.fs.starfarer.api.impl.campaign.CoreReputationPlugin.RepActionEnvelope;
22import com.fs.starfarer.api.impl.campaign.CoreReputationPlugin.RepActions;
23import com.fs.starfarer.api.impl.campaign.DebugFlags;
24import com.fs.starfarer.api.impl.campaign.fleets.RouteLocationCalculator;
25import com.fs.starfarer.api.impl.campaign.fleets.RouteManager.RouteData;
26import com.fs.starfarer.api.impl.campaign.ids.Factions;
27import com.fs.starfarer.api.impl.campaign.ids.Tags;
28import com.fs.starfarer.api.impl.campaign.intel.raid.RaidAssignmentAI;
29import com.fs.starfarer.api.impl.campaign.intel.raid.RaidIntel;
30import com.fs.starfarer.api.impl.campaign.intel.raid.RaidIntel.RaidDelegate;
31import com.fs.starfarer.api.impl.campaign.procgen.themes.RouteFleetAssignmentAI;
32import com.fs.starfarer.api.ui.Alignment;
33import com.fs.starfarer.api.ui.ButtonAPI;
34import com.fs.starfarer.api.ui.IntelUIAPI;
35import com.fs.starfarer.api.ui.LabelAPI;
36import com.fs.starfarer.api.ui.SectorMapAPI;
37import com.fs.starfarer.api.ui.TooltipMakerAPI;
38import com.fs.starfarer.api.util.Misc;
44 public static interface InspectionEndedListener {
45 public void notifyInspectionEnded(HegemonyInspectionOutcome
outcome);
48 public static enum HegemonyInspectionOutcome {
49 COLONY_NO_LONGER_EXISTS,
52 FOUND_EVIDENCE_NO_CORES,
57 public static enum AntiInspectionOrders {
73 protected AntiInspectionOrders
orders = AntiInspectionOrders.COMPLY;
81 protected HegemonyInspectionOutcome
outcome;
82 protected Random
random =
new Random();
87 super(
target.getStarSystem(),
from.getFaction(),
null);
93 for (Industry curr :
target.getIndustries()) {
94 String
id = curr.getAICoreId();
99 PersonAPI admin =
target.getAdmin();
100 if (admin.isAICore()) {
104 float orgDur = 20f + 10f * (float) Math.random();
112 SectorEntityToken gather =
from.getPrimaryEntity();
113 SectorEntityToken raidJump = RouteLocationCalculator.findJumpPointToUse(getFactionForUIColors(),
target.getPrimaryEntity());
115 if (gather ==
null || raidJump ==
null) {
120 float successMult = 0.5f;
123 assemble.addSource(
from);
124 assemble.setSpawnFP(inspectionFP);
125 assemble.setAbortFP(inspectionFP * successMult);
131 travel.setAbortFP(inspectionFP * successMult);
135 action.setAbortFP(inspectionFP * successMult);
169 RaidAssignmentAI raidAI =
new RaidAssignmentAI(fleet, route,
action);
213 super.advanceImpl(amount);
223 protected transient ReputationAdjustmentResult
repResult =
null;
225 boolean hostile = getFaction().isHostileTo(Factions.PLAYER);
228 new RepActionEnvelope(RepActions.MAKE_HOSTILE_AT_BEST,
229 null,
null,
null,
false,
false),
240 CustomRepImpact impact =
new CustomRepImpact();
241 impact.delta = delta;
243 new RepActionEnvelope(RepActions.CUSTOM,
244 impact,
null,
null,
false,
false),
245 getFaction().getId());
254 String base =
"Hegemony AI Inspection";
255 if (
outcome == HegemonyInspectionOutcome.TASK_FORCE_DESTROYED ||
256 outcome == HegemonyInspectionOutcome.COLONY_NO_LONGER_EXISTS)
return base +
" - Failed";
257 if (
outcome !=
null)
return base +
" - Completed";
266 Color h = Misc.getHighlightColor();
267 Color g = Misc.getGrayColor();
272 if (mode == ListInfoMode.IN_DESC) initPad = opad;
274 Color tc = getBulletColorForMode(mode);
277 boolean isUpdate = getListInfoParam() !=
null;
279 boolean hostile = getFaction().isHostileTo(Factions.PLAYER);
281 orders = AntiInspectionOrders.RESIST;
285 FactionAPI other =
target.getFaction();
286 info.addPara(
"Target: %s", initPad, tc,
287 other.getBaseUIColor(),
target.getName());
289 info.addPara(
"" + faction.getDisplayName() +
" forces arrive in-system and encounter resistance", initPad, tc,
290 faction.getBaseUIColor(), faction.getDisplayName());
293 null,
null, info, tc, isUpdate, initPad);
298 FactionAPI other =
target.getFaction();
299 info.addPara(
"Target: %s", initPad, tc,
300 other.getBaseUIColor(),
target.getName());
302 info.addPara(
"Arrived in-system", tc, initPad);
311 String cores =
"cores";
312 if (num == 1) cores =
"core";
313 info.addPara(
"%s AI " + cores +
" confiscated", initPad, tc, h,
"" + num);
316 if (
outcome == HegemonyInspectionOutcome.BRIBED) {
317 info.addPara(
"No AI cores found", initPad, tc, h,
"" + num);
318 }
else if (
outcome == HegemonyInspectionOutcome.FOUND_EVIDENCE_NO_CORES) {
319 FactionAPI other =
target.getFaction();
320 info.addPara(
"Operations at %s disrupted", initPad, tc,
321 other.getBaseUIColor(),
target.getName());
323 }
else if (
outcome == HegemonyInspectionOutcome.CONFISCATE_CORES) {
328 null,
null, info, tc, isUpdate, initPad);
342 float eta = getETA();
344 FactionAPI other =
target.getFaction();
345 info.addPara(
"Target: %s", initPad, tc,
346 other.getBaseUIColor(),
target.getName());
349 if (eta > 1 &&
outcome ==
null) {
350 String days = getDaysString(eta);
351 info.addPara(
"Estimated %s " + days +
" until arrival",
352 initPad, tc, h,
"" + (
int)Math.round(eta));
355 if (hostile ||
orders == AntiInspectionOrders.RESIST) {
356 info.addPara(
"Defenders will resist", tc, initPad);
357 }
else if (
orders == AntiInspectionOrders.COMPLY) {
358 info.addPara(
"Defenders will comply", tc, initPad);
359 }
else if (
orders == AntiInspectionOrders.BRIBE) {
360 info.addPara(
"Funds allocated for bribe", tc, initPad);
363 info.addPara(
"Inspection under way", tc, initPad);
368 String cores =
"cores";
369 if (num == 1) cores =
"core";
370 info.addPara(
"%s AI " + cores +
" confiscated", initPad, tc, h,
"" + num);
372 }
else if (
outcome == HegemonyInspectionOutcome.TASK_FORCE_DESTROYED) {
383 for (RaidStage stage : stages) {
394 super.createIntelInfo(info, mode);
401 Color h = Misc.getHighlightColor();
402 Color g = Misc.getGrayColor();
403 Color tc = Misc.getTextColor();
407 info.addImage(getFactionForUIColors().getLogo(), width, 128, opad);
409 FactionAPI faction = getFaction();
410 String has = faction.getDisplayNameHasOrHave();
411 String is = faction.getDisplayNameIsOrAre();
416 String strDesc = getRaidStrDesc();
417 int numFleets = (int) getOrigNumFleets();
418 String fleets =
"fleets";
419 if (numFleets == 1) fleets =
"fleet";
421 LabelAPI label = info.addPara(Misc.ucFirst(faction.getDisplayNameWithArticle()) +
" " + is +
422 " targeting %s for an inspection due to the suspected use of AI cores there." +
423 " The task force is projected to be " + strDesc +
" and is likely comprised of " +
424 "" + numFleets +
" " + fleets +
".",
425 opad, faction.getBaseUIColor(),
target.getName());
426 label.setHighlight(faction.getDisplayNameWithArticleWithoutArticle(),
target.getName(), strDesc,
"" + numFleets);
427 label.setHighlightColors(faction.getBaseUIColor(),
target.getFaction().getBaseUIColor(), h, h);
430 addStandardStrengthComparisons(info,
target,
targetFaction,
true,
false,
"inspection",
"inspection's");
433 info.addSectionHeading(
"Status",
434 faction.getBaseUIColor(), faction.getDarkUIColor(), Alignment.MID, opad);
436 for (RaidStage stage : stages) {
437 stage.showStageInfo(info);
438 if (getStageIndex(stage) == failStage)
break;
444 info.addSectionHeading(
"Your orders",
445 pf.getBaseUIColor(), pf.getDarkUIColor(), Alignment.MID, opad);
447 boolean hostile = getFaction().isHostileTo(Factions.PLAYER);
449 label = info.addPara(Misc.ucFirst(faction.getDisplayNameWithArticle()) +
" " + is +
450 " hostile towards " + pf.getDisplayNameWithArticle() +
". Your forces will attempt to resist the inspection.",
452 label.setHighlight(faction.getDisplayNameWithArticleWithoutArticle(),
453 pf.getDisplayNameWithArticleWithoutArticle());
454 label.setHighlightColors(faction.getBaseUIColor(), pf.getBaseUIColor());
458 info.addPara(
"The authorities at " +
target.getName() +
" will comply with the inspection. " +
459 "It is certain to find any AI cores currently in use.", opad);
462 info.addPara(
"You've allocated enough funds to ensure the inspection " +
463 "will produce a satisfactory outcome all around.", opad);
470 info.addPara(
"Your space and ground forces will attempt to resist the inspection.", opad);
476 pf.getBaseUIColor(), pf.getDarkUIColor(),
477 (
int)(width), 20f, opad * 2f);
478 button.setShortcut(Keyboard.KEY_T,
true);
480 info.addPara(
"The inspection task force is in-system and there's no time to implement new orders.", opad);
488 null,
null, info, tc,
false, opad);
499 if (listInfoParam == UPDATE_RETURNING) {
504 super.sendUpdateIfPlayerHasIntel(listInfoParam, onlyIfImportant, sendIfHidden);
511 Set<String> tags = super.getIntelTags(map);
512 tags.add(Tags.INTEL_MILITARY);
513 tags.add(Tags.INTEL_COLONIES);
514 tags.add(getFaction().getId());
520 if (
outcome ==
null && failStage >= 0) {
522 outcome = HegemonyInspectionOutcome.COLONY_NO_LONGER_EXISTS;
524 outcome = HegemonyInspectionOutcome.TASK_FORCE_DESTROYED;
549 return target.getPrimaryEntity();
551 return super.getMapLocation(map);
static SettingsAPI getSettings()
static SectorAPI getSector()
static void addAdjustmentMessage(float delta, FactionAPI faction, PersonAPI person, TextPanelAPI panel, TooltipMakerAPI info, Color tc, boolean withCurrent, float pad)
static boolean HEGEMONY_INSPECTION_DEBUG
static boolean FAST_RAIDS
List< String > getCoresRemoved()
RouteFleetAssignmentAI createAssignmentAI(CampaignFleetAPI fleet, RouteData route)
void sendUpdateIfPlayerHasIntel(Object listInfoParam, boolean onlyIfImportant, boolean sendIfHidden)
HegemonyInspectionOutcome outcome
void applyRepPenalty(float delta)
static final Object MADE_HOSTILE_UPDATE
void createSmallDescription(TooltipMakerAPI info, float width, float height)
static final Object OUTCOME_UPDATE
void notifyRaidEnded(RaidIntel raid, RaidStageStatus status)
boolean isEnteredSystem()
void buttonPressConfirmed(Object buttonId, IntelUIAPI ui)
AntiInspectionOrders getOrders()
InspectionEndedListener listener
void setEnteredSystem(boolean enteredSystem)
void setOrders(AntiInspectionOrders orders)
HIActionStage getActionStage()
HegemonyInspectionOutcome getOutcome()
void setOutcome(HegemonyInspectionOutcome outcome)
void createIntelInfo(TooltipMakerAPI info, ListInfoMode mode)
void makeHostileAndSendUpdate()
SectorEntityToken getMapLocation(SectorMapAPI map)
static final Object ENTERED_SYSTEM_UPDATE
transient ReputationAdjustmentResult repResult
transient String targetOwner
static final String BUTTON_CHANGE_ORDERS
Set< String > getIntelTags(SectorMapAPI map)
List< String > getExpectedCores()
void addBulletPoints(TooltipMakerAPI info, ListInfoMode mode)
HegemonyInspectionIntel(MarketAPI from, MarketAPI target, float inspectionFP)
void setInvestedCredits(int investedCredits)
AntiInspectionOrders orders
void sendInSystemUpdate()
InspectionEndedListener getListener()
void setListener(InspectionEndedListener listener)
List< String > expectedCores
void advanceImpl(float amount)
String getSpriteName(String category, String id)