Starsector API
Loading...
Searching...
No Matches
MoteParticleScript.java
Go to the documentation of this file.
1package com.fs.starfarer.api.impl.campaign.world;
2
3import java.awt.Color;
4
5import org.lwjgl.util.vector.Vector2f;
6
7import com.fs.starfarer.api.EveryFrameScript;
8import com.fs.starfarer.api.campaign.SectorEntityToken;
9import com.fs.starfarer.api.util.IntervalUtil;
10import com.fs.starfarer.api.util.Misc;
11
12public class MoteParticleScript implements EveryFrameScript {
13
14 protected float moteSpawnRate = 1f;
15 protected SectorEntityToken entity;
16 protected IntervalUtil moteSpawn = new IntervalUtil(0.01f, 0.1f);
17
18 public MoteParticleScript(SectorEntityToken entity, float moteSpawnRate) {
19 super();
20 this.entity = entity;
21 this.moteSpawnRate = moteSpawnRate;
22 }
23
24 public void advance(float amount) {
25 float days = Misc.getDays(amount);
26 moteSpawn.advance(days * moteSpawnRate);
27 if (moteSpawn.intervalElapsed()) {
29 }
30 }
31
32
33 public static void spawnMote(SectorEntityToken from) {
34 if (!from.isInCurrentLocation()) return;
35 float dur = 1f + 2f * (float) Math.random();
36 dur *= 2f;
37 float size = 3f + (float) Math.random() * 5f;
38 size *= 3f;
39 Color color = new Color(255,100,255,175);
40
41 Vector2f loc = Misc.getPointWithinRadius(from.getLocation(), from.getRadius());
42 Vector2f vel = Misc.getUnitVectorAtDegreeAngle((float) Math.random() * 360f);
43 vel.scale(5f + (float) Math.random() * 10f);
44 vel.scale(0.25f);
45 Vector2f.add(vel, from.getVelocity(), vel);
46 Misc.addGlowyParticle(from.getContainingLocation(), loc, vel, size, 0.5f, dur, color);
47 }
48
49 public boolean isDone() {
50 return false;
51 }
52
53 public boolean runWhilePaused() {
54 return false;
55 }
56}
57
58
59
60
61
62
63
64
65
66
67
68
MoteParticleScript(SectorEntityToken entity, float moteSpawnRate)