v2.2.0: fixed various minor hiccups with new music system

This commit is contained in:
Evan Debenham
2023-09-25 10:22:22 -04:00
parent 41602afd8c
commit 5d16bf99b0
3 changed files with 32 additions and 21 deletions

View File

@@ -193,6 +193,8 @@ public enum Music {
private synchronized void play(String track, com.badlogic.gdx.audio.Music.OnCompletionListener listener){ private synchronized void play(String track, com.badlogic.gdx.audio.Music.OnCompletionListener listener){
try { try {
fadeTime = fadeTotal = -1;
player = Gdx.audio.newMusic(Gdx.files.internal(track)); player = Gdx.audio.newMusic(Gdx.files.internal(track));
player.setLooping(looping); player.setLooping(looping);
player.setVolume(volumeWithFade()); player.setVolume(volumeWithFade());

View File

@@ -31,6 +31,7 @@ import com.shatteredpixel.shatteredpixeldungeon.effects.CellEmitter;
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.ElmoParticle; import com.shatteredpixel.shatteredpixeldungeon.effects.particles.ElmoParticle;
import com.shatteredpixel.shatteredpixeldungeon.items.Heap; import com.shatteredpixel.shatteredpixeldungeon.items.Heap;
import com.shatteredpixel.shatteredpixeldungeon.items.Item; import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.levels.PrisonLevel;
import com.shatteredpixel.shatteredpixeldungeon.levels.RegularLevel; import com.shatteredpixel.shatteredpixeldungeon.levels.RegularLevel;
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.quest.RitualSiteRoom; import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.quest.RitualSiteRoom;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene; import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
@@ -187,6 +188,10 @@ public class CeremonialCandle extends Item {
elemental.state = elemental.HUNTING; elemental.state = elemental.HUNTING;
GameScene.add(elemental, 1); GameScene.add(elemental, 1);
if (Dungeon.level instanceof PrisonLevel){
((PrisonLevel) Dungeon.level).updateWandmakerQuestMusic();
}
for (int i : PathFinder.NEIGHBOURS9){ for (int i : PathFinder.NEIGHBOURS9){
CellEmitter.get(ritualPos+i).burst(ElmoParticle.FACTORY, 10); CellEmitter.get(ritualPos+i).burst(ElmoParticle.FACTORY, 10);
} }

View File

@@ -138,33 +138,37 @@ public class PrisonLevel extends RegularLevel {
1, 1, 1, 1, 1, 1 }; 1, 1, 1, 1, 1, 1 };
} }
private Boolean wandmakerQuestWasActive = null;
@Override @Override
public void occupyCell(Char ch) { public void occupyCell(Char ch) {
super.occupyCell(ch); super.occupyCell(ch);
if (ch == Dungeon.hero) { if (ch == Dungeon.hero) {
if (wandmakerQuestWasActive == null) { updateWandmakerQuestMusic();
wandmakerQuestWasActive = Wandmaker.Quest.active(); }
return; }
}
if (Wandmaker.Quest.active() != wandmakerQuestWasActive) {
wandmakerQuestWasActive = Wandmaker.Quest.active();
Game.runOnRenderThread(new Callback() { private Boolean wandmakerQuestWasActive = null;
@Override
public void call() { public void updateWandmakerQuestMusic(){
Music.INSTANCE.fadeOut(1f, new Callback() { if (wandmakerQuestWasActive == null) {
@Override wandmakerQuestWasActive = Wandmaker.Quest.active();
public void call() { return;
if (Dungeon.level != null) { }
Dungeon.level.playLevelMusic(); if (Wandmaker.Quest.active() != wandmakerQuestWasActive) {
} wandmakerQuestWasActive = Wandmaker.Quest.active();
Game.runOnRenderThread(new Callback() {
@Override
public void call() {
Music.INSTANCE.fadeOut(1f, new Callback() {
@Override
public void call() {
if (Dungeon.level != null) {
Dungeon.level.playLevelMusic();
} }
}); }
} });
}); }
} });
} }
} }