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>
|
|
|
|
|
{
|
2021-12-05 11:03:09 +00:00
|
|
|
|
public override bool RequireWorldObjectsReady => true;
|
2021-12-04 16:39:37 +00:00
|
|
|
|
|
2021-11-11 02:08:03 -08:00
|
|
|
|
public override void SetupListener()
|
2021-11-13 00:09:41 -08:00
|
|
|
|
=> GlobalMessenger<QSBMeteorLauncher>.AddListener(EventNames.QSBMeteorPreLaunch, Handler);
|
2021-11-11 02:08:03 -08:00
|
|
|
|
|
|
|
|
|
public override void CloseListener()
|
2021-11-13 00:09:41 -08:00
|
|
|
|
=> GlobalMessenger<QSBMeteorLauncher>.RemoveListener(EventNames.QSBMeteorPreLaunch, Handler);
|
2021-11-11 02:08:03 -08:00
|
|
|
|
|
2021-11-13 00:09:41 -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
|
|
|
|
{
|
2021-11-13 00:09:41 -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();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|