31 lines
1.1 KiB
C#
Raw Normal View History

2021-02-28 14:43:05 +00:00
using QSB.Events;
using UnityEngine;
namespace QSB.StatueSync.Events
{
2021-02-28 15:29:09 +00:00
internal class StartStatueEvent : QSBEvent<StartStatueMessage>
2021-02-28 14:43:05 +00:00
{
public override QSB.Events.EventType Type => QSB.Events.EventType.StartStatue;
2021-02-28 15:29:09 +00:00
public override void SetupListener()
2021-02-28 14:43:05 +00:00
=> GlobalMessenger<Vector3, Quaternion, float>.AddListener(EventNames.QSBStartStatue, Handler);
2021-02-28 15:29:09 +00:00
public override void CloseListener()
2021-02-28 14:43:05 +00:00
=> GlobalMessenger<Vector3, Quaternion, float>.RemoveListener(EventNames.QSBStartStatue, Handler);
2021-02-28 15:29:09 +00:00
private void Handler(Vector3 position, Quaternion rotation, float degrees)
2021-02-28 14:43:05 +00:00
=> SendEvent(CreateMessage(position, rotation, degrees));
private StartStatueMessage CreateMessage(Vector3 position, Quaternion rotation, float degrees) => new StartStatueMessage
{
AboutId = LocalPlayerId,
PlayerPosition = position,
PlayerRotation = rotation,
CameraDegrees = degrees
};
2021-02-28 15:29:09 +00:00
public override void OnReceiveRemote(bool server, StartStatueMessage message)
2021-02-28 14:43:05 +00:00
=> StatueManager.Instance.BeginSequence(message.PlayerPosition, message.PlayerRotation, message.CameraDegrees);
}
}