Skip to content

Commit

Permalink
Unit Sound (unbiased)
Browse files Browse the repository at this point in the history
  • Loading branch information
WilloIzCitron committed May 15, 2024
1 parent 195257d commit 70b5000
Show file tree
Hide file tree
Showing 10 changed files with 54 additions and 3 deletions.
Binary file added assets/sounds/units/tecta-arrival1.ogg
Binary file not shown.
Binary file added assets/sounds/units/tecta-arrival2.ogg
Binary file not shown.
Binary file added assets/sounds/units/tecta-death.ogg
Binary file not shown.
Binary file added assets/sounds/units/tecta-hit1.ogg
Binary file not shown.
Binary file added assets/sounds/units/tecta-hit2.ogg
Binary file not shown.
Binary file added assets/sounds/units/tecta-hit3.ogg
Binary file not shown.
Binary file added assets/sounds/units/tecta-pickup.ogg
Binary file not shown.
Binary file added assets/sprites-override/effect/error.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 2 additions & 3 deletions src/bluearchive/ArchiveDustry.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package bluearchive;

import arc.*;
import arc.assets.loaders.MusicLoader;
import arc.audio.*;
import arc.scene.style.Drawable;
import arc.scene.style.TextureRegionDrawable;
Expand All @@ -10,7 +9,6 @@
import arc.scene.utils.Elem;
import arc.util.*;
import bluearchive.ui.*;
import mindustry.audio.SoundControl;
import mindustry.gen.*;
import mindustry.game.EventType.*;
import mindustry.mod.*;
Expand Down Expand Up @@ -109,7 +107,7 @@ public ArchiveDustry() {
currentPlay.stop();
}
Time.run(306f, () -> {
tree.loadMusic("win").stop();
Reflect.invoke(tree.loadMusic("win"), "silence");
Time.clear();
});
});
Expand All @@ -119,6 +117,7 @@ public void init(){
if(Core.settings.getBool("ba-addHalo", true)) {
UnitHalo.init();
}
UnitSound.init();
if (!Core.graphics.isPortrait() && Core.settings.getBool("enableL2D", true)) {
switch (Core.settings.getInt("setL2D")) {
case 1:
Expand Down
52 changes: 52 additions & 0 deletions src/bluearchive/units/UnitSound.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package bluearchive.units;

import arc.*;
import arc.audio.Sound;
import arc.struct.Seq;
import arc.util.Interval;
import arc.util.Log;
import arc.util.Time;
import mindustry.content.UnitTypes;
import mindustry.game.EventType;
import mindustry.game.EventType.*;
import mindustry.Vars;
import mindustry.gen.Unit;


public class UnitSound {
public static Seq<Sound> arrivalSound = Seq.with();
public static Seq<Sound> hitSound = Seq.with();
protected static Sound lastSound;
protected static Sound currentSound;
static Interval hitInterval = new Interval(5);
public static void init() {
// tecta atlas start
Events.on(UnitUnloadEvent.class, e -> {
if (e.unit.type == Vars.content.unit("tecta")) {
arrivalSound = Seq.with(new Sound(Vars.tree.get("sounds/units/tecta-arrival1.ogg")), new Sound(Vars.tree.get("sounds/units/tecta-arrival2.ogg")));
arrivalSound.random().play();
}
});
Events.on(PickupEvent.class, e -> {
if (e.unit.type == Vars.content.unit("tecta")) {
Sound pickedSound = new Sound(Vars.tree.get("sounds/units/tecta-pickup.ogg"));
pickedSound.play();
}
});
Events.on(UnitDamageEvent.class, e -> {
/* Check if the unit is same as intended, hit sound was being interval */
if (e.unit.type == Vars.content.unit("tecta") && hitInterval.get(300)) {
hitSound = Seq.with(new Sound(Vars.tree.get("sounds/units/tecta-hit1.ogg")), new Sound(Vars.tree.get("sounds/units/tecta-hit2.ogg")), new Sound(Vars.tree.get("sounds/units/tecta-hit3.ogg")));
if (!e.unit.dead) {
Time.run(0f, () -> {
hitSound.random().play();
});
}
}
});
UnitTypes.tecta.deathSound = new Sound(Vars.tree.get("sounds/units/tecta-death.ogg"));
// tecta atlas end

Log.infoTag("ArchiveDustry", "Unit Sounds Loaded!");
}
}

0 comments on commit 70b5000

Please sign in to comment.