Change Squad.IsEmpty -> IsValid.
This commit is contained in:
@@ -483,7 +483,7 @@ namespace OpenRA.Mods.RA.AI
|
||||
|
||||
void CleanSquads()
|
||||
{
|
||||
squads.RemoveAll(s => s.IsEmpty);
|
||||
squads.RemoveAll(s => !s.IsValid);
|
||||
foreach (var s in squads)
|
||||
s.units.RemoveAll(a => a.Destroyed || a.IsDead());
|
||||
}
|
||||
@@ -647,7 +647,7 @@ namespace OpenRA.Mods.RA.AI
|
||||
if (!protectSq.TargetIsValid)
|
||||
protectSq.Target = attacker;
|
||||
|
||||
if (protectSq.IsEmpty)
|
||||
if (!protectSq.IsValid)
|
||||
{
|
||||
var ownUnits = world.FindActorsInCircle(baseCenter.CenterPosition, WRange.FromCells(15))
|
||||
.Where(unit => unit.Owner == p && !unit.HasTrait<Building>()
|
||||
|
||||
@@ -61,14 +61,11 @@ namespace OpenRA.Mods.RA.AI
|
||||
|
||||
public void Update()
|
||||
{
|
||||
if (IsEmpty) return;
|
||||
if (IsValid)
|
||||
fsm.Update(this);
|
||||
}
|
||||
|
||||
public bool IsEmpty
|
||||
{
|
||||
get { return !units.Any(); }
|
||||
}
|
||||
public bool IsValid { get { return units.Any(); } }
|
||||
|
||||
public Actor Target
|
||||
{
|
||||
|
||||
@@ -151,7 +151,8 @@ namespace OpenRA.Mods.RA.AI
|
||||
|
||||
public void Tick(Squad owner)
|
||||
{
|
||||
if (owner.IsEmpty) return;
|
||||
if (!owner.IsValid)
|
||||
return;
|
||||
|
||||
if (MayBeFlee(owner))
|
||||
{
|
||||
@@ -178,7 +179,8 @@ namespace OpenRA.Mods.RA.AI
|
||||
|
||||
public void Tick(Squad owner)
|
||||
{
|
||||
if (owner.IsEmpty) return;
|
||||
if (!owner.IsValid)
|
||||
return;
|
||||
|
||||
if (!owner.TargetIsValid)
|
||||
{
|
||||
@@ -229,7 +231,8 @@ namespace OpenRA.Mods.RA.AI
|
||||
|
||||
public void Tick(Squad owner)
|
||||
{
|
||||
if (owner.IsEmpty) return;
|
||||
if (!owner.IsValid)
|
||||
return;
|
||||
|
||||
foreach (var a in owner.units)
|
||||
{
|
||||
|
||||
@@ -35,7 +35,9 @@ namespace OpenRA.Mods.RA.AI
|
||||
|
||||
public void Tick(Squad owner)
|
||||
{
|
||||
if (owner.IsEmpty) return;
|
||||
if (!owner.IsValid)
|
||||
return;
|
||||
|
||||
if (!owner.TargetIsValid)
|
||||
{
|
||||
var t = owner.bot.FindClosestEnemy(owner.units.FirstOrDefault().CenterPosition);
|
||||
@@ -71,7 +73,8 @@ namespace OpenRA.Mods.RA.AI
|
||||
|
||||
public void Tick(Squad owner)
|
||||
{
|
||||
if (owner.IsEmpty) return;
|
||||
if (!owner.IsValid)
|
||||
return;
|
||||
|
||||
if (!owner.TargetIsValid)
|
||||
{
|
||||
@@ -128,7 +131,8 @@ namespace OpenRA.Mods.RA.AI
|
||||
|
||||
public void Tick(Squad owner)
|
||||
{
|
||||
if (owner.IsEmpty) return;
|
||||
if (!owner.IsValid)
|
||||
return;
|
||||
|
||||
if (!owner.TargetIsValid)
|
||||
{
|
||||
@@ -161,7 +165,8 @@ namespace OpenRA.Mods.RA.AI
|
||||
|
||||
public void Tick(Squad owner)
|
||||
{
|
||||
if (owner.IsEmpty) return;
|
||||
if (!owner.IsValid)
|
||||
return;
|
||||
|
||||
GoToRandomOwnBuilding(owner);
|
||||
owner.fsm.ChangeState(owner, new GroundUnitsIdleState(), true);
|
||||
|
||||
@@ -27,7 +27,9 @@ namespace OpenRA.Mods.RA.AI
|
||||
|
||||
public void Tick(Squad owner)
|
||||
{
|
||||
if (owner.IsEmpty) return;
|
||||
if (!owner.IsValid)
|
||||
return;
|
||||
|
||||
if (!owner.TargetIsValid)
|
||||
{
|
||||
var circaPostion = AverageUnitsPosition(owner.units);
|
||||
@@ -53,7 +55,8 @@ namespace OpenRA.Mods.RA.AI
|
||||
|
||||
public void Tick(Squad owner)
|
||||
{
|
||||
if (owner.IsEmpty) return;
|
||||
if (!owner.IsValid)
|
||||
return;
|
||||
|
||||
GoToRandomOwnBuilding(owner);
|
||||
owner.fsm.ChangeState(owner, new UnitsForProtectionIdleState(), true);
|
||||
|
||||
@@ -28,7 +28,9 @@ namespace OpenRA.Mods.RA.AI
|
||||
|
||||
protected virtual bool MayBeFlee(Squad owner, Func<List<Actor>, bool> flee)
|
||||
{
|
||||
if (owner.IsEmpty) return false;
|
||||
if (!owner.IsValid)
|
||||
return false;
|
||||
|
||||
var u = owner.units.Random(owner.random);
|
||||
|
||||
var units = owner.world.FindActorsInCircle(u.CenterPosition, WRange.FromCells(dangerRadius)).ToList();
|
||||
|
||||
Reference in New Issue
Block a user