started working on the Player-Actor.
This commit is contained in:
@@ -24,6 +24,9 @@ namespace OpenRa.Game
|
||||
case "DeliverOre":
|
||||
case "Harvest":
|
||||
case "SetRallyPoint":
|
||||
case "StartProduction":
|
||||
case "PauseProduction":
|
||||
case "CancelProduction":
|
||||
{
|
||||
foreach( var t in order.Subject.traits.WithInterface<IOrder>() )
|
||||
t.ResolveOrder( order.Subject, order );
|
||||
@@ -51,52 +54,6 @@ namespace OpenRa.Game
|
||||
} );
|
||||
break;
|
||||
}
|
||||
case "StartProduction":
|
||||
{
|
||||
string group = Rules.UnitCategory[ order.TargetString ];
|
||||
var ui = Rules.UnitInfo[ order.TargetString ];
|
||||
var time = ui.Cost
|
||||
* Rules.General.BuildSpeed /* todo: country-specific build speed bonus */
|
||||
* (25 * 60) /* frames per min */ /* todo: build acceleration, if we do that */
|
||||
/ 1000;
|
||||
|
||||
time = .08f * time; /* temporary hax so we can build stuff fast for test */
|
||||
|
||||
if (!Rules.TechTree.BuildableItems(order.Player, group).Contains(order.TargetString))
|
||||
return; /* you can't build that!! */
|
||||
|
||||
bool hasPlayedSound = false;
|
||||
|
||||
order.Player.BeginProduction(group,
|
||||
new ProductionItem(order.TargetString, (int)time, ui.Cost,
|
||||
() => Game.world.AddFrameEndTask(
|
||||
_ =>
|
||||
{
|
||||
var isBuilding = group == "Building" || group == "Defense";
|
||||
if (!hasPlayedSound && order.Player == Game.LocalPlayer)
|
||||
{
|
||||
Sound.Play(isBuilding ? "conscmp1.aud" : "unitrdy1.aud");
|
||||
hasPlayedSound = true;
|
||||
}
|
||||
if (!isBuilding)
|
||||
Game.BuildUnit(order.Player, order.TargetString);
|
||||
})));
|
||||
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;
|
||||
}
|
||||
case "Chat":
|
||||
{
|
||||
Game.chat.AddLine(order.Player, order.TargetString);
|
||||
|
||||
Reference in New Issue
Block a user