From 3f38d063a90956504c25a0f595cdf38a9b7cc051 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Mon, 6 Jul 2015 10:55:42 +0200 Subject: [PATCH] remove code duplication --- OpenRA.Mods.Common/Traits/Mobile.cs | 29 +---------------------------- 1 file changed, 1 insertion(+), 28 deletions(-) diff --git a/OpenRA.Mods.Common/Traits/Mobile.cs b/OpenRA.Mods.Common/Traits/Mobile.cs index d460930e22..9a23a174f3 100644 --- a/OpenRA.Mods.Common/Traits/Mobile.cs +++ b/OpenRA.Mods.Common/Traits/Mobile.cs @@ -221,34 +221,7 @@ namespace OpenRA.Mods.Common.Traits if ((movementCost = MovementCostForCell(world, cell)) == int.MaxValue) return false; - if (SharesCell && world.ActorMap.HasFreeSubCell(cell)) - return true; - - if (check.HasFlag(CellConditions.TransientActors)) - { - var canIgnoreMovingAllies = self != null && !check.HasFlag(CellConditions.BlockedByMovers); - var needsCellExclusively = self == null || Crushes == null || !Crushes.Any(); - foreach (var a in world.ActorMap.GetUnitsAt(cell)) - { - if (a == ignoreActor) - continue; - - // Neutral/enemy units are blockers. Allied units that are moving are not blockers. - if (canIgnoreMovingAllies && self.Owner.Stances[a.Owner] == Stance.Ally && IsMovingInMyDirection(self, a)) continue; - - // Non-sharable unit can enter a cell with shareable units only if it can crush all of them. - if (needsCellExclusively) - return false; - var crushables = a.TraitsImplementing(); - if (!crushables.Any()) - return false; - foreach (var crushable in crushables) - if (!crushable.CrushableBy(Crushes, self.Owner)) - return false; - } - } - - return true; + return CanMoveFreelyInto(world, self, cell, ignoreActor, check); } public SubCell GetAvailableSubCell(