This commit is contained in:
Matthias Mailänder
2014-04-18 12:32:48 +02:00
parent 048289e6a9
commit fcca5a7683

View File

@@ -203,9 +203,9 @@ namespace OpenRA.Mods.RA
Queue[ 0 ].Tick(playerResources); Queue[ 0 ].Tick(playerResources);
} }
public void ResolveOrder( Actor self, Order order ) public void ResolveOrder(Actor self, Order order)
{ {
switch( order.OrderString ) switch(order.OrderString)
{ {
case "StartProduction": case "StartProduction":
{ {
@@ -225,45 +225,43 @@ namespace OpenRA.Mods.RA
{ {
var inQueue = Queue.Count(pi => pi.Item == order.TargetString); 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); 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) if (inQueue + owned >= bi.BuildLimit)
return; return;
} }
for (var n = 0; n < order.TargetLocation.X; n++) // repeat count for (var n = 0; n < order.TargetLocation.X; n++) // repeat count
{ {
bool hasPlayedSound = false; bool hasPlayedSound = false;
BeginProduction(new ProductionItem(this, order.TargetString, cost, PlayerPower, BeginProduction(new ProductionItem(this, order.TargetString, cost, PlayerPower,
() => self.World.AddFrameEndTask( () => self.World.AddFrameEndTask(_ =>
_ => {
var isBuilding = unit.Traits.Contains<BuildingInfo>();
if (isBuilding && !hasPlayedSound)
{ {
var isBuilding = unit.Traits.Contains<BuildingInfo>(); hasPlayedSound = Sound.PlayNotification(self.Owner, "Speech", Info.ReadyAudio, self.Owner.Country.Race);
}
if (isBuilding && !hasPlayedSound) else if (!isBuilding)
{
if (BuildUnit(order.TargetString))
Sound.PlayNotification(self.Owner, "Speech", Info.ReadyAudio, self.Owner.Country.Race);
else if (!hasPlayedSound && time > 0)
{ {
hasPlayedSound = Sound.PlayNotification(self.Owner, "Speech", Info.ReadyAudio, self.Owner.Country.Race); hasPlayedSound = Sound.PlayNotification(self.Owner, "Speech", Info.BlockedAudio, self.Owner.Country.Race);
} }
else if (!isBuilding) }
{ })));
if (BuildUnit(order.TargetString))
Sound.PlayNotification(self.Owner, "Speech", Info.ReadyAudio, self.Owner.Country.Race);
else if (!hasPlayedSound && time > 0)
{
hasPlayedSound = Sound.PlayNotification(self.Owner, "Speech", Info.BlockedAudio, self.Owner.Country.Race);
}
}
})));
} }
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].Paused = ( order.TargetLocation.X != 0 ); Queue[0].Paused = ( order.TargetLocation.X != 0 );
break; break;
} }
case "CancelProduction": case "CancelProduction":
{ {
CancelProduction(order.TargetString,order.TargetLocation.X); CancelProduction(order.TargetString, order.TargetLocation.X);
break; break;
} }
} }
@@ -309,14 +307,14 @@ namespace OpenRA.Mods.RA
Queue.RemoveAt(0); Queue.RemoveAt(0);
} }
protected void BeginProduction( ProductionItem item ) protected void BeginProduction(ProductionItem item)
{ {
Queue.Add(item); Queue.Add(item);
} }
// Builds a unit from the actor that holds this queue (1 queue per building) // Builds a unit from the actor that holds this queue (1 queue per building)
// Returns false if the unit can't be built // Returns false if the unit can't be built
protected virtual bool BuildUnit( string name ) protected virtual bool BuildUnit(string name)
{ {
// Cannot produce if i'm dead // Cannot produce if i'm dead
if (!self.IsInWorld || self.IsDead()) if (!self.IsInWorld || self.IsDead())
@@ -326,7 +324,7 @@ namespace OpenRA.Mods.RA
} }
var sp = self.TraitsImplementing<Production>().FirstOrDefault(p => p.Info.Produces.Contains(Info.Type)); var sp = self.TraitsImplementing<Production>().FirstOrDefault(p => p.Info.Produces.Contains(Info.Type));
if (sp != null && !self.IsDisabled() && sp.Produce(self, Rules.Info[ name ])) if (sp != null && !self.IsDisabled() && sp.Produce(self, Rules.Info[name]))
{ {
FinishProduction(); FinishProduction();
return true; return true;