Fix style errors in ProductionQueue.cs
This commit is contained in:
@@ -249,66 +249,61 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
switch (order.OrderString)
|
switch (order.OrderString)
|
||||||
{
|
{
|
||||||
case "StartProduction":
|
case "StartProduction":
|
||||||
|
var unit = rules.Actors[order.TargetString];
|
||||||
|
var bi = unit.TraitInfo<BuildableInfo>();
|
||||||
|
|
||||||
|
// Not built by this queue
|
||||||
|
if (!bi.Queue.Contains(Info.Type))
|
||||||
|
return;
|
||||||
|
|
||||||
|
var cost = unit.HasTraitInfo<ValuedInfo>() ? unit.TraitInfo<ValuedInfo>().Cost : 0;
|
||||||
|
var time = GetBuildTime(order.TargetString);
|
||||||
|
|
||||||
|
// You can't build that
|
||||||
|
if (BuildableItems().All(b => b.Name != order.TargetString))
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Check if the player is trying to build more units that they are allowed
|
||||||
|
var fromLimit = int.MaxValue;
|
||||||
|
if (!developerMode.AllTech && bi.BuildLimit > 0)
|
||||||
{
|
{
|
||||||
var unit = rules.Actors[order.TargetString];
|
var inQueue = queue.Count(pi => pi.Item == order.TargetString);
|
||||||
var bi = unit.TraitInfo<BuildableInfo>();
|
var owned = self.Owner.World.ActorsHavingTrait<Buildable>().Count(a => a.Info.Name == order.TargetString && a.Owner == self.Owner);
|
||||||
if (!bi.Queue.Contains(Info.Type))
|
fromLimit = bi.BuildLimit - (inQueue + owned);
|
||||||
return; /* Not built by this queue */
|
|
||||||
|
|
||||||
var cost = unit.HasTraitInfo<ValuedInfo>() ? unit.TraitInfo<ValuedInfo>().Cost : 0;
|
if (fromLimit <= 0)
|
||||||
var time = GetBuildTime(order.TargetString);
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (BuildableItems().All(b => b.Name != order.TargetString))
|
var amountToBuild = Math.Min(fromLimit, order.ExtraData);
|
||||||
return; /* you can't build that!! */
|
for (var n = 0; n < amountToBuild; n++)
|
||||||
|
{
|
||||||
// Check if the player is trying to build more units that they are allowed
|
var hasPlayedSound = false;
|
||||||
var fromLimit = int.MaxValue;
|
BeginProduction(new ProductionItem(this, order.TargetString, cost, playerPower, () => self.World.AddFrameEndTask(_ =>
|
||||||
if (!developerMode.AllTech && bi.BuildLimit > 0)
|
|
||||||
{
|
{
|
||||||
var inQueue = queue.Count(pi => pi.Item == order.TargetString);
|
var isBuilding = unit.HasTraitInfo<BuildingInfo>();
|
||||||
var owned = self.Owner.World.ActorsHavingTrait<Buildable>().Count(a => a.Info.Name == order.TargetString && a.Owner == self.Owner);
|
|
||||||
fromLimit = bi.BuildLimit - (inQueue + owned);
|
|
||||||
|
|
||||||
if (fromLimit <= 0)
|
if (isBuilding && !hasPlayedSound)
|
||||||
return;
|
hasPlayedSound = Game.Sound.PlayNotification(rules, self.Owner, "Speech", Info.ReadyAudio, self.Owner.Faction.InternalName);
|
||||||
}
|
else if (!isBuilding)
|
||||||
|
|
||||||
var amountToBuild = Math.Min(fromLimit, order.ExtraData);
|
|
||||||
for (var n = 0; n < amountToBuild; n++)
|
|
||||||
{
|
|
||||||
var hasPlayedSound = false;
|
|
||||||
BeginProduction(new ProductionItem(this, order.TargetString, cost, playerPower, () => self.World.AddFrameEndTask(_ =>
|
|
||||||
{
|
{
|
||||||
var isBuilding = unit.HasTraitInfo<BuildingInfo>();
|
if (BuildUnit(order.TargetString))
|
||||||
|
Game.Sound.PlayNotification(rules, self.Owner, "Speech", Info.ReadyAudio, self.Owner.Faction.InternalName);
|
||||||
if (isBuilding && !hasPlayedSound)
|
else if (!hasPlayedSound && time > 0)
|
||||||
hasPlayedSound = Game.Sound.PlayNotification(rules, self.Owner, "Speech", Info.ReadyAudio, self.Owner.Faction.InternalName);
|
hasPlayedSound = Game.Sound.PlayNotification(rules, self.Owner, "Speech", Info.BlockedAudio, self.Owner.Faction.InternalName);
|
||||||
else if (!isBuilding)
|
}
|
||||||
{
|
})));
|
||||||
if (BuildUnit(order.TargetString))
|
|
||||||
Game.Sound.PlayNotification(rules, self.Owner, "Speech", Info.ReadyAudio, self.Owner.Faction.InternalName);
|
|
||||||
else if (!hasPlayedSound && time > 0)
|
|
||||||
hasPlayedSound = Game.Sound.PlayNotification(rules, self.Owner, "Speech", Info.BlockedAudio, self.Owner.Faction.InternalName);
|
|
||||||
}
|
|
||||||
})));
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
case "PauseProduction":
|
case "PauseProduction":
|
||||||
{
|
if (queue.Count > 0 && queue[0].Item == order.TargetString)
|
||||||
if (queue.Count > 0 && queue[0].Item == order.TargetString)
|
queue[0].Pause(order.ExtraData != 0);
|
||||||
queue[0].Pause(order.ExtraData != 0);
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
break;
|
||||||
case "CancelProduction":
|
case "CancelProduction":
|
||||||
{
|
CancelProduction(order.TargetString, order.ExtraData);
|
||||||
CancelProduction(order.TargetString, order.ExtraData);
|
break;
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user