Prevent unit requests from stacking during production.

This commit is contained in:
Paul Chote
2018-12-31 21:23:12 +00:00
parent caead311cb
commit f5d788f4fc
3 changed files with 8 additions and 3 deletions

View File

@@ -118,7 +118,8 @@ namespace OpenRA.Mods.Common.Traits
if (unitBuilder != null)
{
var mcvInfo = AIUtils.GetInfoByCommonName(Info.McvTypes, player);
unitBuilder.RequestUnitProduction(bot, mcvInfo.Name);
if (unitBuilder.RequestedProductionCount(bot, mcvInfo.Name) == 0)
unitBuilder.RequestUnitProduction(bot, mcvInfo.Name);
}
}
}

View File

@@ -9,8 +9,6 @@
*/
#endregion
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using OpenRA.Traits;
@@ -96,6 +94,11 @@ namespace OpenRA.Mods.Common.Traits
queuedBuildRequests.Add(requestedActor);
}
int IBotRequestUnitProduction.RequestedProductionCount(IBot bot, string requestedActor)
{
return queuedBuildRequests.Count(r => r == requestedActor);
}
void BuildUnit(IBot bot, string category, bool buildRandom)
{
// Pick a free queue

View File

@@ -472,6 +472,7 @@ namespace OpenRA.Mods.Common.Traits
public interface IBotRequestUnitProduction
{
void RequestUnitProduction(IBot bot, string requestedActor);
int RequestedProductionCount(IBot bot, string requestedActor);
}
[RequireExplicitImplementation]