Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent unit requests from stacking during production. #15982

Merged
merged 1 commit into from Jan 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion OpenRA.Mods.Common/Traits/BotModules/McvManagerBotModule.cs
Expand Up @@ -118,7 +118,8 @@ void IBotTick.BotTick(IBot bot)
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);
}
}
}
Expand Down
7 changes: 5 additions & 2 deletions OpenRA.Mods.Common/Traits/BotModules/UnitBuilderBotModule.cs
Expand Up @@ -9,8 +9,6 @@
*/
#endregion

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using OpenRA.Traits;
Expand Down Expand Up @@ -96,6 +94,11 @@ void IBotRequestUnitProduction.RequestUnitProduction(IBot bot, string requestedA
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
Expand Down
1 change: 1 addition & 0 deletions OpenRA.Mods.Common/TraitsInterfaces.cs
Expand Up @@ -472,6 +472,7 @@ public interface IBotNotifyIdleBaseUnits
public interface IBotRequestUnitProduction
{
void RequestUnitProduction(IBot bot, string requestedActor);
int RequestedProductionCount(IBot bot, string requestedActor);
}

[RequireExplicitImplementation]
Expand Down