Prevent unit requests from stacking during production.
This commit is contained in:
@@ -118,7 +118,8 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
if (unitBuilder != null)
|
if (unitBuilder != null)
|
||||||
{
|
{
|
||||||
var mcvInfo = AIUtils.GetInfoByCommonName(Info.McvTypes, player);
|
var mcvInfo = AIUtils.GetInfoByCommonName(Info.McvTypes, player);
|
||||||
unitBuilder.RequestUnitProduction(bot, mcvInfo.Name);
|
if (unitBuilder.RequestedProductionCount(bot, mcvInfo.Name) == 0)
|
||||||
|
unitBuilder.RequestUnitProduction(bot, mcvInfo.Name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,8 +9,6 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
@@ -96,6 +94,11 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
queuedBuildRequests.Add(requestedActor);
|
queuedBuildRequests.Add(requestedActor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int IBotRequestUnitProduction.RequestedProductionCount(IBot bot, string requestedActor)
|
||||||
|
{
|
||||||
|
return queuedBuildRequests.Count(r => r == requestedActor);
|
||||||
|
}
|
||||||
|
|
||||||
void BuildUnit(IBot bot, string category, bool buildRandom)
|
void BuildUnit(IBot bot, string category, bool buildRandom)
|
||||||
{
|
{
|
||||||
// Pick a free queue
|
// Pick a free queue
|
||||||
|
|||||||
@@ -472,6 +472,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
public interface IBotRequestUnitProduction
|
public interface IBotRequestUnitProduction
|
||||||
{
|
{
|
||||||
void RequestUnitProduction(IBot bot, string requestedActor);
|
void RequestUnitProduction(IBot bot, string requestedActor);
|
||||||
|
int RequestedProductionCount(IBot bot, string requestedActor);
|
||||||
}
|
}
|
||||||
|
|
||||||
[RequireExplicitImplementation]
|
[RequireExplicitImplementation]
|
||||||
|
|||||||
Reference in New Issue
Block a user