quantum-space-buddies/QSB/EchoesOfTheEye/DreamWorld/Messages/EnterDreamWorldMessage.cs

37 lines
833 B
C#
Raw Normal View History

2022-03-26 02:34:21 +00:00
using QSB.ItemSync.WorldObjects.Items;
using QSB.Messaging;
using QSB.Player;
using QSB.Player.TransformSync;
using QSB.WorldSync;
namespace QSB.EchoesOfTheEye.DreamWorld.Messages;
2022-03-26 01:57:26 +00:00
/// <summary>
2022-03-26 02:34:21 +00:00
/// todo SendInitialState
2022-03-26 01:57:26 +00:00
/// </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;
}
}