Starsector API
Loading...
Searching...
No Matches
TemporalShellStats.java
Go to the documentation of this file.
1package com.fs.starfarer.api.impl.combat;
2
3import java.awt.Color;
4
5import com.fs.starfarer.api.Global;
6import com.fs.starfarer.api.combat.MutableShipStatsAPI;
7import com.fs.starfarer.api.combat.ShipAPI;
8
10 public static final float MAX_TIME_MULT = 3f;
11 public static final float MIN_TIME_MULT = 0.1f;
12 public static final float DAM_MULT = 0.1f;
13
14 public static final Color JITTER_COLOR = new Color(90,165,255,55);
15 public static final Color JITTER_UNDER_COLOR = new Color(90,165,255,155);
16
17
18 public void apply(MutableShipStatsAPI stats, String id, State state, float effectLevel) {
19 ShipAPI ship = null;
20 boolean player = false;
21 if (stats.getEntity() instanceof ShipAPI) {
22 ship = (ShipAPI) stats.getEntity();
23 player = ship == Global.getCombatEngine().getPlayerShip();
24 id = id + "_" + ship.getId();
25 } else {
26 return;
27 }
28
29 float jitterLevel = effectLevel;
30 float jitterRangeBonus = 0;
31 float maxRangeBonus = 10f;
32 if (state == State.IN) {
33 jitterLevel = effectLevel / (1f / ship.getSystem().getChargeUpDur());
34 if (jitterLevel > 1) {
35 jitterLevel = 1f;
36 }
37 jitterRangeBonus = jitterLevel * maxRangeBonus;
38 } else if (state == State.ACTIVE) {
39 jitterLevel = 1f;
40 jitterRangeBonus = maxRangeBonus;
41 } else if (state == State.OUT) {
42 jitterRangeBonus = jitterLevel * maxRangeBonus;
43 }
44 jitterLevel = (float) Math.sqrt(jitterLevel);
45 effectLevel *= effectLevel;
46
47 ship.setJitter(this, JITTER_COLOR, jitterLevel, 3, 0, 0 + jitterRangeBonus);
48 ship.setJitterUnder(this, JITTER_UNDER_COLOR, jitterLevel, 25, 0f, 7f + jitterRangeBonus);
49
50
51 float shipTimeMult = 1f + (MAX_TIME_MULT - 1f) * effectLevel;
52 stats.getTimeMult().modifyMult(id, shipTimeMult);
53 if (player) {
54 Global.getCombatEngine().getTimeMult().modifyMult(id, 1f / shipTimeMult);
55// if (ship.areAnyEnemiesInRange()) {
56// Global.getCombatEngine().getTimeMult().modifyMult(id, 1f / shipTimeMult);
57// } else {
58// Global.getCombatEngine().getTimeMult().modifyMult(id, 2f / shipTimeMult);
59// }
60 } else {
62 }
63
64 ship.getEngineController().fadeToOtherColor(this, JITTER_COLOR, new Color(0,0,0,0), effectLevel, 0.5f);
65 ship.getEngineController().extendFlame(this, -0.25f, -0.25f, -0.25f);
66 }
67
68
69 public void unapply(MutableShipStatsAPI stats, String id) {
70 ShipAPI ship = null;
71 boolean player = false;
72 if (stats.getEntity() instanceof ShipAPI) {
73 ship = (ShipAPI) stats.getEntity();
74 player = ship == Global.getCombatEngine().getPlayerShip();
75 id = id + "_" + ship.getId();
76 } else {
77 return;
78 }
79
81 stats.getTimeMult().unmodify(id);
82
83// stats.getHullDamageTakenMult().unmodify(id);
84// stats.getArmorDamageTakenMult().unmodify(id);
85// stats.getEmpDamageTakenMult().unmodify(id);
86 }
87
88 public StatusData getStatusData(int index, State state, float effectLevel) {
89 float shipTimeMult = 1f + (MAX_TIME_MULT - 1f) * effectLevel;
90 if (index == 0) {
91 return new StatusData("time flow altered", false);
92 }
93// if (index == ) {
94// return new StatusData("increased speed", false);
95// }
96// if (index == 1) {
97// return new StatusData("increased acceleration", false);
98// }
99 return null;
100 }
101}
102
103
104
105
106
107
108
109
static CombatEngineAPI getCombatEngine()
Definition Global.java:69
void modifyMult(String source, float value)
StatusData getStatusData(int index, State state, float effectLevel)
void apply(MutableShipStatsAPI stats, String id, State state, float effectLevel)
void unapply(MutableShipStatsAPI stats, String id)
void setJitterUnder(Object source, Color color, float intensity, int copies, float range)
void setJitter(Object source, Color color, float intensity, int copies, float range)
ShipEngineControllerAPI getEngineController()
void fadeToOtherColor(Object key, Color other, Color contrailColor, float effectLevel, float maxBlend)
void extendFlame(Object key, float extendLengthFraction, float extendWidthFraction, float extendGlowFraction)