1
1
package progressed .entities .bullet .energy ;
2
2
3
+ import arc .audio .*;
3
4
import arc .graphics .*;
4
5
import arc .math .*;
5
6
import arc .math .geom .*;
6
7
import arc .struct .*;
7
8
import arc .util .*;
8
9
import blackhole .graphics .*;
10
+ import mindustry .audio .*;
9
11
import mindustry .content .*;
10
12
import mindustry .entities .*;
11
13
import mindustry .entities .bullet .*;
15
17
import progressed .entities .*;
16
18
import progressed .entities .bullet .pseudo3d .*;
17
19
20
+ import static mindustry .Vars .*;
21
+
18
22
public class BlackHoleBulletType extends BulletType {
19
23
static Seq <Class <?>> immuneTypes = Seq .with (
20
24
ArcBulletType .class , //TODO Maybe implement a special case for these 3D bullets? Make suction radius spherical.
@@ -28,6 +32,8 @@ public class BlackHoleBulletType extends BulletType{
28
32
29
33
public Color color = Color .black ;
30
34
public Effect swirlEffect = EnergyFx .blackHoleSwirl ;
35
+ public Sound loopSound = Sounds .spellLoop ;
36
+ public float loopSoundVolume = 2f ;
31
37
public float suctionRadius = 160f , size = 6f , lensEdge = -1f , damageRadius = 17f ;
32
38
public float force = 10f , scaledForce = 800f , bulletForce = 0.1f , bulletScaledForce = 1f ;
33
39
public float bulletDamage = 10f ;
@@ -60,6 +66,15 @@ public float continuousDamage(){
60
66
return damage / 2f * 60f ; //Damage every 2 ticks
61
67
}
62
68
69
+ @ Override
70
+ public void init (Bullet b ){
71
+ super .init (b );
72
+
73
+ if (loopSound != null ){
74
+ b .data = new SoundLoop (loopSound , loopSoundVolume );
75
+ }
76
+ }
77
+
63
78
@ Override
64
79
public void update (Bullet b ){
65
80
if (b .timer (1 , 2f )){
@@ -98,6 +113,10 @@ public void update(Bullet b){
98
113
});
99
114
}
100
115
116
+ if (!headless && b .data instanceof SoundLoop loop ){
117
+ loop .update (b .x , b .y , b .isAdded (), fout (b ));
118
+ }
119
+
101
120
super .update (b );
102
121
}
103
122
@@ -145,6 +164,14 @@ public void despawned(Bullet b){
145
164
}
146
165
}
147
166
167
+ @ Override
168
+ public void removed (Bullet b ){
169
+ super .removed (b );
170
+ if (b .data instanceof SoundLoop loop ){
171
+ loop .stop ();
172
+ }
173
+ }
174
+
148
175
public static boolean checkType (BulletType type ){ //Returns true for bullets immune to suction.
149
176
return immuneTypes .contains (c -> c .isAssignableFrom (type .getClass ()));
150
177
}
0 commit comments