2021-11-29 22:57:13 +00:00
|
|
|
|
using QSB.Events;
|
|
|
|
|
using QSB.WorldSync;
|
|
|
|
|
using QSB.WorldSync.Events;
|
|
|
|
|
using QSB.ZeroGCaveSync.WorldObjects;
|
|
|
|
|
|
|
|
|
|
namespace QSB.ZeroGCaveSync.Events
|
|
|
|
|
{
|
|
|
|
|
internal class SatelliteNodeRepaired : 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-29 22:57:13 +00:00
|
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|