Skip to content

Commit

Permalink
Adjust song unlocking so that it works better when you get multiple m…
Browse files Browse the repository at this point in the history
…usic sheets in a row.
  • Loading branch information
DeamonHunter committed Mar 16, 2023
1 parent 90fde16 commit 6179c98
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
14 changes: 10 additions & 4 deletions ArchipelagoMuseDash/Archipelago/ItemHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,8 @@ IMuseDashItem GetItemFromNetworkItem(NetworkItem item, bool otherPlayersItem) {
return new ExternalItem(name, playerName) { Item = item };
}

if (name == MusicSheetItemName) {
if (CurrentNumberOfMusicSheets + 1 >= NumberOfMusicSheetsToWin)
return new SongItem(GoalSong);
if (name == MusicSheetItemName)
return new MusicSheetItem() { Item = item };
}

if (ArchipelagoStatic.AlbumDatabase.TryGetMusicInfo(name, out var singularInfo))
return new SongItem(singularInfo) { Item = item };
Expand All @@ -167,6 +164,15 @@ IMuseDashItem GetItemFromNetworkItem(NetworkItem item, bool otherPlayersItem) {

public void AddMusicSheet() {
CurrentNumberOfMusicSheets++;

if (CurrentNumberOfMusicSheets < NumberOfMusicSheetsToWin || UnlockedSongUids.Contains(GoalSong.uid))
return;

ArchipelagoStatic.ArchLogger.LogDebug("ItemHandler", "Force unlocking the goal song as we reached the goal.");

UnlockSong(GoalSong);
MusicTagManager.instance.RefreshDBDisplayMusics();
ArchipelagoStatic.SongSelectPanel?.RefreshMusicFSV();
}

public MusicInfo GetRandomUnfinishedSong() {
Expand Down
8 changes: 8 additions & 0 deletions ArchipelagoMuseDash/Archipelago/ItemUnlockHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,14 @@ void ShowItem(IMuseDashItem item) {
if (_unlockingItem != null)
throw new Exception("Tried to unlock an item while one was already unlocking.");

if (item is MusicSheetItem) {
var handler = ArchipelagoStatic.SessionHandler.ItemHandler;

if (handler.CurrentNumberOfMusicSheets + 1 == handler.NumberOfMusicSheetsToWin)
item = new SongItem(handler.GoalSong);
}


_unlockingItem = item;
_hasUnlockedItem = false;

Expand Down
2 changes: 1 addition & 1 deletion ArchipelagoMuseDash/ArchipelagoMuseDashMod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using MelonLoader;
using UnityEngine;

[assembly: MelonInfo(typeof(ArchipelagoMuseDashMod), "Archipelago Muse Dash", "0.7.0", "DeamonHunter")]
[assembly: MelonInfo(typeof(ArchipelagoMuseDashMod), "Archipelago Muse Dash", "0.7.2", "DeamonHunter")]
[assembly: MelonGame("PeroPeroGames", "MuseDash")]

namespace ArchipelagoMuseDash {
Expand Down

0 comments on commit 6179c98

Please sign in to comment.