Remove hardcoded trait assumptions from MCV and ConYards.
This commit is contained in:
@@ -202,11 +202,11 @@ namespace OpenRA.Mods.Common.AI
|
|||||||
|
|
||||||
public CPos GetRandomBaseCenter()
|
public CPos GetRandomBaseCenter()
|
||||||
{
|
{
|
||||||
var randomBaseBuilding = World.ActorsHavingTrait<BaseBuilding>()
|
var randomConstructionYard = World.Actors.Where(a => a.Owner == Player &&
|
||||||
.Where(a => a.Owner == Player && !a.Info.HasTraitInfo<MobileInfo>())
|
Info.BuildingCommonNames.ConstructionYard.Contains(a.Info.Name))
|
||||||
.RandomOrDefault(Random);
|
.RandomOrDefault(Random);
|
||||||
|
|
||||||
return randomBaseBuilding != null ? randomBaseBuilding.Location : initialBaseCenter;
|
return randomConstructionYard != null ? randomConstructionYard.Location : initialBaseCenter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsEnabled;
|
public bool IsEnabled;
|
||||||
@@ -609,8 +609,8 @@ namespace OpenRA.Mods.Common.AI
|
|||||||
|
|
||||||
List<Actor> FindEnemyConstructionYards()
|
List<Actor> FindEnemyConstructionYards()
|
||||||
{
|
{
|
||||||
return World.ActorsHavingTrait<BaseBuilding>()
|
return World.Actors.Where(a => Player.Stances[a.Owner] == Stance.Enemy && !a.IsDead &&
|
||||||
.Where(a => Player.Stances[a.Owner] == Stance.Enemy && !a.IsDead && !a.Info.HasTraitInfo<MobileInfo>()).ToList();
|
Info.BuildingCommonNames.ConstructionYard.Contains(a.Info.Name)).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CleanSquads()
|
void CleanSquads()
|
||||||
@@ -721,7 +721,7 @@ namespace OpenRA.Mods.Common.AI
|
|||||||
void FindNewUnits(Actor self)
|
void FindNewUnits(Actor self)
|
||||||
{
|
{
|
||||||
var newUnits = self.World.ActorsHavingTrait<IPositionable>()
|
var newUnits = self.World.ActorsHavingTrait<IPositionable>()
|
||||||
.Where(a => a.Owner == Player && !a.Info.HasTraitInfo<BaseBuildingInfo>() && !activeUnits.Contains(a));
|
.Where(a => a.Owner == Player && !Info.UnitsCommonNames.Mcv.Contains(a.Info.Name) && !activeUnits.Contains(a));
|
||||||
|
|
||||||
foreach (var a in newUnits)
|
foreach (var a in newUnits)
|
||||||
{
|
{
|
||||||
@@ -845,17 +845,14 @@ namespace OpenRA.Mods.Common.AI
|
|||||||
void InitializeBase(Actor self)
|
void InitializeBase(Actor self)
|
||||||
{
|
{
|
||||||
// Find and deploy our mcv
|
// Find and deploy our mcv
|
||||||
var mcv = self.World.ActorsHavingTrait<BaseBuilding>().FirstOrDefault(a => a.Owner == Player);
|
var mcv = self.World.Actors.FirstOrDefault(a => a.Owner == Player &&
|
||||||
|
Info.UnitsCommonNames.Mcv.Contains(a.Info.Name));
|
||||||
|
|
||||||
if (mcv != null)
|
if (mcv != null)
|
||||||
{
|
{
|
||||||
initialBaseCenter = mcv.Location;
|
initialBaseCenter = mcv.Location;
|
||||||
defenseCenter = mcv.Location;
|
defenseCenter = mcv.Location;
|
||||||
|
QueueOrder(new Order("DeployTransform", mcv, false));
|
||||||
// Don't transform the mcv if it is a fact
|
|
||||||
// HACK: This needs to query against MCVs directly
|
|
||||||
if (mcv.Info.HasTraitInfo<MobileInfo>())
|
|
||||||
QueueOrder(new Order("DeployTransform", mcv, false));
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
BotDebug("AI: Can't find BaseBuildUnit.");
|
BotDebug("AI: Can't find BaseBuildUnit.");
|
||||||
@@ -865,9 +862,8 @@ namespace OpenRA.Mods.Common.AI
|
|||||||
// backup location within the main base.
|
// backup location within the main base.
|
||||||
void FindAndDeployBackupMcv(Actor self)
|
void FindAndDeployBackupMcv(Actor self)
|
||||||
{
|
{
|
||||||
// HACK: This needs to query against MCVs directly
|
var mcvs = self.World.Actors.Where(a => a.Owner == Player &&
|
||||||
var mcvs = self.World.ActorsHavingTrait<BaseBuilding>()
|
Info.UnitsCommonNames.Mcv.Contains(a.Info.Name));
|
||||||
.Where(a => a.Owner == Player && a.Info.HasTraitInfo<MobileInfo>());
|
|
||||||
|
|
||||||
foreach (var mcv in mcvs)
|
foreach (var mcv in mcvs)
|
||||||
{
|
{
|
||||||
@@ -1024,8 +1020,8 @@ namespace OpenRA.Mods.Common.AI
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// No construction yards - Build a new MCV
|
// No construction yards - Build a new MCV
|
||||||
if (!HasAdequateFact() && !self.World.ActorsHavingTrait<BaseBuilding>()
|
if (!HasAdequateFact() && !self.World.Actors.Any(a => a.Owner == Player &&
|
||||||
.Any(a => a.Owner == Player && a.Info.HasTraitInfo<MobileInfo>()))
|
Info.UnitsCommonNames.Mcv.Contains(a.Info.Name)))
|
||||||
BuildUnit("Vehicle", GetInfoByCommonName(Info.UnitsCommonNames.Mcv, Player).Name);
|
BuildUnit("Vehicle", GetInfoByCommonName(Info.UnitsCommonNames.Mcv, Player).Name);
|
||||||
|
|
||||||
foreach (var q in Info.UnitQueues)
|
foreach (var q in Info.UnitQueues)
|
||||||
|
|||||||
Reference in New Issue
Block a user