Fix the mobile trait spamming crush-notifications
This commit is contained in:
@@ -594,8 +594,11 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
if (!self.IsAtGroundLevel())
|
if (!self.IsAtGroundLevel())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var notifiers = self.World.ActorMap.GetActorsAt(ToCell).Where(a => a != self)
|
var actors = self.World.ActorMap.GetActorsAt(ToCell).Where(a => a != self).ToList();
|
||||||
.SelectMany(a => a.TraitsImplementing<INotifyCrushed>().Select(t => new TraitPair<INotifyCrushed>(a, t)));
|
if (!AnyCrushables(actors))
|
||||||
|
return;
|
||||||
|
|
||||||
|
var notifiers = actors.SelectMany(a => a.TraitsImplementing<INotifyCrushed>().Select(t => new TraitPair<INotifyCrushed>(a, t)));
|
||||||
foreach (var notifyCrushed in notifiers)
|
foreach (var notifyCrushed in notifiers)
|
||||||
notifyCrushed.Trait.WarnCrush(notifyCrushed.Actor, self, Info.Crushes);
|
notifyCrushed.Trait.WarnCrush(notifyCrushed.Actor, self, Info.Crushes);
|
||||||
}
|
}
|
||||||
@@ -606,12 +609,28 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
if (!self.IsAtGroundLevel())
|
if (!self.IsAtGroundLevel())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var notifiers = self.World.ActorMap.GetActorsAt(ToCell).Where(a => a != self)
|
var actors = self.World.ActorMap.GetActorsAt(ToCell).Where(a => a != self).ToList();
|
||||||
.SelectMany(a => a.TraitsImplementing<INotifyCrushed>().Select(t => new TraitPair<INotifyCrushed>(a, t)));
|
if (!AnyCrushables(actors))
|
||||||
|
return;
|
||||||
|
|
||||||
|
var notifiers = actors.SelectMany(a => a.TraitsImplementing<INotifyCrushed>().Select(t => new TraitPair<INotifyCrushed>(a, t)));
|
||||||
foreach (var notifyCrushed in notifiers)
|
foreach (var notifyCrushed in notifiers)
|
||||||
notifyCrushed.Trait.OnCrush(notifyCrushed.Actor, self, Info.Crushes);
|
notifyCrushed.Trait.OnCrush(notifyCrushed.Actor, self, Info.Crushes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool AnyCrushables(List<Actor> actors)
|
||||||
|
{
|
||||||
|
var crushables = actors.SelectMany(a => a.TraitsImplementing<ICrushable>().Select(t => new TraitPair<ICrushable>(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)
|
public int MovementSpeedForCell(Actor self, CPos cell)
|
||||||
{
|
{
|
||||||
var index = self.World.Map.GetTerrainIndex(cell);
|
var index = self.World.Map.GetTerrainIndex(cell);
|
||||||
|
|||||||
Reference in New Issue
Block a user