From 1bff8559fb75e90b827db2c314a20e161aa1b499 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Fri, 1 Oct 2010 20:56:17 +1300 Subject: [PATCH] pull HasAdequatePower out into a function --- OpenRA.Mods.RA/HackyAI.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/OpenRA.Mods.RA/HackyAI.cs b/OpenRA.Mods.RA/HackyAI.cs index 16e1c89679..3b296403cb 100644 --- a/OpenRA.Mods.RA/HackyAI.cs +++ b/OpenRA.Mods.RA/HackyAI.cs @@ -86,11 +86,16 @@ namespace OpenRA.Mods.RA return buildableThings.ElementAtOrDefault(random.Next(buildableThings.Count())); } + bool HasAdequatePower() + { + return playerPower.PowerProvided > playerPower.PowerDrained * 1.2; + } + ActorInfo ChooseBuildingToBuild(ProductionQueue queue) { var buildableThings = queue.BuildableItems(); - if (playerPower.PowerProvided <= playerPower.PowerDrained * 1.2) /* try to maintain 20% excess power */ + if (!HasAdequatePower()) /* try to maintain 20% excess power */ { /* find the best thing we can build which produces power */ var best = buildableThings.Where(a => GetPowerProvidedBy(a) > 0)