From 1cb788ac2ef8620d6e7957aecfa975508273957e Mon Sep 17 00:00:00 2001 From: tylerdavidwall <129888930+tylerdavidwall@users.noreply.github.com> Date: Tue, 4 Apr 2023 10:31:02 -0700 Subject: [PATCH] Update Whirlwind.cs Fixes the null reference execption when removing tokens and a the ship doesn't have any jam tokens --- .../Standard/Pilots/FO/TIEWiWhisper/Whirlwind.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Assets/Scripts/Model/Content/SecondEdition/Standard/Pilots/FO/TIEWiWhisper/Whirlwind.cs b/Assets/Scripts/Model/Content/SecondEdition/Standard/Pilots/FO/TIEWiWhisper/Whirlwind.cs index 791bf85078..4383d82ae0 100644 --- a/Assets/Scripts/Model/Content/SecondEdition/Standard/Pilots/FO/TIEWiWhisper/Whirlwind.cs +++ b/Assets/Scripts/Model/Content/SecondEdition/Standard/Pilots/FO/TIEWiWhisper/Whirlwind.cs @@ -99,8 +99,13 @@ private void DoRemoveJamTokens(int count, Action callback) { Messages.ShowInfo($"{HostShip.PilotInfo.PilotName}: {count} Jam token(s) are removed"); - List tokensToRemove = HostShip.Tokens.GetAllTokens().Where( n => n is JamToken).Take(count).ToList(); - HostShip.Tokens.RemoveTokens(tokensToRemove, callback); + List tokensToRemove = HostShip.Tokens.GetAllTokens() + .Where(n => n is JamToken) + .ToList(); + + tokensToRemove.Count > 0 ? + HostShip.Tokens.RemoveTokens(tokensToRemove.Take(count).ToList(), callback) : + callback(); } private void GainFocusTokens()