mirror of
https://github.com/Anuken/Mindustry.git
synced 2024-11-10 15:05:23 +03:00
Machine ambient sounds
This commit is contained in:
parent
c058163ab4
commit
89ee04c942
Binary file not shown.
Before Width: | Height: | Size: 5.5 KiB After Width: | Height: | Size: 5.5 KiB |
@ -514,6 +514,7 @@ setting.lasers.name = Show Power Lasers
|
||||
setting.pixelate.name = Pixelate[lightgray] (disables animations)
|
||||
setting.minimap.name = Show Minimap
|
||||
setting.musicvol.name = Music Volume
|
||||
setting.ambientvol.name = Ambient Volume
|
||||
setting.mutemusic.name = Mute Music
|
||||
setting.sfxvol.name = SFX Volume
|
||||
setting.mutesound.name = Mute Sound
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
core/assets/sounds/drill.ogg
Executable file → Normal file
BIN
core/assets/sounds/drill.ogg
Executable file → Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -132,11 +132,6 @@
|
||||
fontColor: white,
|
||||
up: info-banner
|
||||
},
|
||||
discord: {
|
||||
font: default,
|
||||
fontColor: white,
|
||||
up: info-banner
|
||||
},
|
||||
clear-partial: {
|
||||
down: whiteui,
|
||||
up: pane,
|
||||
|
@ -133,6 +133,7 @@ public class Vars{
|
||||
public static GlobalData data;
|
||||
public static EntityCollisions collisions;
|
||||
public static DefaultWaves defaultWaves;
|
||||
public static LoopControl loops;
|
||||
|
||||
public static Control control;
|
||||
public static Logic logic;
|
||||
@ -181,6 +182,7 @@ public class Vars{
|
||||
content.setVerbose();
|
||||
}
|
||||
|
||||
loops = new LoopControl();
|
||||
defaultWaves = new DefaultWaves();
|
||||
collisions = new EntityCollisions();
|
||||
|
||||
|
@ -1608,8 +1608,8 @@ public class Blocks implements ContentList{
|
||||
shootDuration = 220f;
|
||||
powerUse = 14f;
|
||||
shootSound = Sounds.laserbig;
|
||||
idleSound = Sounds.beam;
|
||||
idleSoundVolume = 2f;
|
||||
activeSound = Sounds.beam;
|
||||
activeSoundVolume = 2f;
|
||||
|
||||
health = 200 * size * size;
|
||||
consumes.add(new ConsumeLiquidFilter(liquid -> liquid.temperature <= 0.5f && liquid.flammability < 0.1f, 0.5f)).update(false);
|
||||
|
@ -392,6 +392,7 @@ public class Control implements ApplicationListener{
|
||||
data.checkSave();
|
||||
|
||||
music.update();
|
||||
loops.update();
|
||||
|
||||
if(!state.is(State.menu)){
|
||||
input.update();
|
||||
@ -415,7 +416,7 @@ public class Control implements ApplicationListener{
|
||||
Platform.instance.updateRPC();
|
||||
}
|
||||
|
||||
if(Core.input.keyTap(Binding.pause) && !ui.restart.isShown() && (state.is(State.paused) || state.is(State.playing))){
|
||||
if(Core.input.keyTap(Binding.pause) && !scene.hasDialog() && !ui.restart.isShown() && (state.is(State.paused) || state.is(State.playing))){
|
||||
state.set(state.is(State.playing) ? State.paused : State.playing);
|
||||
}
|
||||
|
||||
|
@ -20,8 +20,7 @@ import io.anuke.mindustry.world.modules.*;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
import static io.anuke.mindustry.Vars.tileGroup;
|
||||
import static io.anuke.mindustry.Vars.world;
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class TileEntity extends BaseEntity implements TargetTrait, HealthTrait{
|
||||
public static final float timeToSleep = 60f * 4; //4 seconds to fall asleep
|
||||
@ -70,8 +69,8 @@ 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);
|
||||
if(block.activeSound != Sounds.none){
|
||||
sound = new SoundLoop(block.activeSound, block.activeSoundVolume);
|
||||
}
|
||||
|
||||
health = block.health;
|
||||
@ -298,7 +297,11 @@ public class TileEntity extends BaseEntity implements TargetTrait, HealthTrait{
|
||||
}
|
||||
|
||||
if(sound != null){
|
||||
sound.update(x, y, block.shouldIdleSound(tile));
|
||||
sound.update(x, y, block.shouldActiveSound(tile));
|
||||
}
|
||||
|
||||
if(block.idleSound != Sounds.none && block.shouldIdleSound(tile)){
|
||||
loops.play(block.idleSound, this, block.idleSoundVolume);
|
||||
}
|
||||
|
||||
Block previous = block;
|
||||
|
63
core/src/io/anuke/mindustry/game/LoopControl.java
Normal file
63
core/src/io/anuke/mindustry/game/LoopControl.java
Normal file
@ -0,0 +1,63 @@
|
||||
package io.anuke.mindustry.game;
|
||||
|
||||
import io.anuke.arc.*;
|
||||
import io.anuke.arc.audio.*;
|
||||
import io.anuke.arc.collection.*;
|
||||
import io.anuke.arc.math.*;
|
||||
import io.anuke.arc.math.geom.*;
|
||||
import io.anuke.mindustry.*;
|
||||
|
||||
public class LoopControl{
|
||||
private ObjectMap<Sound, SoundData> sounds = new ObjectMap<>();
|
||||
|
||||
public void play(Sound sound, Position pos, float volume){
|
||||
if(Vars.headless) return;
|
||||
|
||||
float baseVol = sound.calcFalloff(pos.getX(), pos.getY());
|
||||
float vol = baseVol * volume;
|
||||
|
||||
SoundData data = sounds.getOr(sound, SoundData::new);
|
||||
data.volume += vol;
|
||||
data.volume = Mathf.clamp(data.volume, 0f, 1f);
|
||||
data.total += baseVol;
|
||||
data.sum.add(pos.getX() * baseVol, pos.getY() * baseVol);
|
||||
}
|
||||
|
||||
public void update(){
|
||||
float avol = Core.settings.getInt("ambientvol", 100) / 100f;
|
||||
|
||||
sounds.each((sound, data) -> {
|
||||
data.curVolume = Mathf.lerpDelta(data.curVolume, data.volume * avol, 0.2f);
|
||||
|
||||
boolean play = data.curVolume > 0.01f;
|
||||
float pan = Mathf.isZero(data.total, 0.0001f) ? 0f : sound.calcPan(data.sum.x / data.total, data.sum.y / data.total);
|
||||
//Log.info(pan);
|
||||
//TODO calc pan
|
||||
if(data.soundID <= 0){
|
||||
if(play){
|
||||
data.soundID = sound.loop(data.curVolume, 1f, pan);
|
||||
}
|
||||
}else{
|
||||
if(data.curVolume <= 0.01f){
|
||||
sound.stop(data.soundID);
|
||||
data.soundID = -1;
|
||||
return;
|
||||
}
|
||||
sound.setPan(data.soundID, pan, data.curVolume);
|
||||
}
|
||||
|
||||
data.volume = 0f;
|
||||
data.total = 0f;
|
||||
data.sum.setZero();
|
||||
});
|
||||
}
|
||||
|
||||
private class SoundData{
|
||||
float volume;
|
||||
float total;
|
||||
Vector2 sum = new Vector2();
|
||||
|
||||
int soundID;
|
||||
float curVolume;
|
||||
}
|
||||
}
|
@ -1,4 +0,0 @@
|
||||
package io.anuke.mindustry.game;
|
||||
|
||||
public class SoundControl{
|
||||
}
|
@ -25,7 +25,9 @@ public class MultiReqImage extends Stack{
|
||||
if(valid != null){
|
||||
valid.visible(true);
|
||||
}else{
|
||||
displays.get((int)(time) % displays.size).visible(true);
|
||||
if(displays.size > 0){
|
||||
displays.get((int)(time) % displays.size).visible(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -126,6 +126,7 @@ public class SettingsMenuDialog extends SettingsDialog{
|
||||
void addSettings(){
|
||||
sound.sliderPref("musicvol", bundle.get("setting.musicvol.name", "Music Volume"), 100, 0, 100, 1, i -> i + "%");
|
||||
sound.sliderPref("sfxvol", bundle.get("setting.sfxvol.name", "SFX Volume"), 100, 0, 100, 1, i -> i + "%");
|
||||
sound.sliderPref("ambientvol", bundle.get("setting.ambientvol.name", "Ambient Volume"), 100, 0, 100, 1, i -> i + "%");
|
||||
|
||||
game.screenshakePref();
|
||||
if(mobile){
|
||||
|
@ -101,7 +101,13 @@ public class Block extends BlockStorage{
|
||||
public boolean hasShadow = true;
|
||||
/** Sounds made when this block breaks.*/
|
||||
public Sound breakSound = Sounds.boom;
|
||||
/** The sound that this block makes while active.*/
|
||||
|
||||
/** The sound that this block makes while active. One sound loop. Do not overuse.*/
|
||||
public Sound activeSound = Sounds.none;
|
||||
/** Active sound base volume. */
|
||||
public float activeSoundVolume = 0.5f;
|
||||
|
||||
/** The sound that this block makes while idle. Uses one sound loop for all blocks.*/
|
||||
public Sound idleSound = Sounds.none;
|
||||
/** Idle sound base volume. */
|
||||
public float idleSoundVolume = 0.5f;
|
||||
@ -212,6 +218,11 @@ public class Block extends BlockStorage{
|
||||
return progressIncrease;
|
||||
}
|
||||
|
||||
/** @return whether this block should play its active sound.*/
|
||||
public boolean shouldActiveSound(Tile tile){
|
||||
return false;
|
||||
}
|
||||
|
||||
/** @return whether this block should play its idle sound.*/
|
||||
public boolean shouldIdleSound(Tile tile){
|
||||
return canProduce(tile);
|
||||
|
@ -105,7 +105,7 @@ public class LaserTurret extends PowerTurret{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldIdleSound(Tile tile){
|
||||
public boolean shouldActiveSound(Tile tile){
|
||||
LaserTurretEntity entity = tile.entity();
|
||||
|
||||
return entity.bulletLife > 0 && entity.bullet != null;
|
||||
|
@ -5,6 +5,7 @@ import io.anuke.mindustry.entities.*;
|
||||
import io.anuke.mindustry.entities.bullet.*;
|
||||
import io.anuke.mindustry.entities.effect.*;
|
||||
import io.anuke.mindustry.entities.type.*;
|
||||
import io.anuke.mindustry.gen.*;
|
||||
import io.anuke.mindustry.type.*;
|
||||
import io.anuke.mindustry.world.*;
|
||||
import io.anuke.mindustry.world.consumers.*;
|
||||
@ -19,6 +20,7 @@ public abstract class LiquidTurret extends Turret{
|
||||
public LiquidTurret(String name){
|
||||
super(name);
|
||||
hasLiquids = true;
|
||||
activeSound = Sounds.spray;
|
||||
}
|
||||
|
||||
/** Initializes accepted ammo map. Format: [liquid1, bullet1, liquid2, bullet2...] */
|
||||
@ -44,6 +46,12 @@ public abstract class LiquidTurret extends Turret{
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldActiveSound(Tile tile){
|
||||
TurretEntity entity = tile.entity();
|
||||
return entity.target != null && hasAmmo(tile);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean validateTarget(Tile tile){
|
||||
TurretEntity entity = tile.entity();
|
||||
@ -79,7 +87,7 @@ public abstract class LiquidTurret extends Turret{
|
||||
|
||||
Effects.effect(type.shootEffect, entity.liquids.current().color, tile.drawx() + tr.x, tile.drawy() + tr.y, entity.rotation);
|
||||
Effects.effect(type.smokeEffect, entity.liquids.current().color, tile.drawx() + tr.x, tile.drawy() + tr.y, entity.rotation);
|
||||
shootSound.at(tile);
|
||||
//shootSound.at(tile);
|
||||
|
||||
if(shootShake > 0){
|
||||
Effects.shake(shootShake, shootShake, tile.entity);
|
||||
|
@ -1,19 +1,17 @@
|
||||
package io.anuke.mindustry.world.blocks.distribution;
|
||||
|
||||
import io.anuke.arc.Core;
|
||||
import io.anuke.arc.collection.LongArray;
|
||||
import io.anuke.arc.graphics.g2d.Draw;
|
||||
import io.anuke.arc.graphics.g2d.TextureRegion;
|
||||
import io.anuke.arc.math.Mathf;
|
||||
import io.anuke.arc.*;
|
||||
import io.anuke.arc.collection.*;
|
||||
import io.anuke.arc.graphics.g2d.*;
|
||||
import io.anuke.arc.math.*;
|
||||
import io.anuke.arc.math.geom.*;
|
||||
import io.anuke.arc.util.*;
|
||||
import io.anuke.mindustry.entities.type.TileEntity;
|
||||
import io.anuke.mindustry.entities.type.Unit;
|
||||
import io.anuke.mindustry.graphics.Layer;
|
||||
import io.anuke.mindustry.input.InputHandler.PlaceDraw;
|
||||
import io.anuke.mindustry.type.Item;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.entities.type.*;
|
||||
import io.anuke.mindustry.gen.*;
|
||||
import io.anuke.mindustry.graphics.*;
|
||||
import io.anuke.mindustry.input.InputHandler.*;
|
||||
import io.anuke.mindustry.type.*;
|
||||
import io.anuke.mindustry.world.*;
|
||||
import io.anuke.mindustry.world.meta.*;
|
||||
|
||||
import java.io.*;
|
||||
@ -41,6 +39,9 @@ public class Conveyor extends Block{
|
||||
group = BlockGroup.transportation;
|
||||
hasItems = true;
|
||||
itemCapacity = 4;
|
||||
|
||||
idleSound = Sounds.conveyor;
|
||||
idleSoundVolume = 0.004f;
|
||||
}
|
||||
|
||||
private static int compareItems(long a, long b){
|
||||
@ -76,6 +77,12 @@ public class Conveyor extends Block{
|
||||
tilesize * entity.blendsclx, tilesize * entity.blendscly, rotation * 90);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldIdleSound(Tile tile){
|
||||
ConveyorEntity entity = tile.entity();
|
||||
return entity.clogHeat <= 0.5f ;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProximityUpdate(Tile tile){
|
||||
super.onProximityUpdate(tile);
|
||||
|
@ -10,6 +10,7 @@ import io.anuke.mindustry.content.*;
|
||||
import io.anuke.mindustry.entities.*;
|
||||
import io.anuke.mindustry.entities.Effects.*;
|
||||
import io.anuke.mindustry.entities.type.*;
|
||||
import io.anuke.mindustry.gen.*;
|
||||
import io.anuke.mindustry.graphics.*;
|
||||
import io.anuke.mindustry.type.*;
|
||||
import io.anuke.mindustry.ui.*;
|
||||
@ -65,8 +66,8 @@ public class Drill extends Block{
|
||||
liquidCapacity = 5f;
|
||||
hasItems = true;
|
||||
|
||||
//idleSound = Sounds.drill;
|
||||
//idleSoundVolume = 0.5f;
|
||||
idleSound = Sounds.drill;
|
||||
idleSoundVolume = 0.004f;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,21 +1,18 @@
|
||||
package io.anuke.mindustry.world.blocks.production;
|
||||
|
||||
import io.anuke.arc.function.Consumer;
|
||||
import io.anuke.arc.function.Supplier;
|
||||
import io.anuke.arc.graphics.g2d.TextureRegion;
|
||||
import io.anuke.arc.math.Mathf;
|
||||
import io.anuke.arc.util.Time;
|
||||
import io.anuke.mindustry.content.Fx;
|
||||
import io.anuke.mindustry.entities.Effects;
|
||||
import io.anuke.mindustry.entities.Effects.Effect;
|
||||
import io.anuke.mindustry.entities.type.TileEntity;
|
||||
import io.anuke.arc.function.*;
|
||||
import io.anuke.arc.graphics.g2d.*;
|
||||
import io.anuke.arc.math.*;
|
||||
import io.anuke.arc.util.*;
|
||||
import io.anuke.mindustry.content.*;
|
||||
import io.anuke.mindustry.entities.*;
|
||||
import io.anuke.mindustry.entities.Effects.*;
|
||||
import io.anuke.mindustry.entities.type.*;
|
||||
import io.anuke.mindustry.gen.*;
|
||||
import io.anuke.mindustry.type.*;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.consumers.ConsumeLiquidBase;
|
||||
import io.anuke.mindustry.world.consumers.ConsumeType;
|
||||
import io.anuke.mindustry.world.meta.BlockStat;
|
||||
import io.anuke.mindustry.world.meta.StatUnit;
|
||||
import io.anuke.mindustry.world.*;
|
||||
import io.anuke.mindustry.world.consumers.*;
|
||||
import io.anuke.mindustry.world.meta.*;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
@ -37,6 +34,8 @@ public class GenericCrafter extends Block{
|
||||
solid = true;
|
||||
hasItems = true;
|
||||
health = 60;
|
||||
idleSound = Sounds.machine;
|
||||
idleSoundVolume = 0.03f;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -58,6 +57,11 @@ public class GenericCrafter extends Block{
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldIdleSound(Tile tile){
|
||||
return tile.entity.cons.valid();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(){
|
||||
outputsLiquid = outputLiquid != null;
|
||||
|
@ -30,8 +30,8 @@ public class CoreBlock extends StorageBlock{
|
||||
update = true;
|
||||
hasItems = true;
|
||||
flags = EnumSet.of(BlockFlag.target, BlockFlag.producer);
|
||||
idleSound = Sounds.respawning;
|
||||
idleSoundVolume = 1f;
|
||||
activeSound = Sounds.respawning;
|
||||
activeSoundVolume = 1f;
|
||||
}
|
||||
|
||||
@Remote(called = Loc.server)
|
||||
@ -156,7 +156,7 @@ public class CoreBlock extends StorageBlock{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldIdleSound(Tile tile){
|
||||
public boolean shouldActiveSound(Tile tile){
|
||||
CoreEntity entity = tile.entity();
|
||||
|
||||
return entity.spawnPlayer != null;
|
||||
|
@ -1,5 +1 @@
|
||||
@Echo Off
|
||||
Set "JV="
|
||||
For /F "Tokens=3" %%A In ('java -version 2^>^&1') Do If Not Defined JV Set "JV=%%~A"
|
||||
If /I "%JV%"=="not" (Echo Java is not installed, this server requires Java to run.) Else (start java -jar server.jar)
|
||||
Pause
|
||||
java -jar server.jar
|
Loading…
Reference in New Issue
Block a user