From 2509750c6b6fe763344e11d2fb80a662a8320177 Mon Sep 17 00:00:00 2001 From: Nick Date: Mon, 3 Jul 2023 10:21:49 -0400 Subject: [PATCH] Disconnect transmitter OnReceiveWarpedBody event when destroyed --- NewHorizons/Components/NomaiWarpTransmitterCooldown.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/NewHorizons/Components/NomaiWarpTransmitterCooldown.cs b/NewHorizons/Components/NomaiWarpTransmitterCooldown.cs index bdf92fc9..f057b062 100644 --- a/NewHorizons/Components/NomaiWarpTransmitterCooldown.cs +++ b/NewHorizons/Components/NomaiWarpTransmitterCooldown.cs @@ -16,6 +16,14 @@ namespace NewHorizons.Components _transmitter.OnReceiveWarpedBody += _transmitter_OnReceiveWarpedBody; } + public void OnDestroy() + { + if (_transmitter != null) + { + _transmitter.OnReceiveWarpedBody -= _transmitter_OnReceiveWarpedBody; + } + } + private void _transmitter_OnReceiveWarpedBody(OWRigidbody warpedBody, NomaiWarpPlatform startPlatform, NomaiWarpPlatform targetPlatform) { _cooldownActive = true;