Skip to content

Commit e9ade59

Browse files
committed
what's a unit, if it has no trails?
1 parent 9930f3d commit e9ade59

14 files changed

Lines changed: 488 additions & 225 deletions

File tree

978 Bytes
Loading
-32 Bytes
Loading
-26 Bytes
Loading

main/src/unity/content/Trails.java

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
package unity.content;
2+
3+
import arc.*;
4+
import arc.graphics.*;
5+
import arc.math.*;
6+
import arc.util.*;
7+
import unity.graphics.*;
8+
import unity.graphics.MultiTrail.*;
9+
import unity.util.*;
10+
11+
public final class Trails{
12+
public static TexturedTrail singlePhantasmal(int length){
13+
return new TexturedTrail(Core.atlas.find("unity-phantasmal-trail"), length){{
14+
blend = Blending.additive;
15+
fadeInterp = Interp.pow2In;
16+
sideFadeInterp = Interp.pow3In;
17+
mixInterp = Interp.pow10In;
18+
gradientInterp = Interp.pow10Out;
19+
fadeColor = new Color(0.3f, 0.5f, 1f);
20+
shrink = 0f;
21+
fadeAlpha = 1f;
22+
mixAlpha = 1f;
23+
trailChance = 0.4f;
24+
trailWidth = 1.6f;
25+
trailColor = UnityPal.monolithLight;
26+
}};
27+
}
28+
29+
public static TexturedTrail phantasmalExhaust(int length){
30+
return Utils.with(singlePhantasmal(length), t -> {
31+
t.fadeInterp = Interp.pow3In;
32+
t.sideFadeInterp = Interp.pow5In;
33+
t.mixAlpha = 0f;
34+
t.trailChance = 0f;
35+
t.shrink = -3.6f;
36+
});
37+
}
38+
39+
public static MultiTrail phantasmal(int length){
40+
return phantasmal(length, 3.6f, 3.5f, 0f);
41+
}
42+
43+
public static MultiTrail phantasmal(RotationHandler rot, int length){
44+
return phantasmal(rot, length, 3.6f, 3.5f, 0f);
45+
}
46+
47+
public static MultiTrail phantasmal(int length, float scale, float magnitude, float offsetY){
48+
return phantasmal(MultiTrail::calcRot, length, scale, magnitude, offsetY);
49+
}
50+
51+
public static MultiTrail phantasmal(RotationHandler rot, int length, float scale, float magnitude, float offsetY){
52+
int strandsAmount = 2;
53+
54+
TrailHold[] trails = new TrailHold[strandsAmount + 2];
55+
for(int i = 0; i < strandsAmount; i++) trails[i] = new TrailHold(Utils.with(singlePhantasmal(Mathf.round(length * 1.5f)), t -> t.trailWidth = 4.8f), 0f, 0f, 0.16f);
56+
trails[strandsAmount] = new TrailHold(singlePhantasmal(length));
57+
trails[strandsAmount + 1] = new TrailHold(phantasmalExhaust(Mathf.round(length * 0.5f)), 0f, 1.6f, 1f);
58+
59+
float offset = Mathf.random(Mathf.PI2 * scale);
60+
return new MultiTrail(rot, trails){
61+
@Override
62+
public void update(float x, float y, float width){
63+
float angle = rotation.get(this, x, y) - 90f;
64+
for(int i = 0; i < strandsAmount; i++){
65+
Tmp.v1.trns(angle, Mathf.sin((Time.time + offset + (Mathf.PI2 * scale) * ((float)i / strandsAmount)), scale, magnitude * width), offsetY);
66+
67+
TrailHold trail = trails[i];
68+
trail.trail.update(x + Tmp.v1.x, y + Tmp.v1.y, width * trail.width);
69+
}
70+
71+
for(int i = strandsAmount; i < trails.length; i++){
72+
TrailHold trail = trails[i];
73+
Tmp.v1.trns(angle, trail.x, trail.y);
74+
75+
trail.trail.update(x + Tmp.v1.x, y + Tmp.v1.y, width * trail.width);
76+
}
77+
78+
lastX = x;
79+
lastY = y;
80+
}
81+
};
82+
}
83+
84+
public static TexturedTrail singleSoul(int length){
85+
return new TexturedTrail(Core.atlas.find("unity-soul-trail"), length){{
86+
blend = Blending.additive;
87+
fadeInterp = Interp.pow5In;
88+
sideFadeInterp = Interp.pow10In;
89+
mixInterp = Interp.pow5In;
90+
gradientInterp = Interp.pow5Out;
91+
fadeColor = new Color(0.1f, 0.2f, 1f);
92+
shrink = 1f;
93+
mixAlpha = 0.8f;
94+
fadeAlpha = 0.5f;
95+
trailChance = 0f;
96+
}};
97+
}
98+
99+
public static MultiTrail soul(int length){
100+
return soul(length, 6f, 2.2f);
101+
}
102+
103+
public static MultiTrail soul(RotationHandler rot, int length){
104+
return soul(rot, length, 6f, 2.2f);
105+
}
106+
107+
public static MultiTrail soul(int length, float scale, float magnitude){
108+
return soul(MultiTrail::calcRot, length, scale, magnitude);
109+
}
110+
111+
public static MultiTrail soul(RotationHandler rot, int length, float scale, float magnitude){
112+
int strandsAmount = 3;
113+
114+
TrailHold[] trails = new TrailHold[strandsAmount + 1];
115+
for(int i = 0; i < strandsAmount; i++) trails[i] = new TrailHold(Utils.with(singleSoul(Mathf.round(length * 1.5f)), t -> t.mixAlpha = 0f), 0f, 0f, 0.56f);
116+
trails[strandsAmount] = new TrailHold(singlePhantasmal(length), UnityPal.monolith);
117+
118+
float dir = Mathf.sign(Mathf.chance(0.5f));
119+
float offset = Mathf.random(Mathf.PI2 * scale);
120+
return new MultiTrail(rot, trails){
121+
@Override
122+
public void update(float x, float y, float width){
123+
float angle = rotation.get(this, x, y) - 90f;
124+
for(int i = 0; i < strandsAmount; i++){
125+
float rad = (Time.time + offset + (Mathf.PI2 * scale) * ((float)i / strandsAmount)) * dir;
126+
float scl = Mathf.map(Mathf.sin(rad, scale, 1f), -1f, 1f, 0.2f, 1f);
127+
Tmp.v1.trns(angle, Mathf.cos(rad, scale, magnitude * width));
128+
129+
TrailHold trail = trails[i];
130+
trail.trail.update(x + Tmp.v1.x, y + Tmp.v1.y, width * trail.width * scl);
131+
}
132+
133+
TrailHold main = trails[trails.length - 1];
134+
Tmp.v1.trns(angle, main.x, main.y);
135+
136+
main.trail.update(x + Tmp.v1.x, y + Tmp.v1.y, width * main.width);
137+
138+
lastX = x;
139+
lastY = y;
140+
}
141+
};
142+
}
143+
144+
private Trails(){
145+
throw new AssertionError();
146+
}
147+
}

