Starsector API
Loading...
Searching...
No Matches
Refining.java
Go to the documentation of this file.
1package com.fs.starfarer.api.impl.campaign.econ.impl;
2
3import com.fs.starfarer.api.impl.campaign.ids.Commodities;
4import com.fs.starfarer.api.util.Pair;
5
6
7public class Refining extends BaseIndustry {
8
9 public void apply() {
10 super.apply(true);
11
12 int size = market.getSize();
13
14
15 demand(Commodities.HEAVY_MACHINERY, size - 2); // have to keep it low since it can be circular
16 demand(Commodities.ORE, size + 2);
17 demand(Commodities.RARE_ORE, size);
18
19 supply(Commodities.METALS, size);
20 supply(Commodities.RARE_METALS, size - 2);
21
22 Pair<String, Integer> deficit = getMaxDeficit(Commodities.HEAVY_MACHINERY, Commodities.ORE);
23 applyDeficitToProduction(1, deficit, Commodities.METALS);
24
25 deficit = getMaxDeficit(Commodities.HEAVY_MACHINERY, Commodities.RARE_ORE);
26 applyDeficitToProduction(1, deficit, Commodities.RARE_METALS);
27
28 if (!isFunctional()) {
29 supply.clear();
30 }
31 }
32
33
34 @Override
35 public void unapply() {
36 super.unapply();
37 }
38
39
40 public float getPatherInterest() {
41 return 2f + super.getPatherInterest();
42 }
43
44 @Override
45 protected boolean canImproveToIncreaseProduction() {
46 return true;
47 }
48}
Map< String, MutableCommodityQuantity > supply
Map< String, MutableCommodityQuantity > demand
Pair< String, Integer > getMaxDeficit(String ... commodityIds)
void applyDeficitToProduction(int index, Pair< String, Integer > deficit, String ... commodities)