Tweak FrozenActorLayer queries:
- FrozenActorsInRegion now filters for valid and (optionally) visible FAs - Add new FrozenActorsInCircle to mirror World.FindActorsInCircle. The first change means that SupportPowerDecision now correctly ignores FrozenActors that the AI has not discovered.
This commit is contained in:
committed by
Oliver Brakmann
parent
3e490e5843
commit
8eeb6d68e7
@@ -323,11 +323,28 @@ namespace OpenRA.Traits
|
|||||||
return fa;
|
return fa;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<FrozenActor> FrozenActorsInRegion(CellRegion region)
|
public IEnumerable<FrozenActor> FrozenActorsInRegion(CellRegion region, bool onlyVisible = true)
|
||||||
{
|
{
|
||||||
var tl = region.TopLeft;
|
var tl = region.TopLeft;
|
||||||
var br = region.BottomRight;
|
var br = region.BottomRight;
|
||||||
return partitionedFrozenActorIds.InBox(Rectangle.FromLTRB(tl.X, tl.Y, br.X, br.Y)).Select(FromID);
|
return partitionedFrozenActorIds.InBox(Rectangle.FromLTRB(tl.X, tl.Y, br.X, br.Y))
|
||||||
|
.Select(FromID)
|
||||||
|
.Where(fa => fa.IsValid && (!onlyVisible || fa.Visible));
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<FrozenActor> FrozenActorsInCircle(World world, WPos origin, WDist r, bool onlyVisible = true)
|
||||||
|
{
|
||||||
|
var centerCell = world.Map.CellContaining(origin);
|
||||||
|
var cellRange = (r.Length + 1023) / 1024;
|
||||||
|
var tl = centerCell - new CVec(cellRange, cellRange);
|
||||||
|
var br = centerCell + new CVec(cellRange, cellRange);
|
||||||
|
|
||||||
|
// Target ranges are calculated in 2D, so ignore height differences
|
||||||
|
return partitionedFrozenActorIds.InBox(Rectangle.FromLTRB(tl.X, tl.Y, br.X, br.Y))
|
||||||
|
.Select(FromID)
|
||||||
|
.Where(fa => fa.IsValid &&
|
||||||
|
(!onlyVisible || fa.Visible) &&
|
||||||
|
(fa.CenterPosition - origin).HorizontalLengthSquared <= r.LengthSquared);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -81,8 +81,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
// IsValid check filters out Frozen Actors that have not initizialized their Owner
|
// IsValid check filters out Frozen Actors that have not initizialized their Owner
|
||||||
foreach (var scrutinized in checkFrozen)
|
foreach (var scrutinized in checkFrozen)
|
||||||
if (scrutinized.IsValid)
|
answer += consideration.GetAttractiveness(scrutinized, firedBy.Stances[scrutinized.Owner], firedBy);
|
||||||
answer += consideration.GetAttractiveness(scrutinized, firedBy.Stances[scrutinized.Owner], firedBy);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return answer;
|
return answer;
|
||||||
|
|||||||
Reference in New Issue
Block a user