fix ghost animators

This commit is contained in:
Mister_Nebula 2022-05-27 05:56:17 +01:00
parent 8733e9f758
commit 77387ffb2a
3 changed files with 23 additions and 0 deletions

View File

@ -5,6 +5,7 @@ using QSB.Player;
using QSB.Player.TransformSync; using QSB.Player.TransformSync;
using QSB.PlayerBodySetup.Remote; using QSB.PlayerBodySetup.Remote;
using QSB.WorldSync; using QSB.WorldSync;
using System.Linq;
namespace QSB.EchoesOfTheEye.DreamWorld.Messages; namespace QSB.EchoesOfTheEye.DreamWorld.Messages;
@ -57,6 +58,11 @@ internal class EnterDreamWorldMessage : QSBWorldObjectMessage<QSBDreamLanternIte
foreach (var ghost in QSBWorldSync.GetWorldObjects<QSBGhostBrain>()) foreach (var ghost in QSBWorldSync.GetWorldObjects<QSBGhostBrain>())
{ {
ghost.OnEnterDreamWorld(player); ghost.OnEnterDreamWorld(player);
if (QSBPlayerManager.PlayerList.Count(x => x.InDreamWorld) == 1)
{
ghost.GetEffects().OnSectorOccupantsUpdated();
}
} }
} }
} }

View File

@ -3,6 +3,7 @@ using QSB.Messaging;
using QSB.Player; using QSB.Player;
using QSB.Player.TransformSync; using QSB.Player.TransformSync;
using QSB.WorldSync; using QSB.WorldSync;
using System.Linq;
namespace QSB.EchoesOfTheEye.DreamWorld.Messages; namespace QSB.EchoesOfTheEye.DreamWorld.Messages;
@ -47,6 +48,11 @@ internal class ExitDreamWorldMessage : QSBMessage
foreach (var ghost in QSBWorldSync.GetWorldObjects<QSBGhostBrain>()) foreach (var ghost in QSBWorldSync.GetWorldObjects<QSBGhostBrain>())
{ {
ghost.OnExitDreamWorld(player); ghost.OnExitDreamWorld(player);
if (QSBPlayerManager.PlayerList.Count(x => x.InDreamWorld) == 0)
{
ghost.GetEffects().OnSectorOccupantsUpdated();
}
} }
} }
} }

View File

@ -1,6 +1,7 @@
using HarmonyLib; using HarmonyLib;
using QSB.EchoesOfTheEye.Ghosts.WorldObjects; using QSB.EchoesOfTheEye.Ghosts.WorldObjects;
using QSB.Patches; using QSB.Patches;
using QSB.Player;
using QSB.Utility; using QSB.Utility;
using QSB.WorldSync; using QSB.WorldSync;
using System; using System;
@ -69,4 +70,14 @@ internal class GhostEffectsPatches : QSBPatch
__instance.GetWorldObject<QSBGhostEffects>().Update_Effects(); __instance.GetWorldObject<QSBGhostEffects>().Update_Effects();
return false; return false;
} }
[HarmonyPrefix]
[HarmonyPatch(nameof(GhostEffects.OnSectorOccupantsUpdated))]
public static bool OnSectorOccupantsUpdated(GhostEffects __instance)
{
__instance._animator.enabled = __instance._sector.ContainsAnyOccupants(DynamicOccupant.Player | DynamicOccupant.Probe)
|| QSBPlayerManager.PlayerList.Any(x => x.InDreamWorld);
return false;
}
} }