Starsector API
Loading...
Searching...
No Matches
ShoveFleetScript.java
Go to the documentation of this file.
1package com.fs.starfarer.api.impl.campaign.terrain;
2
3import org.lwjgl.util.vector.Vector2f;
4
5import com.fs.starfarer.api.EveryFrameScript;
6import com.fs.starfarer.api.Global;
7import com.fs.starfarer.api.campaign.CampaignFleetAPI;
8import com.fs.starfarer.api.util.Misc;
9
10public class ShoveFleetScript implements EveryFrameScript {
11
13 public static float DURATION_SECONDS = 0.1f;
14
15 protected CampaignFleetAPI fleet;
16 protected float elapsed;
17 protected float angle;
18 protected float intensity;
19 protected float impact = IMPACT_SPEED_DELTA;
20 protected Vector2f dV;
21
22 public ShoveFleetScript(CampaignFleetAPI fleet, float direction, float intensity) {
23 this.fleet = fleet;
24 this.intensity = intensity;
25 this.angle = direction;
26
27 //DURATION_SECONDS = 0.1f;
28
29 dV = Misc.getUnitVectorAtDegreeAngle(angle);
30
31 float fleetWeightFactor = (float) fleet.getFleetPoints() / 200f;
32 if (fleetWeightFactor > 1f) fleetWeightFactor = 1f;
33 fleetWeightFactor = 0.5f + 1f * (1f - fleetWeightFactor);
34
35 float speed = IMPACT_SPEED_DELTA * 40f * intensity;
36 float impact = speed * 1f * fleetWeightFactor;
37 dV.scale(impact);
38 dV.scale(1f / DURATION_SECONDS);
39 }
40
41 public void advance(float amount) {
42
43 fleet.setOrbit(null);
44
45 Vector2f v = fleet.getVelocity();
46 fleet.setVelocity(v.x + dV.x * amount, v.y + dV.y * amount);
47
48// Vector2f dir = Misc.getUnitVectorAtDegreeAngle(angle);
49//
50// float fleetWeightFactor = (float) fleet.getFleetPoints() / 200f;
51// if (fleetWeightFactor > 1f) fleetWeightFactor = 1f;
52// fleetWeightFactor = 0.5f + 1f * (1f - fleetWeightFactor);
53//
54// dir.scale(IMPACT_SPEED_DELTA * intensity * fleetWeightFactor* amount *
55// (Math.min(20f, Math.max(10f, fleet.getCurrBurnLevel())) * 50f) * (0.5f + (float) Math.random() * 0.5f));
56//
57// Vector2f v = fleet.getVelocity();
58// fleet.setVelocity(v.x + dir.x, v.y + dir.y);
59
60 elapsed += amount;
61
62 }
63
64 public boolean isDone() {
65 return elapsed >= DURATION_SECONDS;
66 }
67
68 public boolean runWhilePaused() {
69 return false;
70 }
71
72}
static SettingsAPI getSettings()
Definition Global.java:51
ShoveFleetScript(CampaignFleetAPI fleet, float direction, float intensity)