Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 52 additions & 36 deletions BombRushRadio.csproj
Original file line number Diff line number Diff line change
@@ -1,39 +1,55 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net461</TargetFramework>
<AssemblyName>BombRushRadio</AssemblyName>
<Description>Allows adding custom music tracks to Bomb Rush Cyberfunk.</Description>
<Version>1.7</Version>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>11</LangVersion>
</PropertyGroup>

<PropertyGroup>
<ManagedPath>$(BRCPath)/Bomb Rush Cyberfunk_Data/Managed</ManagedPath>
</PropertyGroup>
<PropertyGroup>
<TargetFramework>net461</TargetFramework>
<AssemblyName>BombRushRadio</AssemblyName>
<Description>Allows adding custom music tracks to Bomb Rush Cyberfunk.</Description>
<Version>1.7</Version>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>11</LangVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BepInEx.Analyzers" Version="1.*" PrivateAssets="all" />
<PackageReference Include="BepInEx.AssemblyPublicizer.MSBuild" Version="0.4.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="BepInEx.Core" Version="5.*" />
<PackageReference Include="BepInEx.PluginInfoProps" Version="1.*" />
<PackageReference Include="UnityEngine.Modules" Version="2021.3.27" IncludeAssets="compile" />
<PackageReference Include="TagLibSharp" Version="2.3.0" />
</ItemGroup>

<ItemGroup>
<Reference Include="Assembly-CSharp">
<HintPath>$(ManagedPath)/Assembly-CSharp.dll</HintPath>
<Private>false</Private>
<Publicize>true</Publicize>
</Reference>
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework.TrimEnd(`0123456789`))' == 'net'">
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.2" PrivateAssets="all" />
</ItemGroup>
</Project>
<!-- Debug configuration -->
<PropertyGroup Condition="'$(Configuration)' == 'Debug'">
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<DebugSymbols>true</DebugSymbols>
<Optimize>false</Optimize>
</PropertyGroup>

<!-- Release configuration -->
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
<DefineConstants>TRACE</DefineConstants>
<DebugType>none</DebugType>
<DebugSymbols>false</DebugSymbols>
<Optimize>true</Optimize>
</PropertyGroup>

<PropertyGroup>
<ManagedPath>$(BRCPath)/Bomb Rush Cyberfunk_Data/Managed</ManagedPath>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BepInEx.Analyzers" Version="1.*" PrivateAssets="all"/>
<PackageReference Include="BepInEx.AssemblyPublicizer.MSBuild" Version="0.4.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="BepInEx.Core" Version="5.*"/>
<PackageReference Include="BepInEx.PluginInfoProps" Version="1.*"/>
<PackageReference Include="UnityEngine.Modules" Version="2021.3.27" IncludeAssets="compile"/>
<PackageReference Include="TagLibSharp" Version="2.3.0"/>
</ItemGroup>

<ItemGroup>
<Reference Include="Assembly-CSharp">
<HintPath>$(ManagedPath)/Assembly-CSharp.dll</HintPath>
<Private>false</Private>
<Publicize>true</Publicize>
</Reference>
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework.TrimEnd(`0123456789`))' == 'net'">
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.2" PrivateAssets="all"/>
</ItemGroup>
</Project>
71 changes: 52 additions & 19 deletions Patches/MusicPlayer-Patches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Reptile;
using Reptile.Phone;
using System;
using System.Collections.Generic;
using UnityEngine;

