supporting cheap queues
This commit is contained in:
@@ -175,7 +175,8 @@ namespace OpenRa.Game
|
||||
var queue = Game.LocalPlayer.PlayerActor.traits.Get<Traits.ProductionQueue>();
|
||||
var item = queue.Producing( groupName );
|
||||
if (item != null)
|
||||
Game.controller.AddOrder(Order.CancelProduction(Game.LocalPlayer, item.Item));
|
||||
for( var n = 0; n <= item.Repeats; n++ )
|
||||
Game.controller.AddOrder(Order.CancelProduction(Game.LocalPlayer, item.Item));
|
||||
}
|
||||
|
||||
void ChooseAvailableTab()
|
||||
@@ -294,6 +295,13 @@ namespace OpenRa.Game
|
||||
ready.Play("hold");
|
||||
overlayBits.Add(Pair.New(ready.Image, overlayPos));
|
||||
}
|
||||
|
||||
if (currentItem.Repeats > 0)
|
||||
{
|
||||
ready.PlayFetchIndex("groups", () => currentItem.Repeats + 1);
|
||||
ready.Tick();
|
||||
overlayBits.Add(Pair.New(ready.Image, overlayPos));
|
||||
}
|
||||
}
|
||||
|
||||
var closureItem = item;
|
||||
@@ -349,7 +357,7 @@ namespace OpenRa.Game
|
||||
if (producing == null)
|
||||
{
|
||||
Game.controller.AddOrder(Order.StartProduction(player, item));
|
||||
Sound.Play("abldgin1.aud");
|
||||
Sound.Play((group == "Building" || group == "Defense") ? "abldgin1.aud" : "train1.aud");
|
||||
}
|
||||
else if (producing.Item == item)
|
||||
{
|
||||
@@ -358,8 +366,13 @@ namespace OpenRa.Game
|
||||
if (group == "Building" || group == "Defense")
|
||||
Game.controller.orderGenerator = new PlaceBuilding(player.PlayerActor, item);
|
||||
}
|
||||
else
|
||||
else if (producing.Paused)
|
||||
Game.controller.AddOrder(Order.PauseProduction(player, item, false));
|
||||
else
|
||||
{
|
||||
Sound.Play((group == "Building" || group == "Defense") ? "abldgin1.aud" : "train1.aud");
|
||||
Game.controller.AddOrder(Order.StartProduction(player, item));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -11,6 +11,8 @@ namespace OpenRa.Game
|
||||
public int RemainingTime { get; private set; }
|
||||
public int RemainingCost { get; private set; }
|
||||
|
||||
public int Repeats;
|
||||
|
||||
public bool Paused = false, Done = false;
|
||||
public Action OnComplete;
|
||||
|
||||
@@ -24,6 +26,14 @@ namespace OpenRa.Game
|
||||
OnComplete = onComplete;
|
||||
}
|
||||
|
||||
public void DoRepeat()
|
||||
{
|
||||
RemainingTime = TotalTime;
|
||||
RemainingCost = TotalCost;
|
||||
Done = false;
|
||||
--Repeats;
|
||||
}
|
||||
|
||||
public void Tick(Player player)
|
||||
{
|
||||
if (Done)
|
||||
|
||||
@@ -99,18 +99,33 @@ namespace OpenRa.Game.Traits
|
||||
{
|
||||
var item = production[ category ];
|
||||
if( item == null ) return;
|
||||
self.Owner.GiveCash( item.TotalCost - item.RemainingCost ); // refund what's been paid so far.
|
||||
FinishProduction( category );
|
||||
if (item.Repeats > 0)
|
||||
--item.Repeats;
|
||||
else
|
||||
{
|
||||
self.Owner.GiveCash(item.TotalCost - item.RemainingCost); // refund what's been paid so far.
|
||||
FinishProduction(category);
|
||||
}
|
||||
}
|
||||
|
||||
public void FinishProduction( string category )
|
||||
{
|
||||
production[ category ] = null;
|
||||
var item = production[category];
|
||||
if (item == null) return;
|
||||
if (item.Repeats > 0)
|
||||
item.DoRepeat();
|
||||
else
|
||||
production[category] = null;
|
||||
}
|
||||
|
||||
public void BeginProduction( string group, ProductionItem item )
|
||||
{
|
||||
if( production[ group ] != null ) return;
|
||||
if (production[group] != null)
|
||||
{
|
||||
if (production[group].Item == item.Item)
|
||||
++production[group].Repeats;
|
||||
return;
|
||||
}
|
||||
production[ group ] = item;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user