using QSB.Events; using QSB.ShipSync.WorldObjects; using QSB.WorldSync; using QSB.WorldSync.Events; namespace QSB.ShipSync.Events.Hull { internal class HullRepairedEvent : QSBEvent { public override EventType Type => EventType.HullRepaired; public override void SetupListener() => GlobalMessenger.AddListener(EventNames.QSBHullRepaired, Handler); public override void CloseListener() => GlobalMessenger.RemoveListener(EventNames.QSBHullRepaired, Handler); private void Handler(ShipHull hull) => SendEvent(CreateMessage(hull)); private WorldObjectMessage CreateMessage(ShipHull hull) { var worldObject = QSBWorldSync.GetWorldFromUnity(hull); return new WorldObjectMessage { AboutId = LocalPlayerId, ObjectId = worldObject.ObjectId }; } public override void OnReceiveRemote(bool server, WorldObjectMessage message) { var worldObject = QSBWorldSync.GetWorldFromId(message.ObjectId); worldObject.SetRepaired(); } } }