Starsector API
Loading...
Searching...
No Matches
HABlowbackFactor.java
Go to the documentation of this file.
1package com.fs.starfarer.api.impl.campaign.intel.events;
2
3import java.awt.Color;
4
5import com.fs.starfarer.api.Global;
6import com.fs.starfarer.api.ui.TooltipMakerAPI;
7import com.fs.starfarer.api.ui.TooltipMakerAPI.TooltipCreator;
8import com.fs.starfarer.api.util.Misc;
9
10public class HABlowbackFactor extends BaseEventFactor {
11
12 public static boolean ENABLED = true;
13
14 public static float FRACTION = Global.getSettings().getFloat("blowbackFraction");
15 public static float PER_MONTH = Global.getSettings().getFloat("blowbackPerMonth");
16 public static float ON_RESET = Global.getSettings().getFloat("blowbackOnReset");
17
19
20 }
21
22 @Override
23 public boolean shouldShow(BaseEventIntel intel) {
24 return ENABLED;
25// return true;
26// if (true) return true;
27// int p = Math.round(((HostileActivityEventIntel)intel).getBlowback());
28// return p > 0;
29 }
30
31 @Override
32 public TooltipCreator getMainRowTooltip(final BaseEventIntel intel) {
33 return new BaseFactorTooltip() {
34 @Override
35 public void createTooltip(TooltipMakerAPI tooltip, boolean expanded, Object tooltipParam) {
36 float opad = 10f;
37 Color h = Misc.getHighlightColor();
38
39 tooltip.addPara("Actions that postpone a crisis often have unintended consequences and "
40 + "cause their own problems in the long run. Ultimately, crises can not be avoided, "
41 + "and must instead be dealt with and exploited for the opportunities they provide.", 0f);
42
43 int p = Math.round(((HostileActivityEventIntel)intel).getBlowback());
44 tooltip.addPara("Will contribute %s of the points per month to event progress, and will "
45 + "also increase the value that progress is reset to after a crisis.", opad, h,
46 "" + Math.round(PER_MONTH * 100f) + "%");
47
48 tooltip.addPara("Points remaining: %s", opad, h, "" + p);
49 }
50
51 };
52 }
53
54 @Override
55 public String getProgressStr(BaseEventIntel intel) {
56 if (getProgress(intel) <= 0) return "";
57 return super.getProgressStr(intel);
58 }
59
60 @Override
61 public int getProgress(BaseEventIntel intel) {
62 if (!ENABLED) return 0;
63
64 int p = Math.round(((HostileActivityEventIntel)intel).getBlowback());
65 int amt = Math.round(p * PER_MONTH);
66 if (amt <= 0 && p > 0) {
67 amt = 1;
68 }
69 return amt;
70 }
71
72 @Override
73 public String getDesc(BaseEventIntel intel) {
74 return "Blowback";
75 }
76
77 @Override
78 public Color getDescColor(BaseEventIntel intel) {
79 if (getProgress(intel) > 0) return Misc.getTextColor();
80 return Misc.getGrayColor();
81 }
82
83}
84
85
86
87
88
static SettingsAPI getSettings()
Definition Global.java:51
TooltipCreator getMainRowTooltip(final BaseEventIntel intel)