Starsector API
Loading...
Searching...
No Matches
OrganizeStage.java
Go to the documentation of this file.
1package com.fs.starfarer.api.impl.campaign.intel.raid;
2
3import java.awt.Color;
4
5import com.fs.starfarer.api.campaign.econ.MarketAPI;
6import com.fs.starfarer.api.impl.campaign.ids.MemFlags;
7import com.fs.starfarer.api.impl.campaign.intel.raid.RaidIntel.RaidStageStatus;
8import com.fs.starfarer.api.ui.TooltipMakerAPI;
9import com.fs.starfarer.api.util.IntervalUtil;
10import com.fs.starfarer.api.util.Misc;
11
12public class OrganizeStage extends BaseRaidStage {
13
14 protected MarketAPI market;
15 protected IntervalUtil interval = new IntervalUtil(0.1f, 0.2f);
16 protected boolean wasMilitary = false;
17
18 public OrganizeStage(RaidIntel raid, MarketAPI market, float durDays) {
19 super(raid);
20 this.market = market;
21 this.maxDays = durDays;
22
23 wasMilitary = market.getMemoryWithoutUpdate().getBoolean(MemFlags.MARKET_MILITARY);
24 }
25
26
27 public void advance(float amount) {
28 if (status == RaidStageStatus.ONGOING &&
29 (!market.isInEconomy() || (!market.getMemoryWithoutUpdate().getBoolean(MemFlags.MARKET_MILITARY) && wasMilitary))) {
30 abort();
31 return;
32 }
33 super.advance(amount);
34 }
35
36 protected void updateStatus() {
37 if (maxDays <= elapsed) {
38 status = RaidStageStatus.SUCCESS;
39 }
40 }
41
42 public void abort() {
43 status = RaidStageStatus.FAILURE;
44 }
45
46 public MarketAPI getMarket() {
47 return market;
48 }
49
50 public void showStageInfo(TooltipMakerAPI info) {
51 int curr = intel.getCurrentStage();
52 int index = intel.getStageIndex(this);
53
54 Color h = Misc.getHighlightColor();
55 Color g = Misc.getGrayColor();
56 Color tc = Misc.getTextColor();
57 float pad = 3f;
58 float opad = 10f;
59
60 int days = Math.round(maxDays - elapsed);
61 String strDays = RaidIntel.getDaysString(days);
62
63 String timing = getForcesString() + " should begin assembling in %s " + strDays + ".";
64 if (days < 2) {
65 timing = getForcesString() + " should begin assembling shortly.";
66 }
67
68 String raid = getRaidString();
69 if (status == RaidStageStatus.FAILURE) {
70 info.addPara("The " + raid + " has been disrupted in the planning stages and will not happen.", opad);
71 } else if (curr == index) {
72 boolean known = !market.isHidden() || !market.getPrimaryEntity().isDiscoverable();
73 if (known) {
74 info.addPara("The " + raid + " is currently being planned " +
75 market.getOnOrAt() + " " + market.getName() + ". " + timing,
76 opad, h, "" + days);
77 } else {
78 info.addPara("The " + raid + " is currently in the planning stages. " + timing,
79 opad, h, "" + days);
80 }
81 }
82 }
83
84 protected String getForcesString() {
85 return "The raiding forces";
86 }
87
88 protected String getRaidString() {
89 return "raid";
90 }
91}
92
93
94
95
96
97
OrganizeStage(RaidIntel raid, MarketAPI market, float durDays)