Starsector API
Loading...
Searching...
No Matches
BaseOneTimeFactor.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.util.Misc;
8
9public class BaseOneTimeFactor extends BaseEventFactor {
10
11 public static float SHOW_DURATION_DAYS = 30f;
12
13 protected int points;
14 protected long timestamp;
15
17 this.points = points;
18 timestamp = Global.getSector().getClock().getTimestamp();
19 }
20
21 @Override
22 public int getProgress(BaseEventIntel intel) {
23 return points;
24 }
25
26 @Override
27 public boolean isOneTime() {
28 return true;
29 }
30
31 protected String getBulletPointText(BaseEventIntel intel) {
32 return null;
33 }
34
35 public void addBulletPointForOneTimeFactor(BaseEventIntel intel, TooltipMakerAPI info, Color tc, float initPad) {
36 String text = getBulletPointText(intel);
37 if (text == null) text = getDesc(intel);
38 if (text != null) {
39 info.addPara(text + ": %s", initPad, tc, getProgressColor(intel),
40 getProgressStr(intel));
41 }
42 }
43
44 @Override
45 public boolean isExpired() {
46 return timestamp != 0 && Global.getSector().getClock().getElapsedDaysSince(timestamp) > SHOW_DURATION_DAYS;
47 }
48
49 public boolean hasOtherFactorsOfClass(BaseEventIntel intel, Class c) {
50 for (EventFactor factor : intel.getFactors()) {
51 if (factor != this && c.isInstance(factor)) {
52 return true;
53 }
54 }
55 return false;
56 }
57
58 @Override
59 public String getProgressStr(BaseEventIntel intel) {
60 if (getProgress(intel) == 0) {
61 return "";
62 }
63 return super.getProgressStr(intel);
64 }
65
66 @Override
67 public Color getDescColor(BaseEventIntel intel) {
68 if (getProgress(intel) == 0) {
69 return Misc.getGrayColor();
70 }
71 return super.getDescColor(intel);
72 }
73
74}
static SectorAPI getSector()
Definition Global.java:59
void addBulletPointForOneTimeFactor(BaseEventIntel intel, TooltipMakerAPI info, Color tc, float initPad)