HackyAI: Refactor and remove duplicated logic.

This commit is contained in:
Guido L
2018-01-14 15:22:37 +01:00
committed by reaperrr
parent c46a050da3
commit 21472f2cc6
2 changed files with 49 additions and 88 deletions

View File

@@ -75,7 +75,7 @@ namespace OpenRA.Mods.Common.AI
if (waterState == Water.NotChecked)
{
if (ai.EnoughWaterToBuildNaval())
if (ai.IsAreaAvailable<BaseProvider>(ai.Info.MaxBaseRadius, ai.Info.WaterTerrainTypes))
waterState = Water.EnoughWater;
else
{
@@ -255,7 +255,7 @@ namespace OpenRA.Mods.Common.AI
// Only consider building this if there is enough water inside the base perimeter and there are close enough adjacent buildings
if (waterState == Water.EnoughWater && ai.Info.NewProductionCashThreshold > 0
&& playerResources.Resources > ai.Info.NewProductionCashThreshold
&& ai.CloseEnoughToWater())
&& ai.IsAreaAvailable<GivesBuildableArea>(ai.Info.CheckForWaterRadius, ai.Info.WaterTerrainTypes))
{
var navalproduction = GetProducibleBuilding(ai.Info.BuildingCommonNames.NavalProduction, buildableThings);
if (navalproduction != null && HasSufficientPowerForActor(navalproduction))
@@ -309,7 +309,7 @@ namespace OpenRA.Mods.Common.AI
// and any structure providing buildable area close enough to that water.
// TODO: Extend this check to cover any naval structure, not just production.
if (ai.Info.BuildingCommonNames.NavalProduction.Contains(name)
&& (waterState == Water.NotEnoughWater || !ai.CloseEnoughToWater()))
&& (waterState == Water.NotEnoughWater || !ai.IsAreaAvailable<GivesBuildableArea>(ai.Info.CheckForWaterRadius, ai.Info.WaterTerrainTypes)))
continue;
// Will this put us into low power?