mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-29 09:32:38 +00:00
32 lines
1013 B
C#
32 lines
1013 B
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 bool RequireWorldObjectsReady => true;
|
|
|
|
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()
|
|
{
|
|
ObjectId = qsbMeteorLauncher.ObjectId
|
|
};
|
|
|
|
public override void OnReceiveRemote(bool isHost, WorldObjectMessage message)
|
|
{
|
|
var qsbMeteorLauncher = QSBWorldSync.GetWorldFromId<QSBMeteorLauncher>(message.ObjectId);
|
|
qsbMeteorLauncher.PreLaunchMeteor();
|
|
}
|
|
}
|
|
}
|