Starsector API
Loading...
Searching...
No Matches
GBGoInDirectionWithWobble.java
Go to the documentation of this file.
1
package
com.fs.starfarer.api.impl.campaign.ghosts;
2
3
import
org.lwjgl.util.vector.Vector2f;
4
5
import
com.fs.starfarer.api.util.Misc;
6
7
8
public
class
GBGoInDirectionWithWobble
extends
BaseGhostBehavior
{
9
10
protected
float
direction
;
11
protected
int
maxBurn
;
12
protected
float
phase
= (float) Math.random();
13
protected
float
wobbleRate
;
14
protected
float
maxWobble
;
15
16
public
GBGoInDirectionWithWobble
(
float
duration
,
float
direction
,
float
wobbleRate
,
float
maxWobble
,
int
maxBurn
) {
17
super(
duration
);
18
this.direction =
direction
;
19
this.wobbleRate =
wobbleRate
;
20
this.maxWobble =
maxWobble
;
21
this.maxBurn =
maxBurn
;
22
}
23
24
25
26
@Override
27
public
void
advance
(
float
amount,
SensorGhost
ghost) {
28
super.advance(amount, ghost);
29
30
float
pi = (float) Math.PI;
31
float
sin = (float) Math.sin(
phase
* pi * 2f);
32
phase
+= amount *
wobbleRate
;
33
34
float
maxAngleOffset =
maxWobble
;
35
float
angle =
direction
+ sin * maxAngleOffset;
36
37
Vector2f loc = Misc.getUnitVectorAtDegreeAngle(angle);
38
loc.scale(10000f);
39
Vector2f.add(loc, ghost.
getEntity
().getLocation(), loc);
40
ghost.
moveTo
(loc,
maxBurn
);
41
42
43
//System.out.println("Move angle: " + angle);
44
//System.out.println("Velocity: [" + (int)ghost.getEntity().getVelocity().x + "," + (int)ghost.getEntity().getVelocity().y + "]");
45
//System.out.println("Location: [" + (int)ghost.getEntity().getLocation().x + "," + (int)ghost.getEntity().getLocation().y + "]");
46
47
}
48
49
50
51
}
52
53
54
55
56
57
58
59
60
61
62
63
64
com.fs.starfarer.api.impl.campaign.ghosts.BaseGhostBehavior
Definition
BaseGhostBehavior.java:8
com.fs.starfarer.api.impl.campaign.ghosts.BaseGhostBehavior.duration
float duration
Definition
BaseGhostBehavior.java:9
com.fs.starfarer.api.impl.campaign.ghosts.GBGoInDirectionWithWobble
Definition
GBGoInDirectionWithWobble.java:8
com.fs.starfarer.api.impl.campaign.ghosts.GBGoInDirectionWithWobble.direction
float direction
Definition
GBGoInDirectionWithWobble.java:10
com.fs.starfarer.api.impl.campaign.ghosts.GBGoInDirectionWithWobble.advance
void advance(float amount, SensorGhost ghost)
Definition
GBGoInDirectionWithWobble.java:27
com.fs.starfarer.api.impl.campaign.ghosts.GBGoInDirectionWithWobble.GBGoInDirectionWithWobble
GBGoInDirectionWithWobble(float duration, float direction, float wobbleRate, float maxWobble, int maxBurn)
Definition
GBGoInDirectionWithWobble.java:16
com.fs.starfarer.api.impl.campaign.ghosts.GBGoInDirectionWithWobble.phase
float phase
Definition
GBGoInDirectionWithWobble.java:12
com.fs.starfarer.api.impl.campaign.ghosts.GBGoInDirectionWithWobble.maxBurn
int maxBurn
Definition
GBGoInDirectionWithWobble.java:11
com.fs.starfarer.api.impl.campaign.ghosts.GBGoInDirectionWithWobble.wobbleRate
float wobbleRate
Definition
GBGoInDirectionWithWobble.java:13
com.fs.starfarer.api.impl.campaign.ghosts.GBGoInDirectionWithWobble.maxWobble
float maxWobble
Definition
GBGoInDirectionWithWobble.java:14
com.fs.starfarer.api.impl.campaign.ghosts.SensorGhost
Definition
SensorGhost.java:11
com.fs.starfarer.api.impl.campaign.ghosts.SensorGhost.getEntity
CustomCampaignEntityAPI getEntity()
com.fs.starfarer.api.impl.campaign.ghosts.SensorGhost.moveTo
void moveTo(Vector2f dest, float maxBurn)
src
com
fs
starfarer
api
impl
campaign
ghosts
GBGoInDirectionWithWobble.java
Generated by
1.9.8