main/src/unity/content/effects/ChargeFx.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import mindustry.entities.*;
1212
import mindustry.gen.*;
1313
import mindustry.graphics.*;
14+
import unity.content.*;
1415
import unity.entities.effects.*;
1516
import unity.graphics.*;
1617
import unity.graphics.MultiTrail.*;
@@ -312,11 +313,11 @@ protected EffectState inst(float x, float y, float rotation, Color color, Object
312313
TrailHold[] trails = new TrailHold[12];
313314
for(int i = 0; i < trails.length; i++){
314315
Tmp.v1.trns(Mathf.random(360f), Mathf.random(24f, 64f));
315-
trails[i] = new TrailHold(new TexturedTrail(Core.atlas.find("unity-phantasmal-trail"), 8){{
316-
shrink = 1f;
317-
fadeAlpha = 0.5f;
318-
blend = Blending.additive;
319-
}}, Tmp.v1.x, Tmp.v1.y, Mathf.random(1f, 2f));
316+
trails[i] = new TrailHold(Utils.with(Trails.soul(26), t -> {
317+
if(t.trails[t.trails.length - 1].trail instanceof TexturedTrail tr){
318+
tr.trailChance = 0.1f;
319+
}
320+
}), Tmp.v1.x, Tmp.v1.y, Mathf.random(1f, 2f));
320321
}
321322

322323
EffectState state = super.inst(x, y, rotation, color, data);

main/src/unity/content/effects/ShootFx.java

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import mindustry.entities.*;
1212
import mindustry.gen.*;
1313
import mindustry.graphics.*;
14+
import unity.content.*;
1415
import unity.entities.bullet.anticheat.*;
1516
import unity.entities.effects.*;
1617
import unity.graphics.*;
@@ -291,27 +292,26 @@ public class ShootFx{
291292
class State extends EffectState{
292293
@Override
293294
public void remove(){
294-
if(data instanceof TexturedTrail[] data) for(TexturedTrail trail : data) Fx.trailFade.at(x, y, 1f, UnityPal.monolithLight, trail.copy());
295+
if(data instanceof Trail[] data) for(Trail trail : data) Fx.trailFade.at(x, y, 1f, UnityPal.monolithLight, trail.copy());
295296
super.remove();
296297
}
297298
} return Pools.obtain(State.class, State::new);
298-
}, 24f, e -> {
299-
if(!(e.data instanceof TexturedTrail[] data)) return;
299+
}, 25f, e -> {
300+
if(!(e.data instanceof Trail[] data)) return;
300301

301302
float initAngle = Mathf.randomSeed(e.id, 360f);
302303
for(int i = 0; i < data.length; i++){
303-
TexturedTrail trail = data[i];
304+
Trail trail = data[i];
304305
if(!state.isPaused()){
305306
Tmp.v1
306-
.trns(initAngle + 360f / data.length * i + Time.time * 6f, 4f + e.foutpowdown() * 12f)
307+
.trns(initAngle + 360f / data.length * i + Time.time * 6f, 4f + e.foutpowdown() * 16f)
307308
.add(e.x, e.y);
308309

309-
trail.update(Tmp.v1.x, Tmp.v1.y, e.fin());
310+
trail.update(Tmp.v1.x, Tmp.v1.y, e.fin() * 1.4f);
310311
}
311312

312-
tmpCol.set(UnityPal.monolith).lerp(UnityPal.monolithLight, e.finpowdown());
313-
trail.drawCap(tmpCol, 1.4f);
314-
trail.draw(tmpCol, 1.4f);
313+
trail.drawCap(UnityPal.monolithLight, 1f);
314+
trail.draw(UnityPal.monolithLight, 1f);
315315
}
316316

317317
color(UnityPal.monolithDark, UnityPal.monolith, e.fin());
@@ -321,13 +321,9 @@ public void remove(){
321321
}){
322322
@Override
323323
protected EffectState inst(float x, float y, float rotation, Color color, Object data){
324-
TexturedTrail[] trails = new TexturedTrail[5];
324+
Trail[] trails = new Trail[5];
325325
for(int i = 0; i < trails.length; i++){
326-
trails[i] = new TexturedTrail(Core.atlas.find("unity-phantasmal-trail"), 16){{
327-
shrink = 0f;
328-
fadeAlpha = 1f;
329-
blend = Blending.additive;
330-
}};
326+
trails[i] = Trails.soul(24);
331327
}
332328

333329
EffectState state = super.inst(x, y, rotation, color, data);

0 commit comments

Comments
 (0)