Disables "building"-speech when nothing more can be built

This commit is contained in:
Kanar
2014-01-18 22:42:05 +01:00
parent d28992c054
commit aace7ca607
2 changed files with 12 additions and 6 deletions

View File

@@ -225,11 +225,8 @@ namespace OpenRA.Mods.RA
{
var inQueue = Queue.Count(pi => pi.Item == order.TargetString);
var owned = self.Owner.World.ActorsWithTrait<Buildable>().Count(a => a.Actor.Info.Name == order.TargetString && a.Actor.Owner == self.Owner);
if (inQueue + owned >= bi.BuildLimit)
{
Sound.PlayNotification(self.Owner, "Speech", Info.BlockedAudio, self.Owner.Country.Race);
return;
}
if (inQueue + owned >= bi.BuildLimit)
return;
}
for (var n = 0; n < order.TargetLocation.X; n++) // repeat count

View File

@@ -366,7 +366,16 @@ namespace OpenRA.Mods.RA.Widgets
}
}
else
Sound.PlayNotification(world.LocalPlayer, "Speech", CurrentQueue.Info.QueuedAudio, world.LocalPlayer.Country.Race);
{
// Check if the item's build-limit has already been reached
var queued = CurrentQueue.AllQueued().Count(a => a.Item == unit.Name);
var inWorld = world.ActorsWithTrait<Buildable>().Count(a => a.Actor.Info.Name == unit.Name && a.Actor.Owner == world.LocalPlayer);
if (!((unit.Traits.Get<BuildableInfo>().BuildLimit != 0) && (inWorld + queued >= unit.Traits.Get<BuildableInfo>().BuildLimit)))
Sound.PlayNotification(world.LocalPlayer, "Speech", CurrentQueue.Info.QueuedAudio, world.LocalPlayer.Country.Race);
else
Sound.PlayNotification(world.LocalPlayer, "Speech", CurrentQueue.Info.BlockedAudio, world.LocalPlayer.Country.Race);
}
StartProduction(world, item);
}