Fix McvManagerBotModule spamming deploy orders
Removes the 'activeMCVs' list since it was not useful. The real bugfix is not iterating over 'activeMCVs' when issueing new orders (this was previously needed for already discovered mcvs that stopped) but over 'newMCVs' instead.
This commit is contained in:
@@ -72,9 +72,6 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
int scanInterval;
|
int scanInterval;
|
||||||
bool firstTick = true;
|
bool firstTick = true;
|
||||||
|
|
||||||
// MCVs that the bot already knows about. Any MCV not on this list needs to be given an order.
|
|
||||||
List<Actor> activeMCVs = new List<Actor>();
|
|
||||||
|
|
||||||
public McvManagerBotModule(Actor self, McvManagerBotModuleInfo info)
|
public McvManagerBotModule(Actor self, McvManagerBotModuleInfo info)
|
||||||
: base(info)
|
: base(info)
|
||||||
{
|
{
|
||||||
@@ -140,18 +137,10 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
void DeployMcvs(IBot bot, bool chooseLocation)
|
void DeployMcvs(IBot bot, bool chooseLocation)
|
||||||
{
|
{
|
||||||
activeMCVs.RemoveAll(unitCannotBeOrdered);
|
|
||||||
|
|
||||||
var newMCVs = world.ActorsHavingTrait<Transforms>()
|
var newMCVs = world.ActorsHavingTrait<Transforms>()
|
||||||
.Where(a => a.Owner == player &&
|
.Where(a => a.Owner == player && a.IsIdle && Info.McvTypes.Contains(a.Info.Name));
|
||||||
a.IsIdle &&
|
|
||||||
Info.McvTypes.Contains(a.Info.Name) &&
|
|
||||||
!activeMCVs.Contains(a));
|
|
||||||
|
|
||||||
foreach (var a in newMCVs)
|
foreach (var mcv in newMCVs)
|
||||||
activeMCVs.Add(a);
|
|
||||||
|
|
||||||
foreach (var mcv in activeMCVs)
|
|
||||||
DeployMcv(bot, mcv, chooseLocation);
|
DeployMcv(bot, mcv, chooseLocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -221,11 +210,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
return new List<MiniYamlNode>()
|
return new List<MiniYamlNode>()
|
||||||
{
|
{
|
||||||
new MiniYamlNode("InitialBaseCenter", FieldSaver.FormatValue(initialBaseCenter)),
|
new MiniYamlNode("InitialBaseCenter", FieldSaver.FormatValue(initialBaseCenter))
|
||||||
new MiniYamlNode("ActiveMCVs", FieldSaver.FormatValue(activeMCVs
|
|
||||||
.Where(a => !unitCannotBeOrdered(a))
|
|
||||||
.Select(a => a.ActorID)
|
|
||||||
.ToArray()))
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -237,14 +222,6 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
var initialBaseCenterNode = data.FirstOrDefault(n => n.Key == "InitialBaseCenter");
|
var initialBaseCenterNode = data.FirstOrDefault(n => n.Key == "InitialBaseCenter");
|
||||||
if (initialBaseCenterNode != null)
|
if (initialBaseCenterNode != null)
|
||||||
initialBaseCenter = FieldLoader.GetValue<CPos>("InitialBaseCenter", initialBaseCenterNode.Value.Value);
|
initialBaseCenter = FieldLoader.GetValue<CPos>("InitialBaseCenter", initialBaseCenterNode.Value.Value);
|
||||||
|
|
||||||
var activeMCVsNode = data.FirstOrDefault(n => n.Key == "ActiveMCVs");
|
|
||||||
if (activeMCVsNode != null)
|
|
||||||
{
|
|
||||||
activeMCVs.Clear();
|
|
||||||
activeMCVs.AddRange(FieldLoader.GetValue<uint[]>("ActiveMCVs", activeMCVsNode.Value.Value)
|
|
||||||
.Select(a => world.GetActorById(a)).Where(a => a != null));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user