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

32 lines
1013 B
C#
Raw Normal View History

2021-11-11 02:08:03 -08:00
using QSB.Events;
using QSB.MeteorSync.WorldObjects;
using QSB.WorldSync;
using QSB.WorldSync.Events;
namespace QSB.MeteorSync.Events
{
public class MeteorPreLaunchEvent : QSBEvent<WorldObjectMessage>
{
public override bool RequireWorldObjectsReady => true;
2021-11-11 02:08:03 -08:00
public override void SetupListener()
=> GlobalMessenger<QSBMeteorLauncher>.AddListener(EventNames.QSBMeteorPreLaunch, Handler);
2021-11-11 02:08:03 -08:00
public override void CloseListener()
=> GlobalMessenger<QSBMeteorLauncher>.RemoveListener(EventNames.QSBMeteorPreLaunch, Handler);
2021-11-11 02:08:03 -08:00
private void Handler(QSBMeteorLauncher qsbMeteorLauncher) => SendEvent(CreateMessage(qsbMeteorLauncher));
2021-11-11 02:08:03 -08:00
2021-11-20 19:49:50 +00:00
private WorldObjectMessage CreateMessage(QSBMeteorLauncher qsbMeteorLauncher) => new()
2021-11-11 02:08:03 -08:00
{
ObjectId = qsbMeteorLauncher.ObjectId
2021-11-11 02:08:03 -08:00
};
public override void OnReceiveRemote(bool isHost, WorldObjectMessage message)
{
var qsbMeteorLauncher = QSBWorldSync.GetWorldFromId<QSBMeteorLauncher>(message.ObjectId);
qsbMeteorLauncher.PreLaunchMeteor();
}
}
}