some bad sounds

This commit is contained in:
Anuken
2019-08-12 23:29:24 -04:00
parent a1269c05c5
commit a818da5eb7
30 changed files with 920 additions and 841 deletions
@@ -12,9 +12,9 @@ import io.anuke.mindustry.entities.bullet.Bullet;
import io.anuke.mindustry.entities.impl.BaseEntity;
import io.anuke.mindustry.entities.traits.HealthTrait;
import io.anuke.mindustry.entities.traits.TargetTrait;
import io.anuke.mindustry.game.*;
import io.anuke.mindustry.game.EventType.BlockDestroyEvent;
import io.anuke.mindustry.game.Team;
import io.anuke.mindustry.gen.Call;
import io.anuke.mindustry.gen.*;
import io.anuke.mindustry.world.*;
import io.anuke.mindustry.world.modules.*;
@@ -45,6 +45,7 @@ public class TileEntity extends BaseEntity implements TargetTrait, HealthTrait{
private boolean dead = false;
private boolean sleeping;
private float sleepTime;
private @Nullable SoundLoop sound;
@Remote(called = Loc.server, unreliable = true)
public static void onTileDamage(Tile tile, float health){
@@ -69,6 +70,9 @@ public class TileEntity extends BaseEntity implements TargetTrait, HealthTrait{
x = tile.drawx();
y = tile.drawy();
block = tile.block();
if(block.idleSound != Sounds.none){
sound = new SoundLoop(block.idleSound, block.idleSoundVolume);
}
health = block.health;
timer = new Interval(block.timers);
@@ -231,6 +235,13 @@ public class TileEntity extends BaseEntity implements TargetTrait, HealthTrait{
return proximity;
}
@Override
public void removed(){
if(sound != null){
sound.stop();
}
}
@Override
public void health(float health){
this.health = health;
@@ -286,6 +297,10 @@ public class TileEntity extends BaseEntity implements TargetTrait, HealthTrait{
return; //no need to update anymore
}
if(sound != null){
sound.update(x, y, block.shouldIdleSound(tile));
}
Block previous = block;
block.update(tile);
if(block == previous && cons != null){