mirror of
https://github.com/Anuken/Mindustry.git
synced 2026-01-25 05:51:47 -08:00
More sound fixes
This commit is contained in:
parent
7bb23c3384
commit
28dfe2b1f7
6 changed files with 23 additions and 6 deletions
BIN
core/assets/sounds/lasercharge2.ogg
Normal file
BIN
core/assets/sounds/lasercharge2.ogg
Normal file
Binary file not shown.
|
|
@ -18,11 +18,12 @@ public class SoundLoop{
|
|||
}
|
||||
|
||||
public void update(float x, float y, boolean play){
|
||||
if(baseVolume < 0) return;
|
||||
if(baseVolume <= 0) return;
|
||||
|
||||
if(id < 0){
|
||||
if(play){
|
||||
id = sound.loop(sound.calcVolume(x, y) * volume * baseVolume, 1f, sound.calcPan(x, y));
|
||||
Log.info("playing, id = @", id);
|
||||
}
|
||||
}else{
|
||||
//fade the sound in or out
|
||||
|
|
@ -36,6 +37,7 @@ public class SoundLoop{
|
|||
return;
|
||||
}
|
||||
}
|
||||
|
||||
sound.setPan(id, sound.calcPan(x, y), sound.calcVolume(x, y) * volume * baseVolume);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -432,7 +432,8 @@ public class UnitTypes implements ContentList{
|
|||
|
||||
reload = 320f;
|
||||
recoil = 0f;
|
||||
shootSound = Sounds.laser;
|
||||
chargeSound = Sounds.lasercharge2;
|
||||
shootSound = Sounds.beam;
|
||||
continuous = true;
|
||||
cooldownTime = 200f;
|
||||
|
||||
|
|
@ -1588,7 +1589,7 @@ public class UnitTypes implements ContentList{
|
|||
inaccuracy = 7f;
|
||||
ejectEffect = Fx.none;
|
||||
shake = 3f;
|
||||
shootSound = Sounds.shootBig;
|
||||
shootSound = Sounds.missile;
|
||||
xRand = 8f;
|
||||
shotDelay = 1f;
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import arc.math.*;
|
|||
import arc.math.geom.*;
|
||||
import arc.util.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import mindustry.audio.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.entities.bullet.*;
|
||||
import mindustry.entities.units.*;
|
||||
|
|
@ -117,10 +118,18 @@ abstract class WeaponsComp implements Teamc, Posc, Rotc, Velc, Statusc{
|
|||
mount.bullet.rotation(weaponRotation + 90);
|
||||
mount.bullet.set(shootX, shootY);
|
||||
vel.add(Tmp.v1.trns(rotation + 180f, mount.bullet.type.recoil));
|
||||
if(weapon.shootSound != Sounds.none && !headless){
|
||||
if(mount.sound == null) mount.sound = new SoundLoop(weapon.shootSound, 1f);
|
||||
mount.sound.update(x, y, true);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
//heat decreases when not firing
|
||||
mount.heat = Math.max(mount.heat - Time.delta * reloadMultiplier / mount.weapon.cooldownTime, 0);
|
||||
|
||||
if(mount.sound != null){
|
||||
mount.sound.update(x, y, false);
|
||||
}
|
||||
}
|
||||
|
||||
//flip weapon shoot side for alternating weapons at half reload
|
||||
|
|
@ -168,7 +177,7 @@ abstract class WeaponsComp implements Teamc, Posc, Rotc, Velc, Statusc{
|
|||
float baseX = this.x, baseY = this.y;
|
||||
boolean delay = weapon.firstShotDelay + weapon.shotDelay > 0f;
|
||||
|
||||
(delay ? weapon.chargeSound : weapon.shootSound).at(x, y, Mathf.random(weapon.soundPitchMin, weapon.soundPitchMax));
|
||||
(delay ? weapon.chargeSound : weapon.continuous ? Sounds.none : weapon.shootSound).at(x, y, Mathf.random(weapon.soundPitchMin, weapon.soundPitchMax));
|
||||
|
||||
BulletType ammo = weapon.bullet;
|
||||
float lifeScl = ammo.scaleVelocity ? Mathf.clamp(Mathf.dst(x, y, aimX, aimY) / ammo.range()) : 1f;
|
||||
|
|
@ -195,7 +204,9 @@ abstract class WeaponsComp implements Teamc, Posc, Rotc, Velc, Statusc{
|
|||
vel.add(Tmp.v1.trns(rotation + 180f, ammo.recoil));
|
||||
Effect.shake(weapon.shake, weapon.shake, x, y);
|
||||
mount.heat = 1f;
|
||||
weapon.shootSound.at(x, y, Mathf.random(weapon.soundPitchMin, weapon.soundPitchMax));
|
||||
if(!weapon.continuous){
|
||||
weapon.shootSound.at(x, y, Mathf.random(weapon.soundPitchMin, weapon.soundPitchMax));
|
||||
}
|
||||
});
|
||||
}else{
|
||||
vel.add(Tmp.v1.trns(rotation + 180f, ammo.recoil));
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package mindustry.entities.units;
|
||||
|
||||
import arc.util.*;
|
||||
import mindustry.audio.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.type.*;
|
||||
|
||||
|
|
@ -25,6 +26,8 @@ public class WeaponMount{
|
|||
public boolean side;
|
||||
/** current bullet for continuous weapons */
|
||||
public @Nullable Bullet bullet;
|
||||
/** sound loop for continuous weapons */
|
||||
public @Nullable SoundLoop sound;
|
||||
|
||||
public WeaponMount(Weapon weapon){
|
||||
this.weapon = weapon;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
org.gradle.daemon=true
|
||||
org.gradle.jvmargs=-Xms256m -Xmx1024m
|
||||
archash=b99073959675a037f3a722a7ca08d28c21e10038
|
||||
archash=3919455d82ac008743cf6794593b3379f9758a38
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue