mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-29 18:32:45 +00:00
32 lines
1.0 KiB
C#
32 lines
1.0 KiB
C#
using QSB.Events;
|
|
using QSB.WorldSync;
|
|
using QSB.WorldSync.Events;
|
|
using QSB.ZeroGCaveSync.WorldObjects;
|
|
|
|
namespace QSB.ZeroGCaveSync.Events
|
|
{
|
|
internal class SatelliteNodeRepaired : QSBEvent<WorldObjectMessage>
|
|
{
|
|
public override void SetupListener() => GlobalMessenger<SatelliteNode>.AddListener(EventNames.QSBSatelliteRepaired, Handler);
|
|
public override void CloseListener() => GlobalMessenger<SatelliteNode>.RemoveListener(EventNames.QSBSatelliteRepaired, Handler);
|
|
|
|
private void Handler(SatelliteNode node) => SendEvent(CreateMessage(node));
|
|
|
|
private WorldObjectMessage CreateMessage(SatelliteNode node)
|
|
{
|
|
var worldObject = QSBWorldSync.GetWorldFromUnity<QSBSatelliteNode>(node);
|
|
return new WorldObjectMessage
|
|
{
|
|
AboutId = LocalPlayerId,
|
|
ObjectId = worldObject.ObjectId
|
|
};
|
|
}
|
|
|
|
public override void OnReceiveRemote(bool server, WorldObjectMessage message)
|
|
{
|
|
var worldObject = QSBWorldSync.GetWorldFromId<QSBSatelliteNode>(message.ObjectId);
|
|
worldObject.SetRepaired();
|
|
}
|
|
}
|
|
}
|