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