quantum-space-buddies/QSB/MeteorSync/Events/MeteorLaunchMessage.cs

37 lines
873 B
C#
Raw Normal View History

2021-12-23 01:24:57 -08:00
using QSB.Messaging;
using QSB.MeteorSync.WorldObjects;
2021-11-11 02:08:03 -08:00
using QuantumUNET.Transport;
namespace QSB.MeteorSync.Events
{
2021-12-23 01:24:57 -08:00
public class MeteorLaunchMessage : QSBWorldObjectMessage<QSBMeteorLauncher>
2021-11-11 02:08:03 -08:00
{
2021-12-23 01:24:57 -08:00
private int MeteorId;
private float LaunchSpeed;
public MeteorLaunchMessage(QSBMeteorLauncher qsbMeteorLauncher)
{
MeteorId = qsbMeteorLauncher.MeteorId;
LaunchSpeed = qsbMeteorLauncher.LaunchSpeed;
}
public MeteorLaunchMessage() { }
2021-11-11 02:08:03 -08:00
public override void Deserialize(QNetworkReader reader)
{
base.Deserialize(reader);
2021-11-12 22:34:28 -08:00
MeteorId = reader.ReadInt32();
2021-11-11 02:08:03 -08:00
LaunchSpeed = reader.ReadSingle();
}
public override void Serialize(QNetworkWriter writer)
{
base.Serialize(writer);
2021-11-12 22:34:28 -08:00
writer.Write(MeteorId);
2021-11-11 02:08:03 -08:00
writer.Write(LaunchSpeed);
}
2021-12-23 01:24:57 -08:00
public override void OnReceiveRemote() => WorldObject.LaunchMeteor(MeteorId, LaunchSpeed);
2021-11-11 02:08:03 -08:00
}
}