Starsector API
Loading...
Searching...
No Matches
BaseCampaignObjectivePlugin.java
Go to the documentation of this file.
1package com.fs.starfarer.api.impl.campaign;
2
3import com.fs.starfarer.api.campaign.TextPanelAPI;
4import com.fs.starfarer.api.ui.TooltipMakerAPI;
5import com.fs.starfarer.api.util.Misc;
6
8
9 public static final String HACKED = "$cob_hacked";
10 public static final String RESET = "$cob_reset";
11
12 public static final float HACK_DURATION_DAYS = 90f;
13 public static final float RESET_DURATION_DAYS = 30f;
14
15 public void printEffect(TooltipMakerAPI text, float pad) {
16
17 }
18
19 public void addHackStatusToTooltip(TooltipMakerAPI text, float pad) {
20 if (isHacked()) {
21 text.addPara("Hacked", Misc.getTextColor(), pad);
22 }
23 if (isReset()) {
24 text.addPara("Disrupted by factory reset", Misc.getTextColor(), pad);
25 }
26 }
27
28 public void printNonFunctionalAndHackDescription(TextPanelAPI text) {
29
30 }
31
32
33 public Boolean isHacked() {
34 return entity != null && entity.getMemoryWithoutUpdate().getBoolean(HACKED);
35 }
36
37 public void setHacked(boolean hacked) {
38 setHacked(hacked, HACK_DURATION_DAYS + (float) Math.random() * 0.5f * HACK_DURATION_DAYS);
39 }
40
41 public void setHacked(boolean hacked, float days) {
42 if (hacked) {
43 entity.getMemoryWithoutUpdate().set(HACKED, hacked, days);
44 } else {
45 entity.getMemoryWithoutUpdate().unset(HACKED);
46 }
47 }
48
49 public Boolean isReset() {
50 return entity != null && entity.getMemoryWithoutUpdate().getBoolean(RESET);
51 }
52
53 public void setReset(boolean reset) {
54 setReset(reset, RESET_DURATION_DAYS + (float) Math.random() * 0.5f * RESET_DURATION_DAYS);
55 }
56
57 public void setReset(boolean reset, float days) {
58 if (reset) {
59 entity.getMemoryWithoutUpdate().set(RESET, reset, days);
60 } else {
61 entity.getMemoryWithoutUpdate().unset(RESET);
62 }
63 }
64
65
66
67}
68
69
70
71