49 lines
994 B
C#
Raw Normal View History

2022-05-16 21:38:02 +01:00
using QSB.EchoesOfTheEye.Ghosts.WorldObjects;
using QSB.Messaging;
using QSB.Player;
using QSB.Player.TransformSync;
2022-05-16 21:38:02 +01:00
using QSB.WorldSync;
namespace QSB.EchoesOfTheEye.DreamWorld.Messages;
2022-03-25 18:57:26 -07:00
/// <summary>
2022-03-25 19:34:21 -07:00
/// todo SendInitialState
2022-03-25 18:57:26 -07:00
/// </summary>
internal class ExitDreamWorldMessage : QSBMessage
{
static ExitDreamWorldMessage()
{
GlobalMessenger.AddListener(OWEvents.ExitDreamWorld, () =>
{
if (!PlayerTransformSync.LocalInstance)
{
return;
}
new ExitDreamWorldMessage().Send();
});
}
2022-03-28 15:57:31 -07:00
public override void OnReceiveLocal()
{
var player = QSBPlayerManager.LocalPlayer;
player.InDreamWorld = false;
player.AssignedSimulationLantern = null;
}
public override void OnReceiveRemote()
{
var player = QSBPlayerManager.GetPlayer(From);
player.InDreamWorld = false;
player.AssignedSimulationLantern = null;
2022-05-16 21:38:02 +01:00
if (QSBCore.IsHost)
{
foreach (var ghost in QSBWorldSync.GetWorldObjects<QSBGhostBrain>())
{
ghost.OnExitDreamWorld();
}
}
}
}