Reset the secret woods music whenever it is entered

The game only does this before 1800, afterwards it is expected that no sound will play.
However, with this mod installed having silence 1800-2000 is a bit jarring, so we keep
the woods theme playing until 2000. We need to handle playing this in the time range
1800-2000.
This commit is contained in:
Strelkasaurus 2022-07-27 03:29:49 +02:00
parent d7e8314eb9
commit e7075c1c7d
2 changed files with 17 additions and 8 deletions

View file

@ -30,8 +30,11 @@ namespace SoundLoopMod
public override void Entry(IModHelper helper)
{
helper.Events.GameLoop.OneSecondUpdateTicking += this.CheckMusicNeedsRestarting;
helper.Events.Player.Warped += this.ResetMusicSecretWoods;
}
private const string WoodsName = "Woods";
private void CheckMusicNeedsRestarting(object? sender, OneSecondUpdateTickingEventArgs e)
{
// Don't do anything if we're at the title screen
@ -62,14 +65,9 @@ namespace SoundLoopMod
// Seems to be safe to touch the current song, check if it has finished
if (Game1.currentSong == null || Game1.currentSong.IsStopped || Game1.requestedMusicTrack.ToLower().Contains("ambient"))
{
if (Game1.currentLocation.Name == "Woods")
if (Game1.currentLocation.Name == WoodsName)
{
// The music for the secret woods is a bit of a special case.
// Handle this in a way similar to the game when entering the woods.
// The game doesn't start the woods song after 1800, do the same here
if (Game1.timeOfDay >= 1800)
return;
Game1.changeMusicTrack("woodsTheme");
}
else
@ -80,5 +78,16 @@ namespace SoundLoopMod
this.Monitor.Log("Restarted music");
}
}
private void ResetMusicSecretWoods(object? sender, WarpedEventArgs e)
{
// The game won't touch the music when entering the woods after 1800, causing the previously playing
// music to keep playing. Hence we stop it and let CheckMusicNeedsRestarting play the woods theme.
// However, after dark, let it keep playing the ambient night sound.
if (e.IsLocalPlayer && e.NewLocation.Name == WoodsName && !Game1.isDarkOut())
{
Game1.changeMusicTrack("none");
}
}
}
}

View file

@ -1,7 +1,7 @@
{
"Name": "SoundLoop Mod",
"Author": "strelkasaur",
"Version": "1.0.1-beta1",
"Version": "1.0.1-beta2",
"Description": "Loops the in-game music",
"UniqueID": "com.strelkasaurus.sm.soundloop",
"EntryDll": "SoundLoopMod.dll",