diff --git a/QSB/Events/EventNames.cs b/QSB/Events/EventNames.cs
index d92b3062..5a1739ea 100644
--- a/QSB/Events/EventNames.cs
+++ b/QSB/Events/EventNames.cs
@@ -72,6 +72,7 @@
public static string QSBHullImpact = "QSBHullImpact";
public static string QSBHullDamaged = "QSBHullDamaged";
public static string QSBHullChangeIntegrity = "QSBHullChangeIntegrity";
+ public static string QSBHullRepaired = "QSBHullRepaired";
public static string QSBComponentDamaged = "QSBComponentDamaged";
public static string QSBComponentRepaired = "QSBComponentRepaired";
}
diff --git a/QSB/Events/EventType.cs b/QSB/Events/EventType.cs
index 241d1bd5..665f9deb 100644
--- a/QSB/Events/EventType.cs
+++ b/QSB/Events/EventType.cs
@@ -49,6 +49,7 @@
HullImpact,
HullDamaged,
HullChangeIntegrity,
+ HullRepaired,
ComponentDamaged,
ComponentRepaired
}
diff --git a/QSB/Events/QSBEventManager.cs b/QSB/Events/QSBEventManager.cs
index fad6d5c6..d5f4ad7b 100644
--- a/QSB/Events/QSBEventManager.cs
+++ b/QSB/Events/QSBEventManager.cs
@@ -87,6 +87,7 @@ namespace QSB.Events
new HullImpactEvent(),
new HullDamagedEvent(),
new HullChangeIntegrityEvent(),
+ new HullRepairedEvent(),
new ComponentDamagedEvent(),
new ComponentRepairedEvent()
};
diff --git a/QSB/QSB.csproj b/QSB/QSB.csproj
index 06e7c37e..1fbf892a 100644
--- a/QSB/QSB.csproj
+++ b/QSB/QSB.csproj
@@ -249,6 +249,7 @@
+
diff --git a/QSB/ShipSync/Events/Hull/HullRepairedEvent.cs b/QSB/ShipSync/Events/Hull/HullRepairedEvent.cs
new file mode 100644
index 00000000..4045e31d
--- /dev/null
+++ b/QSB/ShipSync/Events/Hull/HullRepairedEvent.cs
@@ -0,0 +1,43 @@
+using QSB.Events;
+using QSB.ShipSync.WorldObjects;
+using QSB.Utility;
+using QSB.WorldSync.Events;
+using QSB.WorldSync;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace QSB.ShipSync.Events.Hull
+{
+ 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 OnReceiveLocal(bool server, WorldObjectMessage message)
+ {
+ DebugLog.DebugWrite($"[HULL] {message.ObjectId} OnRepaired.", OWML.Common.MessageType.Warning);
+ }
+
+ public override void OnReceiveRemote(bool server, WorldObjectMessage message)
+ {
+ var worldObject = QSBWorldSync.GetWorldFromId(message.ObjectId);
+ worldObject.SetRepaired();
+ }
+ }
+}
diff --git a/QSB/ShipSync/WorldObjects/QSBShipHull.cs b/QSB/ShipSync/WorldObjects/QSBShipHull.cs
index 0f99cf5c..9d3344ed 100644
--- a/QSB/ShipSync/WorldObjects/QSBShipHull.cs
+++ b/QSB/ShipSync/WorldObjects/QSBShipHull.cs
@@ -19,6 +19,15 @@ namespace QSB.ShipSync.WorldObjects
QSBWorldSync.RaiseEvent(AttachedObject, "OnDamaged", AttachedObject);
}
+ public void SetRepaired()
+ {
+ DebugLog.DebugWrite($"[HULL] {AttachedObject} Set repaired.");
+ AttachedObject.SetValue("_damaged", false);
+ QSBWorldSync.RaiseEvent(AttachedObject, "OnRepaired", AttachedObject);
+ var damageEffect = AttachedObject.GetValue("_damageEffect");
+ damageEffect.SetEffectBlend(0f);
+ }
+
public void ChangeIntegrity(float newIntegrity)
{
DebugLog.DebugWrite($"[HULL] {AttachedObject} Change integrity to {newIntegrity}.");