2022-01-13 23:38:45 -08:00
|
|
|
|
using Mirror;
|
|
|
|
|
using QSB.ClientServerStateSync;
|
2022-02-05 02:50:13 -08:00
|
|
|
|
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-02-27 04:40:44 -08:00
|
|
|
|
|
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-02-24 22:04:54 -08:00
|
|
|
|
|
2022-03-02 19:46:33 -08:00
|
|
|
|
public override void OnReceiveRemote()
|
|
|
|
|
{
|
|
|
|
|
if (QSBCore.IsHost)
|
2022-02-27 04:40:44 -08:00
|
|
|
|
{
|
2022-03-02 19:46:33 -08:00
|
|
|
|
new ServerStateMessage(ServerState.InStatueCutscene).Send();
|
2022-02-27 04:40:44 -08:00
|
|
|
|
}
|
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
|
|
|
|
}
|