Starsector API
Loading...
Searching...
No Matches
PortsideBarData.java
Go to the documentation of this file.
1package com.fs.starfarer.api.impl.campaign.intel.bar;
2
3import java.util.ArrayList;
4import java.util.Iterator;
5import java.util.List;
6
7import com.fs.starfarer.api.EveryFrameScript;
8import com.fs.starfarer.api.Global;
9import com.fs.starfarer.api.impl.campaign.intel.bar.events.BarEventManager;
10
11public class PortsideBarData implements EveryFrameScript {
12
13 public static final String KEY = "$core_PortsideBarData";
14
15// public static final float CHECK_DAYS = 10f;
16// public static final float CHECK_PROB = 0.5f;
17
18
19 public static PortsideBarData getInstance() {
20 Object test = Global.getSector().getMemoryWithoutUpdate().get(KEY);
21 return (PortsideBarData) test;
22 }
23
24 protected List<PortsideBarEvent> active = new ArrayList<PortsideBarEvent>();
25
26 public PortsideBarData() {
27 Global.getSector().getMemoryWithoutUpdate().set(KEY, this);
28 }
29
30
31 public void addEvent(PortsideBarEvent event) {
32 active.add(event);
33 }
34
35 public void removeEvent(PortsideBarEvent event) {
36 active.remove(event);
37 // may or may not be there, but try to remove in any case
38 BarEventManager.getInstance().getActive().remove(event);
39 }
40
41 public List<PortsideBarEvent> getEvents() {
42// boolean exists = false;
43// for (PortsideBarEvent curr : active) {
44// if (curr instanceof HubMissionBarEventWrapper) {
45// exists = true;
46// break;
47// }
48// }
49// if (!exists) {
50// active.add(new HubMissionBarEventWrapper("cheapCom"));
51// }
52 return active;
53 }
54
55 public void advance(float amount) {
56
57 Iterator<PortsideBarEvent> iter = active.iterator();
58 while (iter.hasNext()) {
59 PortsideBarEvent curr = iter.next();
60 if (curr.shouldRemoveEvent()) {
61 iter.remove();
62 } else {
63 curr.advance(amount);
64 if (curr.shouldRemoveEvent()) {
65 iter.remove();
66 }
67 }
68 }
69
70 }
71
72 public boolean isDone() {
73 return false;
74 }
75
76 public boolean runWhilePaused() {
77 return false;
78 }
79
80
81
82}
83
84
static SectorAPI getSector()
Definition Global.java:59