diff --git a/annotations/src/main/java/mindustry/annotations/impl/AssetsProcess.java b/annotations/src/main/java/mindustry/annotations/impl/AssetsProcess.java index 64b12ca33d..acad282be2 100644 --- a/annotations/src/main/java/mindustry/annotations/impl/AssetsProcess.java +++ b/annotations/src/main/java/mindustry/annotations/impl/AssetsProcess.java @@ -184,6 +184,7 @@ public class AssetsProcess extends BaseProcessor{ if(classname.equals("Sounds")){ type.addField(FieldSpec.builder(ClassName.bestGuess(rtype), "none", Modifier.STATIC, Modifier.PUBLIC).initializer("new " + rtype + "()").build()); + type.addField(FieldSpec.builder(ClassName.bestGuess(rtype), "unset", Modifier.STATIC, Modifier.PUBLIC).initializer("new " + rtype + "()").build()); } type.addMethod(loadBegin.build()); diff --git a/core/assets/sounds/rockBreak.ogg b/core/assets/sounds/rockBreak.ogg index 6a17a5edc2..90eb5fa097 100644 Binary files a/core/assets/sounds/rockBreak.ogg and b/core/assets/sounds/rockBreak.ogg differ diff --git a/core/assets/sounds/shootPayload.ogg b/core/assets/sounds/shootPayload.ogg new file mode 100644 index 0000000000..08715f1a5d Binary files /dev/null and b/core/assets/sounds/shootPayload.ogg differ diff --git a/core/assets/sounds/unitCreate.ogg b/core/assets/sounds/unitCreate.ogg new file mode 100644 index 0000000000..ba12fc4bff Binary files /dev/null and b/core/assets/sounds/unitCreate.ogg differ diff --git a/core/assets/sounds/unitCreateBig.ogg b/core/assets/sounds/unitCreateBig.ogg new file mode 100644 index 0000000000..5dccb757a5 Binary files /dev/null and b/core/assets/sounds/unitCreateBig.ogg differ diff --git a/core/assets/sounds/bang.ogg b/core/assets/sounds/unitExplode1.ogg similarity index 100% rename from core/assets/sounds/bang.ogg rename to core/assets/sounds/unitExplode1.ogg diff --git a/core/assets/sounds/unitExplode2.ogg b/core/assets/sounds/unitExplode2.ogg new file mode 100644 index 0000000000..a4b5a00b89 Binary files /dev/null and b/core/assets/sounds/unitExplode2.ogg differ diff --git a/core/assets/sounds/unitExplode3.ogg b/core/assets/sounds/unitExplode3.ogg new file mode 100644 index 0000000000..99294608df Binary files /dev/null and b/core/assets/sounds/unitExplode3.ogg differ diff --git a/core/assets/sounds/wreckFall.ogg b/core/assets/sounds/wreckFall.ogg new file mode 100644 index 0000000000..1865ee11f2 Binary files /dev/null and b/core/assets/sounds/wreckFall.ogg differ diff --git a/core/assets/sounds/wreckFallBig.ogg b/core/assets/sounds/wreckFallBig.ogg new file mode 100644 index 0000000000..83fc33a10b Binary files /dev/null and b/core/assets/sounds/wreckFallBig.ogg differ diff --git a/core/src/mindustry/content/Blocks.java b/core/src/mindustry/content/Blocks.java index 81801ee679..a133f59029 100644 --- a/core/src/mindustry/content/Blocks.java +++ b/core/src/mindustry/content/Blocks.java @@ -6253,6 +6253,7 @@ public class Blocks{ consumePower(13f); consumeItems(with(Items.silicon, 850, Items.titanium, 750, Items.plastanium, 650)); consumeLiquid(Liquids.cryofluid, 1f); + createSound = Sounds.unitCreateBig; constructTime = 60f * 60f * 1.5f; liquidCapacity = 60f; @@ -6278,6 +6279,7 @@ public class Blocks{ constructTime = 60f * 60f * 4; liquidCapacity = 180f; + createSound = Sounds.unitCreateBig; upgrades.addAll( new UnitType[]{UnitTypes.antumbra, UnitTypes.eclipse}, diff --git a/core/src/mindustry/content/UnitTypes.java b/core/src/mindustry/content/UnitTypes.java index b1279caaeb..314d167fa3 100644 --- a/core/src/mindustry/content/UnitTypes.java +++ b/core/src/mindustry/content/UnitTypes.java @@ -1037,6 +1037,7 @@ public class UnitTypes{ omniMovement = false; rotateSpeed = 5f; circleTargetRadius = 60f; + wreckSoundVolume = 0.7f; weapons.add(new Weapon(){{ y = 1f; @@ -1323,6 +1324,7 @@ public class UnitTypes{ range = 50f; isEnemy = false; controlSelectGlobal = false; + wreckSoundVolume = deathSoundVolume = 0.7f; ammoType = new PowerAmmoType(500); @@ -1348,6 +1350,7 @@ public class UnitTypes{ ammoType = new PowerAmmoType(900); mineTier = 2; mineSpeed = 3.5f; + wreckSoundVolume = 0.9f; abilities.add(new RepairFieldAbility(5f, 60f * 8, 50f)); @@ -2445,6 +2448,8 @@ public class UnitTypes{ engineOffset = 6f; hitSize = 8f; alwaysUnlocked = true; + wreckSoundVolume = 0.8f; + deathSoundVolume = 0.7f; weapons.add(new Weapon("small-basic-weapon"){{ reload = 17f; diff --git a/core/src/mindustry/entities/comp/UnitComp.java b/core/src/mindustry/entities/comp/UnitComp.java index f66efa3cac..f747ab9cb3 100644 --- a/core/src/mindustry/entities/comp/UnitComp.java +++ b/core/src/mindustry/entities/comp/UnitComp.java @@ -854,7 +854,7 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I Effect.scorch(x, y, (int)(hitSize / 5)); } Effect.shake(shake, shake, this); - type.deathSound.at(this); + type.deathSound.at(this, 1f, type.deathSoundVolume); Events.fire(new UnitDestroyEvent(self())); @@ -935,6 +935,8 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I //don't waste time when the unit is already on the ground, just destroy it if(!type.flying || !type.createWreck){ destroy(); + }else{ + type.wreckSound.at(this, 1f, type.wreckSoundVolume); } } diff --git a/core/src/mindustry/entities/units/AIController.java b/core/src/mindustry/entities/units/AIController.java index edd33ba595..9ca7908990 100644 --- a/core/src/mindustry/entities/units/AIController.java +++ b/core/src/mindustry/entities/units/AIController.java @@ -380,7 +380,7 @@ public class AIController implements UnitController{ if(arrive && length > 0){ Tmp.v3.set(-unit.vel.x / unit.type.accel * 2f, -unit.vel.y / unit.type.accel * 2f).add((target.getX() - unit.x), (target.getY() - unit.y)); - if(unit.type.omniMovement){ + if(unit.type.omniMovement || unit.type.rotateMoveFirst){ vec.add(Tmp.v3).limit(speed * length); }else{ //directly move the unit to prevent a backwards movement vector from messing things up diff --git a/core/src/mindustry/type/UnitType.java b/core/src/mindustry/type/UnitType.java index ddf216e494..a63cc459a8 100644 --- a/core/src/mindustry/type/UnitType.java +++ b/core/src/mindustry/type/UnitType.java @@ -295,7 +295,13 @@ public class UnitType extends UnlockableContent implements Senseable{ /** override for unit shield colour. */ public @Nullable Color shieldColor; /** sound played when this unit explodes (*not* when it is shot down) */ - public Sound deathSound = Sounds.bang; + public Sound deathSound = Sounds.unset; + /** volume of death sound */ + public float deathSoundVolume = 1f; + /** sound played when the unit wreck is shot down */ + public Sound wreckSound = Sounds.unset; + /** volume of wreck falling sound */ + public float wreckSoundVolume = 1f; /** sound played on loop when this unit is around. */ public Sound loopSound = Sounds.none; /** volume of loop sound */ @@ -897,6 +903,17 @@ public class UnitType extends UnlockableContent implements Senseable{ envEnabled |= Env.space; } + if(deathSound == Sounds.unset){ + deathSound = + hitSize < 12f ? Sounds.unitExplode1 : + hitSize < 22f ? Sounds.unitExplode2 : + Sounds.unitExplode3; + } + + if(wreckSound == Sounds.unset){ + wreckSound = hitSize >= 22f ? Sounds.wreckFallBig : Sounds.wreckFall; + } + if(lightRadius == -1){ lightRadius = Math.max(60f, hitSize * 2.3f); } diff --git a/core/src/mindustry/world/blocks/payloads/PayloadVoid.java b/core/src/mindustry/world/blocks/payloads/PayloadVoid.java index 78e77fcb7d..18826c2251 100644 --- a/core/src/mindustry/world/blocks/payloads/PayloadVoid.java +++ b/core/src/mindustry/world/blocks/payloads/PayloadVoid.java @@ -9,7 +9,7 @@ import mindustry.graphics.*; public class PayloadVoid extends PayloadBlock{ public Effect incinerateEffect = Fx.blastExplosion; - public Sound incinerateSound = Sounds.bang; + public Sound incinerateSound = Sounds.unitExplode1; public PayloadVoid(String name){ super(name); diff --git a/core/src/mindustry/world/blocks/units/Reconstructor.java b/core/src/mindustry/world/blocks/units/Reconstructor.java index 2ae3d90095..fbeded3ca7 100644 --- a/core/src/mindustry/world/blocks/units/Reconstructor.java +++ b/core/src/mindustry/world/blocks/units/Reconstructor.java @@ -3,6 +3,7 @@ package mindustry.world.blocks.units; import arc.*; import arc.Graphics.*; import arc.Graphics.Cursor.*; +import arc.audio.*; import arc.graphics.g2d.*; import arc.math.*; import arc.math.geom.*; @@ -34,6 +35,9 @@ public class Reconstructor extends UnitBlock{ public Seq upgrades = new Seq<>(); public int[] capacities = {}; + public Sound createSound = Sounds.unitCreate; + public float createSoundVolume = 1f; + public Reconstructor(String name){ super(name); regionRotated1 = 1; @@ -324,6 +328,7 @@ public class Reconstructor extends UnitBlock{ payload.unit.command().command(command == null && payload.unit.type.defaultCommand != null ? payload.unit.type.defaultCommand : command); } + createSound.at(this, 1f + Mathf.range(0.06f), createSoundVolume); progress %= 1f; Effect.shake(2f, 3f, this); Fx.producesmoke.at(this); diff --git a/core/src/mindustry/world/blocks/units/UnitAssembler.java b/core/src/mindustry/world/blocks/units/UnitAssembler.java index 8fca9282e2..25b0dbb95a 100644 --- a/core/src/mindustry/world/blocks/units/UnitAssembler.java +++ b/core/src/mindustry/world/blocks/units/UnitAssembler.java @@ -1,6 +1,7 @@ package mindustry.world.blocks.units; import arc.*; +import arc.audio.*; import arc.graphics.*; import arc.graphics.g2d.*; import arc.math.*; @@ -45,6 +46,9 @@ public class UnitAssembler extends PayloadBlock{ public Seq plans = new Seq<>(4); + public Sound createSound = Sounds.unitCreateBig; + public float createSoundVolume = 1f; + protected @Nullable ConsumePayloadDynamic consPayload; protected @Nullable ConsumeItemDynamic consItem; @@ -60,6 +64,8 @@ public class UnitAssembler extends PayloadBlock{ group = BlockGroup.units; commandable = true; quickRotate = false; + ambientSound = Sounds.respawning; + ambientSoundVolume = 0.13f; } public Rect getRect(Rect rect, float x, float y, int rotation){ @@ -536,8 +542,10 @@ public class UnitAssembler extends PayloadBlock{ Units.notifyUnitSpawn(unit); } + createSound.at(spawn.x, spawn.y, 1f + Mathf.range(0.06f), createSoundVolume); + progress = 0f; - Fx.unitAssemble.at(spawn.x, spawn.y, 0f, plan.unit); + Fx.unitAssemble.at(spawn.x, spawn.y, rotdeg() - 90f, plan.unit); blocks.clear(); } @@ -662,6 +670,7 @@ public class UnitAssembler extends PayloadBlock{ float rot = payload.angleTo(spawn); Fx.shootPayloadDriver.at(payload.x(), payload.y(), rot); Fx.payloadDeposit.at(payload.x(), payload.y(), rot, new YeetData(spawn.cpy(), payload.content())); + Sounds.shootPayload.at(x, y, 1f + Mathf.range(0.1f), 1f); } @Override diff --git a/core/src/mindustry/world/blocks/units/UnitFactory.java b/core/src/mindustry/world/blocks/units/UnitFactory.java index 2ce911b2c0..250c403fbd 100644 --- a/core/src/mindustry/world/blocks/units/UnitFactory.java +++ b/core/src/mindustry/world/blocks/units/UnitFactory.java @@ -1,6 +1,7 @@ package mindustry.world.blocks.units; import arc.*; +import arc.audio.*; import arc.graphics.*; import arc.graphics.g2d.*; import arc.math.*; @@ -34,6 +35,8 @@ public class UnitFactory extends UnitBlock{ public int[] capacities = {}; public Seq plans = new Seq<>(4); + public Sound createSound = Sounds.unitCreate; + public float createSoundVolume = 1f; public UnitFactory(String name){ super(name); @@ -417,6 +420,7 @@ public class UnitFactory extends UnitBlock{ unit.command().command(command == null && unit.type.defaultCommand != null ? unit.type.defaultCommand : command); } + createSound.at(this, 1f + Mathf.range(0.06f), createSoundVolume); payload = new UnitPayload(unit); payVector.setZero(); consume();