When player dies, check for nearby Jester music source to show Game Over text

This commit is contained in:
ivan tkachenko 2026-04-06 07:36:34 +03:00
parent 8561834e22
commit 3cdd99f57e
3 changed files with 28 additions and 1 deletions

View File

@ -8,7 +8,7 @@
- Added lyrics to the existing track HighLow. - Added lyrics to the existing track HighLow.
- New random track will be selected every time instead of having the same track all day. - New random track will be selected every time instead of having the same track all day.
- Groupped tracks (verses of the same song) are still played together in a sequence. - Groupped tracks (verses of the same song) are still played together in a sequence.
- Don't reset overridden Game Over text prematurely at the end of round. - Override Death Screen / Game Over text in more cases.
- Attempted to fix issue when Jester wouldn't select any track after the first one. - Attempted to fix issue when Jester wouldn't select any track after the first one.
## MuzikaGromche 1337.9001.68 - LocalHost hotfix ## MuzikaGromche 1337.9001.68 - LocalHost hotfix

View File

@ -1,4 +1,5 @@
using System.Collections; using System.Collections;
using GameNetcodeStuff;
using HarmonyLib; using HarmonyLib;
using TMPro; using TMPro;
using UnityEngine; using UnityEngine;
@ -73,4 +74,29 @@ namespace MuzikaGromche
DeathScreenGameOverTextManager.Clear(); DeathScreenGameOverTextManager.Clear();
} }
} }
[HarmonyPatch(typeof(PlayerControllerB))]
static class PlayerControllerBKillPlayerPatch
{
// Use prefix to test distance from listener before the listener is reassigned
[HarmonyPatch(nameof(PlayerControllerB.KillPlayer))]
[HarmonyPrefix]
static void KillPlayerPrefix(PlayerControllerB __instance)
{
if (__instance.IsOwner && !__instance.isPlayerDead && __instance.AllowPlayerDeath())
{
// KILL LOCAL PLAYER
var list = Object.FindObjectsByType<EnemyAI>(FindObjectsInactive.Exclude, FindObjectsSortMode.None);
foreach (var jester in list)
{
if (jester.TryGetComponent<MuzikaGromcheJesterNetworkBehaviour>(out var behaviour) &&
behaviour.IsPlaying && Plugin.LocalPlayerCanHearMusic(jester))
{
behaviour.OverrideDeathScreenGameOverText();
break;
}
}
}
}
}
} }

View File

@ -162,6 +162,7 @@ namespace MuzikaGromche
Harmony.PatchAll(typeof(DiscoBallDespawnPatch)); Harmony.PatchAll(typeof(DiscoBallDespawnPatch));
Harmony.PatchAll(typeof(SpawnRatePatch)); Harmony.PatchAll(typeof(SpawnRatePatch));
Harmony.PatchAll(typeof(DeathScreenGameOverTextResetPatch)); Harmony.PatchAll(typeof(DeathScreenGameOverTextResetPatch));
Harmony.PatchAll(typeof(PlayerControllerBKillPlayerPatch));
Harmony.PatchAll(typeof(ScreenFiltersManager.HUDManagerScreenFiltersPatch)); Harmony.PatchAll(typeof(ScreenFiltersManager.HUDManagerScreenFiltersPatch));
Harmony.PatchAll(typeof(ClearAudioClipCachePatch)); Harmony.PatchAll(typeof(ClearAudioClipCachePatch));
NetcodePatcher(); NetcodePatcher();