2021-12-30 15:53:10 -08:00
|
|
|
|
using QSB.Menus;
|
|
|
|
|
using QSB.Messaging;
|
2021-12-23 12:33:30 -08:00
|
|
|
|
using QSB.Player;
|
2021-12-23 12:38:14 -08:00
|
|
|
|
using QSB.Player.TransformSync;
|
2021-12-23 12:33:30 -08:00
|
|
|
|
using QSB.WorldSync;
|
|
|
|
|
|
2021-12-23 15:44:32 -08:00
|
|
|
|
namespace QSB.EyeOfTheUniverse.EyeStateSync.Messages
|
2021-12-23 12:33:30 -08:00
|
|
|
|
{
|
|
|
|
|
internal class EyeStateMessage : QSBEnumMessage<EyeState>
|
|
|
|
|
{
|
2021-12-26 00:53:43 -08:00
|
|
|
|
static EyeStateMessage() => GlobalMessenger<EyeState>.AddListener(OWEvents.EyeStateChanged, Handler);
|
2021-12-23 12:38:14 -08:00
|
|
|
|
|
|
|
|
|
private static void Handler(EyeState state)
|
|
|
|
|
{
|
2021-12-23 22:40:37 -08:00
|
|
|
|
if (PlayerTransformSync.LocalInstance)
|
2021-12-23 12:38:14 -08:00
|
|
|
|
{
|
|
|
|
|
new EyeStateMessage(state).Send();
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-12-23 12:33:30 -08:00
|
|
|
|
|
|
|
|
|
|
2021-12-23 14:27:41 -08:00
|
|
|
|
private EyeStateMessage(EyeState state) => Value = state;
|
2021-12-23 12:33:30 -08:00
|
|
|
|
|
|
|
|
|
public override bool ShouldReceive => WorldObjectManager.AllObjectsReady;
|
|
|
|
|
|
|
|
|
|
public override void OnReceiveLocal()
|
|
|
|
|
{
|
|
|
|
|
QSBPlayerManager.LocalPlayer.EyeState = Value;
|
2021-12-30 15:53:10 -08:00
|
|
|
|
MenuManager.Instance.OnEyeStateChange(Value);
|
2021-12-23 12:33:30 -08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void OnReceiveRemote()
|
|
|
|
|
{
|
|
|
|
|
var player = QSBPlayerManager.GetPlayer(From);
|
|
|
|
|
player.EyeState = Value;
|
2021-12-30 15:53:10 -08:00
|
|
|
|
MenuManager.Instance.OnEyeStateChange(Value);
|
2021-12-23 12:33:30 -08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|