StateBase.cs modified:

1. Optimize & move "ammo" related function from "AirStates.cs" to StateBase.cs

2. Optimize & move "IsRearm" function from "AirStates.cs" to StateBase.cs, name changed to "IsRearming"

(optimized by reaperrr)
This commit is contained in:
dnqbob
2020-04-26 22:58:40 +08:00
committed by abcdefg30
parent 3df43529a6
commit 2d7790f5e4
2 changed files with 56 additions and 48 deletions

View File

@@ -101,5 +101,54 @@ namespace OpenRA.Mods.Common.Traits.BotModules.Squads
return flee(enemyAroundUnit);
}
protected static bool IsRearming(Actor a)
{
if (a.IsIdle)
return false;
var activity = a.CurrentActivity;
if (activity.GetType() == typeof(Resupply))
return true;
var next = activity.NextActivity;
if (next == null)
return false;
if (next.GetType() == typeof(Resupply))
return true;
return false;
}
protected static bool FullAmmo(IEnumerable<AmmoPool> ammoPools)
{
foreach (var ap in ammoPools)
if (!ap.HasFullAmmo)
return false;
return true;
}
protected static bool HasAmmo(IEnumerable<AmmoPool> ammoPools)
{
foreach (var ap in ammoPools)
if (!ap.HasAmmo)
return false;
return true;
}
protected static bool ReloadsAutomatically(IEnumerable<AmmoPool> ammoPools, Rearmable rearmable)
{
if (rearmable == null)
return true;
foreach (var ap in ammoPools)
if (!rearmable.Info.AmmoPools.Contains(ap.Info.Name))
return false;
return true;
}
}
}