namespace BombRushRadio;
Expand Down Expand Up @@ -61,34 +62,48 @@ public static void Refresh(MusicPlayer __instance, ChapterMusic chapterMusic, St
{
__instance.musicTrackQueue.ClearTracks();

Story.ObjectiveInfo currentObjectiveInfo = Story.GetCurrentObjectiveInfo();
if (stage == Stage.hideout)
if (!BombRushRadio.RemoveBaseGameSongs.Value)
{
MusicTrack musicTrackByID = Core.Instance.AudioManager.MusicLibraryPlayer.GetMusicTrackByID(MusicTrackID.Hideout_Mixtape);
__instance.AddMusicTrack(musicTrackByID);
Debug.Log("[BRR] [BASE-GAME] Added " + musicTrackByID.Title + " to the total list.");
Story.ObjectiveInfo currentObjectiveInfo = Story.GetCurrentObjectiveInfo();
if (stage == Stage.hideout)
{
MusicTrack musicTrackByID = Core.Instance.AudioManager.MusicLibraryPlayer.GetMusicTrackByID(MusicTrackID.Hideout_Mixtape);
__instance.AddMusicTrack(musicTrackByID);
Debug.Log("[BRR] [BASE-GAME] Added " + musicTrackByID.Title + " to the total list.");
}
else
{
MusicTrack chapterMusic2 = chapterMusic.GetChapterMusic(currentObjectiveInfo.chapter);
__instance.AddMusicTrack(chapterMusic2);
Debug.Log("[BRR] [BASE-GAME] Added " + chapterMusic2.Title + " to the total list.");
}
AUnlockable[] unlockables = WorldHandler.instance.GetCurrentPlayer().phone.GetAppInstance<AppMusicPlayer>().Unlockables;
for (int i = 0; i < unlockables.Length; i++)
{
var musicTrack = unlockables[i] as MusicTrack;
if (Core.Instance.Platform.User.GetUnlockableSaveDataFor(musicTrack).IsUnlocked)
{
musicTrack.isRepeatable = false;
__instance.AddMusicTrack(musicTrack);
Debug.Log("[BRR] [BASE-GAME] Added " + musicTrack.Title + " to the total list.");
}
}
}
else
{
MusicTrack chapterMusic2 = chapterMusic.GetChapterMusic(currentObjectiveInfo.chapter);
__instance.AddMusicTrack(chapterMusic2);
Debug.Log("[BRR] [BASE-GAME] Added " + chapterMusic2.Title + " to the total list.");
Debug.Log("[BRR] Base game songs removed per config setting.");
}
AUnlockable[] unlockables = WorldHandler.instance.GetCurrentPlayer().phone.GetAppInstance<AppMusicPlayer>().Unlockables;
for (int i = 0; i < unlockables.Length; i++)

var existingTracks = new HashSet<string>();
foreach (var track in __instance.musicTrackQueue.currentMusicTracks)
{
var musicTrack = unlockables[i] as MusicTrack;
if (Core.Instance.Platform.User.GetUnlockableSaveDataFor(musicTrack).IsUnlocked)
{
musicTrack.isRepeatable = false;
__instance.AddMusicTrack(musicTrack);
Debug.Log("[BRR] [BASE-GAME] Added " + musicTrack.Title + " to the total list.");
}
existingTracks.Add($"{track.Artist}|{track.Title}");
}

foreach (MusicTrack track in BombRushRadio.Audios)
{
if (__instance.musicTrackQueue.currentMusicTracks.Find(m => m.Title == track.Title && m.Artist == track.Artist) != null)
string trackKey = $"{track.Artist}|{track.Title}";
if (existingTracks.Contains(trackKey))
{
continue;
}
Expand Down Expand Up @@ -124,7 +139,8 @@ public class MusicTrackQueue_Patches
{
static bool Prefix(MusicTrack musicTrack) // ignore unlocking for custom stuff
{
if (BombRushRadio.Audios.Find(m => musicTrack.Artist == m.Artist && musicTrack.Title == m.Title))
string trackKey = $"{musicTrack.Artist}|{musicTrack.Title}";
if (BombRushRadio.AudioLookup.ContainsKey(trackKey))
{
return false;
}
Expand Down Expand Up @@ -177,3 +193,20 @@ static void Prefix(MusicPlayer __instance)
__instance.ForcePaused();
}
}

[HarmonyPatch(typeof(MusicPlayer), nameof(MusicPlayer.EvaluateRepeatingMusicTrack))]
public class MusicPlayer_Patches_EvaluateRepeatingMusicTrack
{
static void Postfix(ref bool __result)
{
if (BombRushRadio.Skipping)
{
Debug.Log($"[BRR] EvaluateRepeatingMusicTrack - was {__result}, forcing to false because skipping");
}

if (BombRushRadio.Skipping)
{
__result = false;
}
}
}
8 changes: 4 additions & 4 deletions Patches/MusicPlayerBuffer-Patches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace BombRushRadio;
[HarmonyPatch(typeof(MusicPlayerBuffer), nameof(MusicPlayerBuffer.BufferMusicTrack))]
public class MusicPlayerBuffer_BufferMusicTrack_Patches
{
static bool Prefix(MusicPlayerBuffer __instance, MusicTrack musicTrackToLoad) // the the game to not unload our files please lol
static bool Prefix(MusicPlayerBuffer __instance, MusicTrack musicTrackToLoad) // tell the game to not unload our files please lol
{
if (musicTrackToLoad == null || musicTrackToLoad.AudioClip == null)
{
Expand All @@ -28,11 +28,11 @@ static bool Prefix(MusicPlayerBuffer __instance, MusicTrack musicTrackToLoad) //
[HarmonyPatch(typeof(MusicPlayerBuffer), nameof(MusicPlayerBuffer.UnloadMusicPlayerData))]
public class MusicPlayerBuffer_Patches
{
static bool Prefix(MusicPlayerData musicPlayerData) // the the game to not unload our files please lol
static bool Prefix(MusicPlayerData musicPlayerData) // tell the game to not unload our files please lol
{
MusicTrack t = BombRushRadio.Audios.Find(m => musicPlayerData.Artist == m.Artist && musicPlayerData.Title == m.Title);
string trackKey = $"{musicPlayerData.Artist}|{musicPlayerData.Title}";

if (t != null)
if (BombRushRadio.AudioLookup.ContainsKey(trackKey))
{
return false;
}
Expand Down
Loading