Skip to content

Commit

Permalink
Better black hole sounds
Browse files Browse the repository at this point in the history
  • Loading branch information
MEEPofFaith committed Mar 17, 2024
1 parent 936790f commit 888251a
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
4 changes: 0 additions & 4 deletions src/progressed/content/PMSounds.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ public class PMSounds{
pixelShoot = new Sound(),
pixelHit = new Sound(),
rockExplode = new Sound(),
harbingerCharge = new Sound(),
harbingerBlast = new Sound(),
nuclearExplosion = new Sound(),
pulseBeam = new Sound(),
funiBoom = new Sound(),
Expand All @@ -31,8 +29,6 @@ public static void load() {
pixelShoot = Vars.tree.loadSound("pixel-shoot");
pixelHit = Vars.tree.loadSound("pixel-hit");
rockExplode = Vars.tree.loadSound("rock-explode");
harbingerCharge = Vars.tree.loadSound("harbinger-charge");
harbingerBlast = Vars.tree.loadSound("harbinger-blast");
nuclearExplosion = Vars.tree.loadSound("nuclear-explosion");
pulseBeam = Vars.tree.loadSound("pulse-beam");
funiBoom = Vars.tree.loadSound("funi-boom");
Expand Down
2 changes: 1 addition & 1 deletion src/progressed/content/blocks/PMBlocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,7 @@ public void setStats(){
recoilTime = 240f;
cooldownTime = 300f;
shootY = 0f;
shootSound = Sounds.release;
shootSound = Sounds.dullExplosion;
shootType = PMBullets.blackHole;

consumePower(35f);
Expand Down
27 changes: 27 additions & 0 deletions src/progressed/entities/bullet/energy/BlackHoleBulletType.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package progressed.entities.bullet.energy;

import arc.audio.*;
import arc.graphics.*;
import arc.math.*;
import arc.math.geom.*;
import arc.struct.*;
import arc.util.*;
import blackhole.graphics.*;
import mindustry.audio.*;
import mindustry.content.*;
import mindustry.entities.*;
import mindustry.entities.bullet.*;
Expand All @@ -15,6 +17,8 @@
import progressed.entities.*;
import progressed.entities.bullet.pseudo3d.*;

import static mindustry.Vars.*;

public class BlackHoleBulletType extends BulletType{
static Seq<Class<?>> immuneTypes = Seq.with(
ArcBulletType.class, //TODO Maybe implement a special case for these 3D bullets? Make suction radius spherical.
Expand All @@ -28,6 +32,8 @@ public class BlackHoleBulletType extends BulletType{

public Color color = Color.black;
public Effect swirlEffect = EnergyFx.blackHoleSwirl;
public Sound loopSound = Sounds.spellLoop;
public float loopSoundVolume = 2f;
public float suctionRadius = 160f, size = 6f, lensEdge = -1f, damageRadius = 17f;
public float force = 10f, scaledForce = 800f, bulletForce = 0.1f, bulletScaledForce = 1f;
public float bulletDamage = 10f;
Expand Down Expand Up @@ -60,6 +66,15 @@ public float continuousDamage(){
return damage / 2f * 60f; //Damage every 2 ticks
}

@Override
public void init(Bullet b){
super.init(b);

if(loopSound != null){
b.data = new SoundLoop(loopSound, loopSoundVolume);
}
}

@Override
public void update(Bullet b){
if(b.timer(1, 2f)){
Expand Down Expand Up @@ -98,6 +113,10 @@ public void update(Bullet b){
});
}

if(!headless && b.data instanceof SoundLoop loop){
loop.update(b.x, b.y, b.isAdded(), fout(b));
}

super.update(b);
}

Expand Down Expand Up @@ -145,6 +164,14 @@ public void despawned(Bullet b){
}
}

@Override
public void removed(Bullet b){
super.removed(b);
if(b.data instanceof SoundLoop loop){
loop.stop();
}
}

public static boolean checkType(BulletType type){ //Returns true for bullets immune to suction.
return immuneTypes.contains(c -> c.isAssignableFrom(type.getClass()));
}
Expand Down

0 comments on commit 888251a

Please sign in to comment.