diff --git a/Source/TMagic/TMagic/Verb_ShatterSentinel.cs b/Source/TMagic/TMagic/Verb_ShatterSentinel.cs index 5a2ba6c2..ae53a628 100644 --- a/Source/TMagic/TMagic/Verb_ShatterSentinel.cs +++ b/Source/TMagic/TMagic/Verb_ShatterSentinel.cs @@ -13,15 +13,15 @@ public class Verb_ShatterSentinel : Verb_UseAbility { protected override bool TryCastShot() { - Pawn caster = base.CasterPawn; Pawn pawn = this.currentTarget.Thing as Pawn; CompAbilityUserMagic comp = pawn.GetComp(); - if(comp.IsMagicUser) + if (comp.IsMagicUser) { - if(comp.summonedSentinels.Count > 0) + if (comp.summonedSentinels.Count > 0) { - for(int i =0; i < comp.summonedSentinels.Count; i++) + var toRemove = new HashSet(); + for (int i = 0; i < comp.summonedSentinels.Count; i++) { Thing sentinel = comp.summonedSentinels[i]; if (!sentinel.DestroyedOrNull()) @@ -33,15 +33,11 @@ protected override bool TryCastShot() sentinel.Destroy(DestroyMode.Vanish); } } - else - { - comp.summonedSentinels.Remove(comp.summonedSentinels[i]); - } + + toRemove.Add(sentinel); } - } - else - { + comp.summonedSentinels.RemoveAll(toRemove.Contains); } } return true;