Fix that bots don't re-use capturers
They were never removed from activeCapturers when their target becomes invalid, preventing the bot from reusing them.
This commit is contained in:
@@ -48,7 +48,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
readonly World world;
|
readonly World world;
|
||||||
readonly Player player;
|
readonly Player player;
|
||||||
readonly Func<Actor, bool> isEnemyUnit;
|
readonly Func<Actor, bool> isEnemyUnit;
|
||||||
readonly Predicate<Actor> unitCannotBeOrdered;
|
readonly Predicate<Actor> unitCannotBeOrderedOrIsIdle;
|
||||||
readonly int maximumCaptureTargetOptions;
|
readonly int maximumCaptureTargetOptions;
|
||||||
int minCaptureDelayTicks;
|
int minCaptureDelayTicks;
|
||||||
|
|
||||||
@@ -69,7 +69,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
&& !unit.Info.HasTraitInfo<HuskInfo>()
|
&& !unit.Info.HasTraitInfo<HuskInfo>()
|
||||||
&& unit.Info.HasTraitInfo<ITargetableInfo>();
|
&& unit.Info.HasTraitInfo<ITargetableInfo>();
|
||||||
|
|
||||||
unitCannotBeOrdered = a => a.Owner != player || a.IsDead || !a.IsInWorld;
|
unitCannotBeOrderedOrIsIdle = a => a.Owner != player || a.IsDead || !a.IsInWorld || a.IsIdle;
|
||||||
|
|
||||||
maximumCaptureTargetOptions = Math.Max(1, Info.MaximumCaptureTargetOptions);
|
maximumCaptureTargetOptions = Math.Max(1, Info.MaximumCaptureTargetOptions);
|
||||||
}
|
}
|
||||||
@@ -118,7 +118,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
if (!Info.CapturingActorTypes.Any() || player.WinState != WinState.Undefined)
|
if (!Info.CapturingActorTypes.Any() || player.WinState != WinState.Undefined)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
activeCapturers.RemoveAll(unitCannotBeOrdered);
|
activeCapturers.RemoveAll(unitCannotBeOrderedOrIsIdle);
|
||||||
|
|
||||||
var newUnits = world.ActorsHavingTrait<IPositionable>()
|
var newUnits = world.ActorsHavingTrait<IPositionable>()
|
||||||
.Where(a => a.Owner == player && !activeCapturers.Contains(a));
|
.Where(a => a.Owner == player && !activeCapturers.Contains(a));
|
||||||
|
|||||||
Reference in New Issue
Block a user