Starsector API
Loading...
Searching...
No Matches
BaseGhostBehavior.java
Go to the documentation of this file.
1package com.fs.starfarer.api.impl.campaign.ghosts;
2
3import java.util.ArrayList;
4import java.util.List;
5
6import com.fs.starfarer.api.Global;
7
8public class BaseGhostBehavior implements GhostBehavior {
9 protected float duration;
10 protected List<GhostBehaviorInterrupt> interrupts = new ArrayList<GhostBehaviorInterrupt>();
11
13 this.duration = duration;
14 }
15
16 public boolean isDone() {
17 return duration <= 0f;
18 }
19
20 public void advance(float amount, SensorGhost ghost) {
21 float days = Global.getSector().getClock().convertToDays(amount);
22 duration -= days;
23
25 curr.advance(amount, ghost, this);
26 if (curr.shouldInterruptBehavior(ghost, this)) {
27 end();
28 break;
29 }
30 }
31 }
32
33 public void end() {
34 duration = 0f;
35 }
36
37 public void addInterrupt(GhostBehaviorInterrupt interrupt) {
38 interrupts.add(interrupt);
39 }
40}
static SectorAPI getSector()
Definition Global.java:59