Starsector API
Loading...
Searching...
No Matches
DelayedBlueprintLearnScript.java
Go to the documentation of this file.
1package com.fs.starfarer.api.impl.campaign;
2
3import java.util.ArrayList;
4import java.util.List;
5
6import com.fs.starfarer.api.Global;
7import com.fs.starfarer.api.campaign.FactionAPI;
8import com.fs.starfarer.api.util.DelayedActionScript;
9
10public class DelayedBlueprintLearnScript extends DelayedActionScript {
11
12 public static float LEARNED_HULL_FREQUENCY = 0.1f;
13
14 protected List<String> fighters = new ArrayList<String>();
15 protected List<String> weapons = new ArrayList<String>();
16 protected List<String> ships = new ArrayList<String>();
17 protected List<String> industries = new ArrayList<String>();
18
19 protected String factionId;
20
22 this(factionId, 30f);
23 }
24
25 public DelayedBlueprintLearnScript(String factionId, float daysLeft) {
26 super(daysLeft);
27 this.factionId = factionId;
28 }
29
30 @Override
31 public void doAction() {
32 FactionAPI faction = Global.getSector().getFaction(factionId);
33 if (faction != null) {
34 if (!ships.isEmpty()) {
35 faction.clearShipRoleCache();
36 }
37
38 for (String id : ships) {
39 if (faction.knowsShip(id)) continue;
40 faction.addKnownShip(id, true);
41 faction.addUseWhenImportingShip(id);
42 faction.getHullFrequency().put(id, LEARNED_HULL_FREQUENCY);
43 }
44 for (String id : fighters) {
45 if (faction.knowsFighter(id)) continue;
46 faction.addKnownFighter(id, true);
47 }
48 for (String id : weapons) {
49 if (faction.knowsWeapon(id)) continue;
50 faction.addKnownWeapon(id, true);
51 }
52 for (String id : industries) {
53 if (faction.knowsIndustry(id)) continue;
54 faction.addKnownIndustry(id);
55 }
56 }
57 }
58
59 public List<String> getFighters() {
60 return fighters;
61 }
62
63 public List<String> getWeapons() {
64 return weapons;
65 }
66
67 public List<String> getShips() {
68 return ships;
69 }
70
71 public List<String> getIndustries() {
72 return industries;
73 }
74
75}
76
77
78
static SectorAPI getSector()
Definition Global.java:59