Don't pass movement class via IsPassable directly

Let IsPassable get that info from the locomotor instead.
This commit is contained in:
reaperrr
2018-03-23 23:47:03 +01:00
committed by abcdefg30
parent a52e83ca49
commit 5364515004
9 changed files with 25 additions and 35 deletions

View File

@@ -42,10 +42,9 @@ namespace OpenRA.Mods.Common.AI
CPos FindNextResource(Actor actor, Harvester harv)
{
var locomotorInfo = actor.Info.TraitInfo<MobileInfo>().LocomotorInfo;
var passable = (uint)locomotorInfo.GetMovementClass(World.Map.Rules.TileSet);
Func<CPos, bool> isValidResource = cell =>
domainIndex.IsPassable(actor.Location, cell, locomotorInfo, passable) &&
domainIndex.IsPassable(actor.Location, cell, locomotorInfo) &&
harv.CanHarvestCell(actor, cell) &&
claimLayer.CanClaimCell(actor, cell);

View File

@@ -31,11 +31,10 @@ namespace OpenRA.Mods.Common.AI
// You might be tempted to move these lookups into Activate() but that causes null reference exception.
var domainIndex = first.World.WorldActor.Trait<DomainIndex>();
var locomotorInfo = first.Info.TraitInfo<MobileInfo>().LocomotorInfo;
var passable = (uint)locomotorInfo.GetMovementClass(first.World.Map.Rules.TileSet);
var navalProductions = owner.World.ActorsHavingTrait<Building>().Where(a
=> owner.Bot.Info.BuildingCommonNames.NavalProduction.Contains(a.Info.Name)
&& domainIndex.IsPassable(first.Location, a.Location, locomotorInfo, passable)
&& domainIndex.IsPassable(first.Location, a.Location, locomotorInfo)
&& a.AppearsHostileTo(first));
if (navalProductions.Any())