using QSB.Events; using QSB.WorldSync; using QSB.WorldSync.Events; using QSB.ZeroGCaveSync.WorldObjects; namespace QSB.ZeroGCaveSync.Events { internal class SatelliteNodeRepaired : QSBEvent { public override void SetupListener() => GlobalMessenger.AddListener(EventNames.QSBSatelliteRepaired, Handler); public override void CloseListener() => GlobalMessenger.RemoveListener(EventNames.QSBSatelliteRepaired, Handler); private void Handler(SatelliteNode node) => SendEvent(CreateMessage(node)); private WorldObjectMessage CreateMessage(SatelliteNode node) { var worldObject = QSBWorldSync.GetWorldFromUnity(node); return new WorldObjectMessage { AboutId = LocalPlayerId, ObjectId = worldObject.ObjectId }; } public override void OnReceiveRemote(bool server, WorldObjectMessage message) { var worldObject = QSBWorldSync.GetWorldFromId(message.ObjectId); worldObject.SetRepaired(); } } }