2021-12-23 20:33:30 +00:00
|
|
|
|
using QSB.Events;
|
|
|
|
|
using QSB.Messaging;
|
|
|
|
|
using QSB.Player;
|
2021-12-23 20:38:14 +00:00
|
|
|
|
using QSB.Player.TransformSync;
|
2021-12-23 20:33:30 +00:00
|
|
|
|
using QSB.WorldSync;
|
|
|
|
|
|
|
|
|
|
namespace QSB.EyeOfTheUniverse.EyeStateSync.Events
|
|
|
|
|
{
|
|
|
|
|
internal class EyeStateMessage : QSBEnumMessage<EyeState>
|
|
|
|
|
{
|
2021-12-23 20:38:14 +00:00
|
|
|
|
static EyeStateMessage() => GlobalMessenger<EyeState>.AddListener(EventNames.EyeStateChanged, Handler);
|
|
|
|
|
|
|
|
|
|
private static void Handler(EyeState state)
|
|
|
|
|
{
|
|
|
|
|
if (PlayerTransformSync.LocalInstance != null)
|
|
|
|
|
{
|
|
|
|
|
new EyeStateMessage(state).Send();
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-12-23 20:33:30 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public EyeStateMessage(EyeState state) => Value = state;
|
|
|
|
|
|
|
|
|
|
public EyeStateMessage() { }
|
|
|
|
|
|
|
|
|
|
public override bool ShouldReceive => WorldObjectManager.AllObjectsReady;
|
|
|
|
|
|
|
|
|
|
public override void OnReceiveLocal()
|
|
|
|
|
{
|
|
|
|
|
QSBPlayerManager.LocalPlayer.EyeState = Value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void OnReceiveRemote()
|
|
|
|
|
{
|
|
|
|
|
var player = QSBPlayerManager.GetPlayer(From);
|
|
|
|
|
player.EyeState = Value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|