2021-06-20 10:06:29 +01:00
|
|
|
|
using QSB.Events;
|
|
|
|
|
using QSB.ShipSync.WorldObjects;
|
|
|
|
|
using QSB.WorldSync;
|
2021-07-04 22:34:38 +01:00
|
|
|
|
using QSB.WorldSync.Events;
|
2021-06-20 10:06:29 +01:00
|
|
|
|
|
|
|
|
|
namespace QSB.ShipSync.Events.Hull
|
|
|
|
|
{
|
2021-07-12 22:02:50 +01:00
|
|
|
|
internal class HullRepairedEvent : QSBEvent<WorldObjectMessage>
|
2021-06-20 10:06:29 +01:00
|
|
|
|
{
|
|
|
|
|
public override EventType Type => EventType.HullRepaired;
|
|
|
|
|
|
|
|
|
|
public override void SetupListener() => GlobalMessenger<ShipHull>.AddListener(EventNames.QSBHullRepaired, Handler);
|
|
|
|
|
public override void CloseListener() => GlobalMessenger<ShipHull>.RemoveListener(EventNames.QSBHullRepaired, Handler);
|
|
|
|
|
|
|
|
|
|
private void Handler(ShipHull hull) => SendEvent(CreateMessage(hull));
|
|
|
|
|
|
|
|
|
|
private WorldObjectMessage CreateMessage(ShipHull hull)
|
|
|
|
|
{
|
2021-11-01 15:49:00 +00:00
|
|
|
|
var worldObject = QSBWorldSync.GetWorldFromUnity<QSBShipHull>(hull);
|
2021-06-20 10:06:29 +01:00
|
|
|
|
return new WorldObjectMessage
|
|
|
|
|
{
|
|
|
|
|
AboutId = LocalPlayerId,
|
|
|
|
|
ObjectId = worldObject.ObjectId
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void OnReceiveRemote(bool server, WorldObjectMessage message)
|
|
|
|
|
{
|
|
|
|
|
var worldObject = QSBWorldSync.GetWorldFromId<QSBShipHull>(message.ObjectId);
|
|
|
|
|
worldObject.SetRepaired();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|