Erekir turret SFX (of varying quality)

This commit is contained in:
Anuken
2022-08-21 20:44:07 -04:00
parent ae83779253
commit 2c28b206b8
19 changed files with 62 additions and 3 deletions

View File

@@ -19,11 +19,15 @@ public class SoundLoop{
}
public void update(float x, float y, boolean play){
update(x, y, play, 1f);
}
public void update(float x, float y, boolean play, float volumeScl){
if(baseVolume <= 0) return;
if(id < 0){
if(play){
id = sound.loop(sound.calcVolume(x, y) * volume * baseVolume, 1f, sound.calcPan(x, y));
id = sound.loop(sound.calcVolume(x, y) * volume * baseVolume * volumeScl, 1f, sound.calcPan(x, y));
}
}else{
//fade the sound in or out
@@ -38,7 +42,7 @@ public class SoundLoop{
}
}
Core.audio.set(id, sound.calcPan(x, y), sound.calcVolume(x, y) * volume * baseVolume);
Core.audio.set(id, sound.calcPan(x, y), sound.calcVolume(x, y) * volume * baseVolume * volumeScl);
}
}

View File

@@ -3892,6 +3892,7 @@ public class Blocks{
);
coolantMultiplier = 6f;
shootSound = Sounds.shootAlt;
shake = 1f;
ammoPerShot = 2;
@@ -3944,6 +3945,8 @@ public class Blocks{
maxAmmo = 30;
consumeAmmoOnce = true;
shootSound = Sounds.shootAltLong;
drawer = new DrawTurret("reinforced-"){{
parts.add(new RegionPart("-front"){{
progress = PartProgress.warmup;
@@ -4012,6 +4015,10 @@ public class Blocks{
float r = range = 130f;
loopSound = Sounds.torch;
shootSound = Sounds.none;
loopSoundVolume = 1f;
//TODO balance, set up, where is liquid/sec displayed? status effects maybe?
ammo(
Liquids.ozone, new ContinuousFlameBulletType(){{
@@ -4247,6 +4254,9 @@ public class Blocks{
waveRad = 40f;
}};
//TODO shoot sound
shootSound = Sounds.cannon;
fragBullet = intervalBullet = new BasicBulletType(3f, 30){{
width = 9f;
hitSize = 5f;
@@ -4368,6 +4378,10 @@ public class Blocks{
}});
}};
shootSound = Sounds.none;
loopSoundVolume = 1f;
loopSound = Sounds.laserbeam;
shootWarmupSpeed = 0.08f;
shootCone = 360f;
@@ -4410,6 +4424,8 @@ public class Blocks{
missileAccelTime = 50f;
lowAltitude = true;
//targetAir = false;
loopSound = Sounds.missileTrail;
loopSoundVolume = 0.6f;
fogRadius = 6f;
@@ -4517,6 +4533,7 @@ public class Blocks{
recoil = 0.5f;
coolantMultiplier = 6f;
shootSound = Sounds.missileLaunch;
minWarmup = 0.94f;
shootWarmupSpeed = 0.03f;
@@ -4614,6 +4631,7 @@ public class Blocks{
mag = 3f;
}});
shootSound = Sounds.shootSmite;
minWarmup = 0.99f;
coolantMultiplier = 6f;
@@ -4803,6 +4821,9 @@ public class Blocks{
coolant = consume(new ConsumeLiquid(Liquids.water, 15f / 60f));
limitRange();
loopSound = Sounds.glow;
loopSoundVolume = 0.8f;
}};
malign = new PowerTurret("malign"){{
@@ -4816,6 +4837,10 @@ public class Blocks{
var circleColor = haloColor;
float circleY = 25f, circleRad = 11f, circleRotSpeed = 3.5f, circleStroke = 1.6f;
shootSound = Sounds.malignShoot;
loopSound = Sounds.spellLoop;
loopSoundVolume = 1.3f;
shootType = new FlakBulletType(8f, 80f){{
sprite = "missile-large";

View File

@@ -1098,6 +1098,11 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
return false;
}
/** @return volume cale of active sound. */
public float activeSoundVolume(){
return 1f;
}
/** @return whether this block should play its idle sound.*/
public boolean shouldAmbientSound(){
return shouldConsume();
@@ -1954,7 +1959,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
//TODO separate system for sound? AudioSource, etc
if(!headless){
if(sound != null){
sound.update(x, y, shouldActiveSound());
sound.update(x, y, shouldActiveSound(), activeSoundVolume());
}
if(block.ambientSound != Sounds.none && shouldAmbientSound()){

View File

@@ -437,6 +437,10 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
healTime -= Time.delta / 20f;
wasHealed = false;
if(!headless && type.loopSound != Sounds.none){
control.sound.loop(type.loopSound, this, type.loopSoundVolume);
}
//check if environment is unsupported
if(!type.supportsEnv(state.rules.env) && !dead){
Call.unitEnvDeath(self());

View File

@@ -246,6 +246,10 @@ public class UnitType extends UnlockableContent{
public Color lightColor = Pal.powerLight;
/** sound played when this unit explodes (*not* when it is shot down) */
public Sound deathSound = Sounds.bang;
/** sound played on loop when this unit is around. */
public Sound loopSound = Sounds.none;
/** volume of loop sound */
public float loopSoundVolume = 0.5f;
/** effect that this unit emits when falling */
public Effect fallEffect = Fx.fallSmoke;
/** effect created at engine when unit falls. */

View File

@@ -151,6 +151,11 @@ public class ContinuousTurret extends Turret{
return bullets.any();
}
@Override
public float activeSoundVolume(){
return 1f;
}
@Override
public byte version(){
return 3;

View File

@@ -581,6 +581,16 @@ public class Turret extends ReloadTurret{
}
@Override
public float activeSoundVolume(){
return shootWarmup;
}
@Override
public boolean shouldActiveSound(){
return shootWarmup > 0.01f && loopSound != Sounds.none;
}
@Override
public void write(Writes write){
super.write(write);