65 lines
1.6 KiB
C#
Raw Normal View History

using QSB.EchoesOfTheEye.DreamLantern.WorldObjects;
2022-10-10 22:23:44 -07:00
using QSB.EchoesOfTheEye.Ghosts.WorldObjects;
using QSB.Messaging;
using QSB.Player;
using QSB.Player.TransformSync;
2022-03-26 14:17:40 +00:00
using QSB.PlayerBodySetup.Remote;
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>
2023-07-28 19:30:57 +01:00
public class EnterDreamWorldMessage : QSBWorldObjectMessage<QSBDreamLanternItem>
{
static EnterDreamWorldMessage()
{
GlobalMessenger.AddListener(OWEvents.EnterDreamWorld, () =>
{
if (!PlayerTransformSync.LocalInstance)
{
return;
}
Locator.GetDreamWorldController()
.GetPlayerLantern()
.GetWorldObject<QSBDreamLanternItem>()
.SendMessage(new EnterDreamWorldMessage());
});
}
public override void OnReceiveLocal()
{
var player = QSBPlayerManager.LocalPlayer;
player.InDreamWorld = true;
player.AssignedSimulationLantern = WorldObject;
2022-05-27 05:39:12 +01:00
foreach (var ghost in QSBWorldSync.GetWorldObjects<QSBGhostBrain>())
{
2022-05-27 05:39:12 +01:00
ghost.OnEnterDreamWorld(player);
}
}
public override void OnReceiveRemote()
{
var player = QSBPlayerManager.GetPlayer(From);
player.InDreamWorld = true;
player.AssignedSimulationLantern = WorldObject;
2022-03-26 14:17:40 +00:00
// do the spawn shader
2022-03-26 10:14:55 -07:00
player.SetVisible(false);
2022-03-26 14:17:40 +00:00
player.SetVisible(true, DreamWorldSpawnAnimator.DREAMWORLD_SPAWN_TIME);
player.DreamWorldSpawnAnimator.StartSpawnEffect();
2022-05-16 21:38:02 +01:00
if (QSBCore.IsHost)
{
foreach (var ghost in QSBWorldSync.GetWorldObjects<QSBGhostBrain>())
{
ghost.OnEnterDreamWorld(player);
2022-05-27 05:59:10 +01:00
ghost.GetEffects().OnSectorOccupantsUpdated();
2022-05-16 21:38:02 +01:00
}
}
}
}