quantum-space-buddies/QSB/StatueSync/Events/StartStatueEvent.cs
Mister_Nebula 85bb0f9716 cleanup
2021-02-28 15:29:09 +00:00

31 lines
1.1 KiB
C#

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