quantum-space-buddies/QSB/QuantumSync/Messages/EyeProxyMoonStateChangeMessage.cs

41 lines
892 B
C#
Raw Normal View History

using Mirror;
using QSB.Messaging;
2021-12-24 15:25:13 +00:00
using QSB.QuantumSync.WorldObjects;
using UnityEngine;
2022-03-03 03:46:33 +00:00
namespace QSB.QuantumSync.Messages;
2023-07-28 18:30:57 +00:00
public class EyeProxyMoonStateChangeMessage : QSBWorldObjectMessage<QSBEyeProxyQuantumMoon>
2021-12-24 15:25:13 +00:00
{
2022-03-03 03:46:33 +00:00
private bool Active;
private float Angle;
2021-12-24 15:25:13 +00:00
2022-03-03 03:46:33 +00:00
public EyeProxyMoonStateChangeMessage(bool active, float angle)
{
Active = active;
Angle = angle;
}
2021-12-24 15:25:13 +00:00
2022-03-03 03:46:33 +00:00
public override void Serialize(NetworkWriter writer)
{
base.Serialize(writer);
writer.Write(Active);
writer.Write(Angle);
}
2022-03-03 03:46:33 +00:00
public override void Deserialize(NetworkReader reader)
{
base.Deserialize(reader);
Active = reader.Read<bool>();
Angle = reader.Read<float>();
}
2022-03-03 03:46:33 +00:00
public override void OnReceiveRemote()
{
WorldObject.AttachedObject._moonStateRoot.SetActive(Active);
if (Angle != -1f)
2021-12-24 15:25:13 +00:00
{
2022-03-03 03:46:33 +00:00
WorldObject.AttachedObject.transform.localEulerAngles = new Vector3(0f, Angle, 0f);
2021-12-24 15:25:13 +00:00
}
}
}