Pause and Cancel orders for production.
This commit is contained in:
@@ -118,5 +118,15 @@ namespace OpenRa.Game
|
|||||||
{
|
{
|
||||||
return new Order(subject, "StartProduction", null, null, int2.Zero, item, Cursor.Default );
|
return new Order(subject, "StartProduction", null, null, int2.Zero, item, Cursor.Default );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Order PauseProduction(Player subject, string item, bool pause)
|
||||||
|
{
|
||||||
|
return new Order( subject, "PauseProduction", null, null, new int2(pause ?1:0,0), item, Cursor.Default );
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Order CancelProduction(Player subject, string item)
|
||||||
|
{
|
||||||
|
return new Order( subject, "CancelProduction", null, null, int2.Zero, item, Cursor.Default );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -217,9 +217,6 @@ namespace OpenRa.Game
|
|||||||
|
|
||||||
if( mi.Button == MouseButtons.Left && mi.Event == MouseInputEvent.Down )
|
if( mi.Button == MouseButtons.Left && mi.Event == MouseInputEvent.Down )
|
||||||
{
|
{
|
||||||
/* todo: move all this shit elsewhere! we can't have it in the UI if it's going to be
|
|
||||||
* correct in netplay!! */
|
|
||||||
|
|
||||||
if (producing == null)
|
if (producing == null)
|
||||||
{
|
{
|
||||||
Game.controller.AddOrder( Order.StartProduction( player, item.Tag ) );
|
Game.controller.AddOrder( Order.StartProduction( player, item.Tag ) );
|
||||||
@@ -230,7 +227,7 @@ namespace OpenRa.Game
|
|||||||
if (producing.Done)
|
if (producing.Done)
|
||||||
Build(item);
|
Build(item);
|
||||||
else
|
else
|
||||||
producing.Paused = false;
|
Game.controller.AddOrder( Order.PauseProduction( player, item.Tag, false ) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -244,12 +241,12 @@ namespace OpenRa.Game
|
|||||||
if (producing.Paused || producing.Done)
|
if (producing.Paused || producing.Done)
|
||||||
{
|
{
|
||||||
Game.PlaySound("cancld1.aud", false);
|
Game.PlaySound("cancld1.aud", false);
|
||||||
player.CancelProduction(Rules.UnitCategory[item.Tag]);
|
Game.controller.AddOrder( Order.CancelProduction( player, item.Tag ) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Game.PlaySound("onhold1.aud", false);
|
Game.PlaySound("onhold1.aud", false);
|
||||||
producing.Paused = true;
|
Game.controller.AddOrder( Order.PauseProduction( player, item.Tag, true ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -97,6 +97,20 @@ namespace OpenRa.Game
|
|||||||
order.Player.BeginProduction( group, new ProductionItem( order.TargetString, (int)time, ui.Cost, complete ) );
|
order.Player.BeginProduction( group, new ProductionItem( order.TargetString, (int)time, ui.Cost, complete ) );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case "PauseProduction":
|
||||||
|
{
|
||||||
|
var producing = order.Player.Producing( Rules.UnitCategory[ order.TargetString ] );
|
||||||
|
if( producing != null && producing.Item == order.TargetString )
|
||||||
|
producing.Paused = ( order.TargetLocation.X != 0 );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "CancelProduction":
|
||||||
|
{
|
||||||
|
var producing = order.Player.Producing( Rules.UnitCategory[ order.TargetString ] );
|
||||||
|
if( producing != null && producing.Item == order.TargetString )
|
||||||
|
order.Player.CancelProduction( Rules.UnitCategory[ order.TargetString ] );
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user