Starsector API
Loading...
Searching...
No Matches
DisruptIndustryRaidObjectivePluginImpl.java
Go to the documentation of this file.
1package com.fs.starfarer.api.impl.campaign.graid;
2
3import java.awt.Color;
4import java.util.Random;
5
6import com.fs.starfarer.api.campaign.CargoAPI;
7import com.fs.starfarer.api.campaign.TextPanelAPI;
8import com.fs.starfarer.api.campaign.econ.Industry;
9import com.fs.starfarer.api.campaign.econ.Industry.IndustryTooltipMode;
10import com.fs.starfarer.api.campaign.econ.MarketAPI;
11import com.fs.starfarer.api.impl.campaign.procgen.StarSystemGenerator;
12import com.fs.starfarer.api.impl.campaign.rulecmd.salvage.MarketCMD.RaidDangerLevel;
13import com.fs.starfarer.api.loading.IndustrySpecAPI;
14import com.fs.starfarer.api.ui.TooltipMakerAPI;
15import com.fs.starfarer.api.util.Misc;
16
18
19 public static float DISRUPTION_DAYS_XP_MULT = 300;
20
21 public DisruptIndustryRaidObjectivePluginImpl(MarketAPI market, Industry target) {
22 super(market, target.getId());
23 setSource(target);
24 }
25
26 @Override
27 public void setSource(Industry source) {
28 super.setSource(source);
29// RaidDangerLevel level = getDangerLevel();
30// int marines = level.marineTokens;
31// if (source != null) {
32// marines = source.adjustMarineTokensToRaidItem(id, data, marines);
33// }
34// setMarinesRequired(marines);
35 }
36
37 @Override
38 public String getQuantityString(int marines) {
39 float days = source.getDisruptedDays();
40 if (days > 0 && days < 1) days = 1;
41 days = Math.round(days);
42 if (days > 0) {
43 return "" + (int) days;
44 }
45 return "";
46 }
47
48 @Override
49 public Color getQuantityColor(int marines) {
50 //if (getQuantityString(marines).isEmpty()) return Misc.getGrayColor();
51 return Misc.getHighlightColor();
52 }
53
54 public int getDisruptionDaysSort(int marines) {
55 marines = Math.max(1, marines);
56 return (int) getBaseDisruptDuration(marines);
57 }
58
59 public String getDisruptionDaysString(int marines) {
60 marines = Math.max(1, marines);
61 return "" + (int) getBaseDisruptDuration(marines);
62 }
63
64 public float getQuantity(int marines) {
65 return 0;
66 }
67
68 public int getValue(int marines) {
69 return 0;
70 }
71
73 return 0;
74 }
75
76 public IndustrySpecAPI getSpec() {
77 return getSource().getSpec();
78 }
79
80 public RaidDangerLevel getDangerLevel() {
81 RaidDangerLevel level = getSpec().getDisruptDanger();
82 return level;
83 }
84
85 public float getQuantitySortValue() {
86 IndustrySpecAPI spec = getSpec();
87 float add = spec.getOrder();
88 return QUANTITY_SORT_TIER_4 + add + 1000;
89 }
90
91 public String getName() {
92 return getSource().getCurrentName();
93 }
94
95 @Override
96 public String getIconName() {
97 return getSource().getCurrentImage();
98 }
99
100 protected float addedDisruptionDays = 0f;
101 public float getAddedDisruptionDays() {
102 return addedDisruptionDays;
103 }
104
106 this.addedDisruptionDays = addedDisruptionDays;
107 }
108
109 public int performRaid(CargoAPI loot, Random random, float lootMult, TextPanelAPI text) {
110 if (marinesAssigned <= 0) return 0;
111
113 dur *= lootMult;
114 dur *= StarSystemGenerator.getNormalRandom(random, 1f, 1.1f);
115 if (dur < 2) dur = 2;
116 float already = source.getDisruptedDays();
117 source.setDisrupted(already + dur);
119
120 //text.addPara("The raid was successful in disrupting " + source.getNameForModifier() + " operations." +
121 text.addPara("The raid was successful in disrupting " + source.getCurrentName() + " operations." +
122 " It will take at least %s days for normal operations to resume.",
123 Misc.getHighlightColor(), "" + (int) Math.round(source.getDisruptedDays()));
124
125 int xpGained = (int) (dur * DISRUPTION_DAYS_XP_MULT);
126 return xpGained;
127 }
128
129 public float getBaseDisruptDuration(int marines) {
130 if (marines <= 0) return 0f;
131 float already = source.getDisruptedDays();
132 //float dur = marines * Global.getSettings().getFloat("raidDisruptDurationPerMarineToken");
133 float dur = marines * source.getSpec().getDisruptDanger().disruptionDays;
134 dur *= dur / (dur + already);
135 return dur;
136 }
137
138 @Override
139 public boolean hasTooltip() {
140 return true;
141 }
142
143 @Override
144 public float getTooltipWidth() {
145 return getSource().getTooltipWidth();
146 }
147
148 @Override
149 public void createTooltip(TooltipMakerAPI t, boolean expanded) {
150 getSource().createTooltip(IndustryTooltipMode.NORMAL, t, expanded);
151// float opad = 10f;
152// float pad = 3f;
153// Color h = Misc.getHighlightColor();
154// Color bad = Misc.getNegativeHighlightColor();
155// Color good = Misc.getPositiveHighlightColor();
156//
157// //Description desc = Global.getSettings().getDescription(id, Type.RESOURCE);
158//
159// t.addPara(getItemSpec().getDescFirstPara(), 0f);
160//
161// t.addPara("Base value: %s per unit", opad, h, Misc.getDGSCredits(getItemSpec().getBasePrice()));
162 }
163}
164
165
166
167