quantum-space-buddies/QSB/OrbSync/Messages/OrbSlotMessage.cs

27 lines
625 B
C#
Raw Normal View History

using Mirror;
using QSB.Messaging;
2021-12-23 09:50:09 +00:00
using QSB.OrbSync.WorldObjects;
2020-12-07 18:49:51 +00:00
2022-03-03 03:46:33 +00:00
namespace QSB.OrbSync.Messages;
2021-12-23 09:50:09 +00:00
2022-03-03 03:46:33 +00:00
public class OrbSlotMessage : QSBWorldObjectMessage<QSBOrb, int>
{
private bool _playAudio;
2021-12-23 09:50:09 +00:00
2022-03-11 01:57:50 +00:00
public OrbSlotMessage(int slotIndex, bool playAudio) : base(slotIndex) =>
2022-03-03 03:46:33 +00:00
_playAudio = playAudio;
2022-03-03 03:46:33 +00:00
public override void Serialize(NetworkWriter writer)
{
base.Serialize(writer);
writer.Write(_playAudio);
}
2022-03-03 03:46:33 +00:00
public override void Deserialize(NetworkReader reader)
{
base.Deserialize(reader);
_playAudio = reader.Read<bool>();
}
2022-03-03 03:46:33 +00:00
public override void OnReceiveRemote() => WorldObject.SetSlot(Data, _playAudio);
}