2021-12-23 21:49:04 +00:00
|
|
|
|
using OWML.Common;
|
|
|
|
|
using QSB.Animation.NPC.WorldObjects;
|
2021-12-29 11:30:54 +00:00
|
|
|
|
using QSB.EyeOfTheUniverse.VesselSync;
|
2021-12-23 21:49:04 +00:00
|
|
|
|
using QSB.Messaging;
|
|
|
|
|
using QSB.Player.TransformSync;
|
|
|
|
|
using QSB.PoolSync;
|
|
|
|
|
using QSB.ShipSync;
|
|
|
|
|
using QSB.Utility;
|
|
|
|
|
using QSB.WorldSync;
|
|
|
|
|
using QuantumUNET.Transport;
|
|
|
|
|
|
2021-12-23 21:49:47 +00:00
|
|
|
|
namespace QSB.Player.Messages
|
2021-12-23 21:49:04 +00:00
|
|
|
|
{
|
|
|
|
|
internal class EnterLeaveMessage : QSBEnumMessage<EnterLeaveType>
|
|
|
|
|
{
|
|
|
|
|
static EnterLeaveMessage()
|
|
|
|
|
{
|
2021-12-26 08:53:43 +00:00
|
|
|
|
GlobalMessenger.AddListener(OWEvents.PlayerEnterQuantumMoon, () => Handler(EnterLeaveType.EnterMoon));
|
|
|
|
|
GlobalMessenger.AddListener(OWEvents.PlayerExitQuantumMoon, () => Handler(EnterLeaveType.ExitMoon));
|
|
|
|
|
GlobalMessenger.AddListener(OWEvents.EnterShip, () => Handler(EnterLeaveType.EnterShip));
|
|
|
|
|
GlobalMessenger.AddListener(OWEvents.ExitShip, () => Handler(EnterLeaveType.ExitShip));
|
2021-12-23 21:49:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void Handler(EnterLeaveType type, int objectId = -1)
|
|
|
|
|
{
|
2021-12-24 06:40:37 +00:00
|
|
|
|
if (PlayerTransformSync.LocalInstance)
|
2021-12-23 21:49:04 +00:00
|
|
|
|
{
|
|
|
|
|
new EnterLeaveMessage(type, objectId).Send();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private int ObjectId;
|
|
|
|
|
|
|
|
|
|
public EnterLeaveMessage(EnterLeaveType type, int objectId = -1)
|
|
|
|
|
{
|
|
|
|
|
Value = type;
|
|
|
|
|
ObjectId = objectId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void Serialize(QNetworkWriter writer)
|
|
|
|
|
{
|
|
|
|
|
base.Serialize(writer);
|
|
|
|
|
writer.Write(ObjectId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void Deserialize(QNetworkReader reader)
|
|
|
|
|
{
|
|
|
|
|
base.Deserialize(reader);
|
|
|
|
|
ObjectId = reader.ReadInt32();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override bool ShouldReceive => WorldObjectManager.AllObjectsReady;
|
|
|
|
|
|
|
|
|
|
public override void OnReceiveLocal() => OnReceiveRemote();
|
|
|
|
|
|
|
|
|
|
public override void OnReceiveRemote()
|
|
|
|
|
{
|
|
|
|
|
var player = QSBPlayerManager.GetPlayer(From);
|
|
|
|
|
switch (Value)
|
|
|
|
|
{
|
|
|
|
|
case EnterLeaveType.EnterMoon:
|
|
|
|
|
player.IsInMoon = true;
|
|
|
|
|
break;
|
|
|
|
|
case EnterLeaveType.ExitMoon:
|
|
|
|
|
player.IsInMoon = false;
|
|
|
|
|
break;
|
|
|
|
|
case EnterLeaveType.EnterShrine:
|
|
|
|
|
player.IsInShrine = true;
|
|
|
|
|
break;
|
|
|
|
|
case EnterLeaveType.ExitShrine:
|
|
|
|
|
player.IsInShrine = false;
|
|
|
|
|
break;
|
|
|
|
|
case EnterLeaveType.EnterPlatform:
|
|
|
|
|
CustomNomaiRemoteCameraPlatform.CustomPlatformList[ObjectId]
|
|
|
|
|
.OnRemotePlayerEnter(From);
|
|
|
|
|
break;
|
|
|
|
|
case EnterLeaveType.ExitPlatform:
|
|
|
|
|
CustomNomaiRemoteCameraPlatform.CustomPlatformList[ObjectId]
|
|
|
|
|
.OnRemotePlayerExit(From);
|
|
|
|
|
break;
|
|
|
|
|
case EnterLeaveType.EnterNonNomaiHeadZone:
|
2021-12-26 06:37:20 +00:00
|
|
|
|
ObjectId.GetWorldObject<QSBCharacterAnimController>().AddPlayerToHeadZone(player);
|
2021-12-23 21:49:04 +00:00
|
|
|
|
break;
|
|
|
|
|
case EnterLeaveType.ExitNonNomaiHeadZone:
|
2021-12-26 06:37:20 +00:00
|
|
|
|
ObjectId.GetWorldObject<QSBCharacterAnimController>().RemovePlayerFromHeadZone(player);
|
2021-12-23 21:49:04 +00:00
|
|
|
|
break;
|
|
|
|
|
case EnterLeaveType.EnterNomaiHeadZone:
|
2021-12-26 06:37:20 +00:00
|
|
|
|
ObjectId.GetWorldObject<QSBSolanumAnimController>().AddPlayerToHeadZone(player);
|
2021-12-23 21:49:04 +00:00
|
|
|
|
break;
|
|
|
|
|
case EnterLeaveType.ExitNomaiHeadZone:
|
2021-12-26 06:37:20 +00:00
|
|
|
|
ObjectId.GetWorldObject<QSBSolanumAnimController>().RemovePlayerFromHeadZone(player);
|
2021-12-23 21:49:04 +00:00
|
|
|
|
break;
|
|
|
|
|
case EnterLeaveType.EnterShip:
|
|
|
|
|
ShipManager.Instance.AddPlayerToShip(player);
|
|
|
|
|
break;
|
|
|
|
|
case EnterLeaveType.ExitShip:
|
|
|
|
|
ShipManager.Instance.RemovePlayerFromShip(player);
|
|
|
|
|
break;
|
2021-12-29 11:30:54 +00:00
|
|
|
|
case EnterLeaveType.EnterVesselCage:
|
|
|
|
|
VesselManager.Instance.Enter(player);
|
|
|
|
|
break;
|
|
|
|
|
case EnterLeaveType.ExitVesselCage:
|
|
|
|
|
VesselManager.Instance.Exit(player);
|
|
|
|
|
break;
|
2021-12-23 21:49:04 +00:00
|
|
|
|
default:
|
|
|
|
|
DebugLog.ToConsole($"Warning - Unknown EnterLeaveType : {Value}", MessageType.Warning);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|