mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-29 09:32:38 +00:00
32 lines
935 B
C#
32 lines
935 B
C#
using QSB.Events;
|
|
using QSB.MeteorSync.WorldObjects;
|
|
using QSB.WorldSync;
|
|
using QSB.WorldSync.Events;
|
|
|
|
namespace QSB.MeteorSync.Events
|
|
{
|
|
public class MeteorSpecialImpactEvent : QSBEvent<WorldObjectMessage>
|
|
{
|
|
public override bool RequireWorldObjectsReady => true;
|
|
|
|
public override void SetupListener()
|
|
=> GlobalMessenger<QSBMeteor>.AddListener(EventNames.QSBMeteorSpecialImpact, Handler);
|
|
|
|
public override void CloseListener()
|
|
=> GlobalMessenger<QSBMeteor>.RemoveListener(EventNames.QSBMeteorSpecialImpact, Handler);
|
|
|
|
private void Handler(QSBMeteor qsbMeteor) => SendEvent(CreateMessage(qsbMeteor));
|
|
|
|
private WorldObjectMessage CreateMessage(QSBMeteor qsbMeteor) => new()
|
|
{
|
|
ObjectId = qsbMeteor.ObjectId
|
|
};
|
|
|
|
public override void OnReceiveRemote(bool isHost, WorldObjectMessage message)
|
|
{
|
|
var qsbMeteor = QSBWorldSync.GetWorldFromId<QSBMeteor>(message.ObjectId);
|
|
qsbMeteor.SpecialImpact();
|
|
}
|
|
}
|
|
}
|