From 35600d9291baabf144aaa988a00867b6b9593e3d Mon Sep 17 00:00:00 2001 From: reaperrr Date: Tue, 31 Jul 2018 23:16:03 +0200 Subject: [PATCH] Some HackyAI cleanups - harvManager.Tick should run after FindNewUnits() in case new harvesters have appeared - moved the FindNewUnits Mcv and ExcludeFromSquads checks to the foreach loop, for better readability and preparation of the idle harvester fix --- OpenRA.Mods.Common/AI/HackyAI.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/OpenRA.Mods.Common/AI/HackyAI.cs b/OpenRA.Mods.Common/AI/HackyAI.cs index c4dbc7918b..5227c30a33 100644 --- a/OpenRA.Mods.Common/AI/HackyAI.cs +++ b/OpenRA.Mods.Common/AI/HackyAI.cs @@ -614,8 +614,8 @@ namespace OpenRA.Mods.Common.AI if (--assignRolesTicks <= 0) { assignRolesTicks = Info.AssignRolesInterval; - harvManager.Tick(activeUnits); FindNewUnits(self); + harvManager.Tick(activeUnits); InitializeBase(self, true); } @@ -738,11 +738,13 @@ namespace OpenRA.Mods.Common.AI void FindNewUnits(Actor self) { var newUnits = self.World.ActorsHavingTrait() - .Where(a => a.Owner == Player && !Info.UnitsCommonNames.Mcv.Contains(a.Info.Name) && - !Info.UnitsCommonNames.ExcludeFromSquads.Contains(a.Info.Name) && !activeUnits.Contains(a)); + .Where(a => a.Owner == Player && !activeUnits.Contains(a)); foreach (var a in newUnits) { + if (Info.UnitsCommonNames.Mcv.Contains(a.Info.Name) || Info.UnitsCommonNames.ExcludeFromSquads.Contains(a.Info.Name)) + continue; + unitsHangingAroundTheBase.Add(a); if (a.Info.HasTraitInfo() && a.Info.HasTraitInfo())