quantum-space-buddies/QSB/StatueSync/Messages/StartStatueMessage.cs

58 lines
1.4 KiB
C#
Raw Normal View History

using Mirror;
using QSB.ClientServerStateSync;
2021-12-26 00:10:41 +00:00
using QSB.Messaging;
using QSB.WorldSync;
2021-02-28 14:43:05 +00:00
using UnityEngine;
namespace QSB.StatueSync.Messages
2021-02-28 14:43:05 +00:00
{
2021-12-26 00:10:41 +00:00
internal class StartStatueMessage : QSBMessage
2021-02-28 14:43:05 +00:00
{
2021-12-26 00:10:41 +00:00
private Vector3 PlayerPosition;
private Quaternion PlayerRotation;
private float CameraDegrees;
2021-02-28 14:43:05 +00:00
2021-12-26 00:10:41 +00:00
public StartStatueMessage(Vector3 position, Quaternion rotation, float degrees)
2021-02-28 14:43:05 +00:00
{
2021-12-26 00:10:41 +00:00
PlayerPosition = position;
PlayerRotation = rotation;
CameraDegrees = degrees;
2021-02-28 14:43:05 +00:00
}
public override void Serialize(NetworkWriter writer)
2021-02-28 14:43:05 +00:00
{
base.Serialize(writer);
writer.Write(PlayerPosition);
writer.Write(PlayerRotation);
writer.Write(CameraDegrees);
}
2021-12-26 00:10:41 +00:00
public override void Deserialize(NetworkReader reader)
2021-12-26 00:10:41 +00:00
{
base.Deserialize(reader);
PlayerPosition = reader.ReadVector3();
PlayerRotation = reader.ReadQuaternion();
CameraDegrees = reader.Read<float>();
2021-12-26 00:10:41 +00:00
}
public override bool ShouldReceive => QSBWorldSync.AllObjectsReady;
2021-12-26 00:10:41 +00:00
public override void OnReceiveLocal()
{
if (QSBCore.IsHost)
{
ServerStateManager.Instance.SendChangeServerStateMessage(ServerState.InStatueCutscene);
}
}
public override void OnReceiveRemote()
{
if (QSBCore.IsHost)
{
ServerStateManager.Instance.SendChangeServerStateMessage(ServerState.InStatueCutscene);
}
StatueManager.Instance.BeginSequence(PlayerPosition, PlayerRotation, CameraDegrees);
}
2021-02-28 14:43:05 +00:00
}
2021-12-26 00:10:41 +00:00
}