58 lines
1.3 KiB
C#
Raw Normal View History

using Mirror;
using QSB.ClientServerStateSync;
using QSB.ClientServerStateSync.Messages;
2021-12-25 16:10:41 -08:00
using QSB.Messaging;
using QSB.WorldSync;
2021-02-28 14:43:05 +00:00
using UnityEngine;
2022-03-02 19:46:33 -08:00
namespace QSB.StatueSync.Messages;
2023-07-28 19:30:57 +01:00
public class StartStatueMessage : QSBMessage
2021-02-28 14:43:05 +00:00
{
2022-03-02 19:46:33 -08:00
private Vector3 PlayerPosition;
private Quaternion PlayerRotation;
private float CameraDegrees;
2021-12-25 16:10:41 -08:00
2022-03-02 19:46:33 -08:00
public StartStatueMessage(Vector3 position, Quaternion rotation, float degrees)
{
PlayerPosition = position;
PlayerRotation = rotation;
CameraDegrees = degrees;
}
2021-12-25 16:10:41 -08:00
2022-03-02 19:46:33 -08:00
public override void Serialize(NetworkWriter writer)
{
base.Serialize(writer);
writer.Write(PlayerPosition);
writer.Write(PlayerRotation);
writer.Write(CameraDegrees);
}
2021-12-25 16:10:41 -08:00
2022-03-02 19:46:33 -08:00
public override void Deserialize(NetworkReader reader)
{
base.Deserialize(reader);
PlayerPosition = reader.ReadVector3();
PlayerRotation = reader.ReadQuaternion();
CameraDegrees = reader.Read<float>();
}
2021-12-25 16:10:41 -08:00
2022-03-02 19:46:33 -08:00
public override bool ShouldReceive => QSBWorldSync.AllObjectsReady;
2022-03-02 19:46:33 -08:00
public override void OnReceiveLocal()
{
if (QSBCore.IsHost)
2021-12-25 16:10:41 -08:00
{
2022-03-02 19:46:33 -08:00
new ServerStateMessage(ServerState.InStatueCutscene).Send();
2021-12-25 16:10:41 -08:00
}
2022-03-02 19:46:33 -08:00
}
2022-03-02 19:46:33 -08:00
public override void OnReceiveRemote()
{
if (QSBCore.IsHost)
{
2022-03-02 19:46:33 -08:00
new ServerStateMessage(ServerState.InStatueCutscene).Send();
}
2022-03-02 19:46:33 -08:00
StatueManager.Instance.BeginSequence(PlayerPosition, PlayerRotation, CameraDegrees);
2021-02-28 14:43:05 +00:00
}
2021-12-25 16:10:41 -08:00
}