mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-30 21:32:47 +00:00
37 lines
1.1 KiB
C#
37 lines
1.1 KiB
C#
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 EventType Type => EventType.MeteorPreLaunch;
|
|
|
|
public override void SetupListener()
|
|
=> GlobalMessenger<QSBMeteorLauncher>.AddListener(EventNames.QSBMeteorPreLaunch, Handler);
|
|
|
|
public override void CloseListener()
|
|
=> GlobalMessenger<QSBMeteorLauncher>.RemoveListener(EventNames.QSBMeteorPreLaunch, Handler);
|
|
|
|
private void Handler(QSBMeteorLauncher qsbMeteorLauncher) => SendEvent(CreateMessage(qsbMeteorLauncher));
|
|
|
|
private WorldObjectMessage CreateMessage(QSBMeteorLauncher qsbMeteorLauncher) => new WorldObjectMessage
|
|
{
|
|
ObjectId = qsbMeteorLauncher.ObjectId
|
|
};
|
|
|
|
public override void OnReceiveRemote(bool isHost, WorldObjectMessage message)
|
|
{
|
|
if (!MeteorManager.Ready)
|
|
{
|
|
return;
|
|
}
|
|
|
|
var qsbMeteorLauncher = QSBWorldSync.GetWorldFromId<QSBMeteorLauncher>(message.ObjectId);
|
|
qsbMeteorLauncher.PreLaunchMeteor();
|
|
}
|
|
}
|
|
}
|