quantum-space-buddies/QSB/EchoesOfTheEye/DreamWorld/Messages/EnterDreamWorldMessage.cs
2022-03-26 10:14:55 -07:00

43 lines
1.0 KiB
C#

using QSB.ItemSync.WorldObjects.Items;
using QSB.Messaging;
using QSB.Player;
using QSB.Player.TransformSync;
using QSB.PlayerBodySetup.Remote;
using QSB.WorldSync;
namespace QSB.EchoesOfTheEye.DreamWorld.Messages;
/// <summary>
/// todo SendInitialState
/// </summary>
internal 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 OnReceiveRemote()
{
var player = QSBPlayerManager.GetPlayer(From);
player.InDreamWorld = true;
player.AssignedSimulationLantern = WorldObject;
// do the spawn shader
player.SetVisible(false);
player.SetVisible(true, DreamWorldSpawnAnimator.DREAMWORLD_SPAWN_TIME);
player.DreamWorldSpawnAnimator.StartSpawnEffect();
}
}