Skip to content

Commit

Permalink
Removed string param from NemesisMusic RPC
Browse files Browse the repository at this point in the history
  • Loading branch information
Moffein committed Dec 10, 2023
1 parent 7dcdb24 commit c318950
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 18 deletions.
22 changes: 14 additions & 8 deletions Starstorm 2/Components/NemesisMusicController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ namespace Starstorm2Unofficial.Components
{
public class NemesisMusicController : NetworkBehaviour
{
public string soundName = "Play_SS2U_NemesisTheme";
private bool isPlaying = false;
private uint playID;

public void StartMusicServer(string soundName)
public void StartMusicServer()
{
if (!NetworkServer.active) return;
RpcStartMusic(soundName);
RpcStartMusic();
}

public void StopMusicServer()
Expand All @@ -22,12 +23,9 @@ public void StopMusicServer()
}

[ClientRpc]
private void RpcStartMusic(string soundName)
private void RpcStartMusic()
{
StopMusic();
isPlaying = true;
Modules.Music.musicSources++;
playID = Util.PlaySound(soundName, base.gameObject);
StartMusic();
}

[ClientRpc]
Expand All @@ -36,12 +34,20 @@ private void RpcStopMusic()
StopMusic();
}

private void StartMusic()
{
StopMusic();
isPlaying = true;
Modules.Music.musicSources++;
playID = Util.PlaySound(soundName, base.gameObject);
}

private void StopMusic()
{
if (!isPlaying) return;
isPlaying = false;
Modules.Music.musicSources--;
AkSoundEngine.StopPlayingID(this.playID);
AkSoundEngine.StopPlayingID(playID);
}

private void OnDestroy()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,15 +176,6 @@ IEnumerator SpawnNemesisServer(NemesisCard card, Xoroshiro128Plus rng)
});
}
yield return new WaitForSeconds(12f);

if (nemesisMusic)
{
NemesisMusicController nmc = nemesisMusic.GetComponent<NemesisMusicController>();
if (nmc)
{
nmc.StartMusicServer("Play_SS2U_NemesisTheme");
}
}
Transform spawnOnTarget = null;
DirectorCore.MonsterSpawnDistance input = DirectorCore.MonsterSpawnDistance.Far;
if (TeleporterInteraction.instance)
Expand Down Expand Up @@ -281,7 +272,17 @@ IEnumerator SpawnNemesisServer(NemesisCard card, Xoroshiro128Plus rng)
}));
GameObject spawnedObject = DirectorCore.instance.TrySpawnObject(directorSpawnRequest);

combatSquad.onDefeatedServer += StopNemesisMusic;


if (nemesisMusic)
{
NemesisMusicController nmc = nemesisMusic.GetComponent<NemesisMusicController>();
if (nmc)
{
nmc.StartMusicServer();
}
combatSquad.onDefeatedServer += StopNemesisMusic;
}

NetworkServer.Spawn(combatSquad.gameObject);
}
Expand Down
8 changes: 8 additions & 0 deletions Starstorm 2/Starstorm2-Unity/Assets/StreamingAssets.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified Starstorm 2/Starstorm2Release/VideogameMod2Unofficial.zip
Binary file not shown.
Binary file not shown.

0 comments on commit c318950

Please sign in to comment.