diff --git a/OpenRA.Mods.Common/Traits/Mobile.cs b/OpenRA.Mods.Common/Traits/Mobile.cs index 806f82f2db..11c6aeacf5 100644 --- a/OpenRA.Mods.Common/Traits/Mobile.cs +++ b/OpenRA.Mods.Common/Traits/Mobile.cs @@ -594,8 +594,11 @@ namespace OpenRA.Mods.Common.Traits if (!self.IsAtGroundLevel()) return; - var notifiers = self.World.ActorMap.GetActorsAt(ToCell).Where(a => a != self) - .SelectMany(a => a.TraitsImplementing().Select(t => new TraitPair(a, t))); + var actors = self.World.ActorMap.GetActorsAt(ToCell).Where(a => a != self).ToList(); + if (!AnyCrushables(actors)) + return; + + var notifiers = actors.SelectMany(a => a.TraitsImplementing().Select(t => new TraitPair(a, t))); foreach (var notifyCrushed in notifiers) notifyCrushed.Trait.WarnCrush(notifyCrushed.Actor, self, Info.Crushes); } @@ -606,12 +609,28 @@ namespace OpenRA.Mods.Common.Traits if (!self.IsAtGroundLevel()) return; - var notifiers = self.World.ActorMap.GetActorsAt(ToCell).Where(a => a != self) - .SelectMany(a => a.TraitsImplementing().Select(t => new TraitPair(a, t))); + var actors = self.World.ActorMap.GetActorsAt(ToCell).Where(a => a != self).ToList(); + if (!AnyCrushables(actors)) + return; + + var notifiers = actors.SelectMany(a => a.TraitsImplementing().Select(t => new TraitPair(a, t))); foreach (var notifyCrushed in notifiers) notifyCrushed.Trait.OnCrush(notifyCrushed.Actor, self, Info.Crushes); } + bool AnyCrushables(List actors) + { + var crushables = actors.SelectMany(a => a.TraitsImplementing().Select(t => new TraitPair(a, t))).ToList(); + if (crushables.Count == 0) + return false; + + foreach (var crushes in crushables) + if (!crushes.Trait.CrushableBy(crushes.Actor, self, Info.Crushes)) + return false; + + return true; + } + public int MovementSpeedForCell(Actor self, CPos cell) { var index = self.World.Map.GetTerrainIndex(cell);