PlaceBuilding order is now handled by the player, not in UnitOrders.
This commit is contained in:
37
OpenRa.Game/Traits/PlaceBuilding.cs
Executable file
37
OpenRa.Game/Traits/PlaceBuilding.cs
Executable file
@@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using OpenRa.GameRules;
|
||||
|
||||
namespace OpenRa.Traits
|
||||
{
|
||||
class PlaceBuildingInfo : StatelessTraitInfo<PlaceBuilding> { }
|
||||
|
||||
class PlaceBuilding : IResolveOrder
|
||||
{
|
||||
public void ResolveOrder( Actor self, Order order )
|
||||
{
|
||||
if( order.OrderString == "PlaceBuilding" )
|
||||
{
|
||||
Game.world.AddFrameEndTask( _ =>
|
||||
{
|
||||
var queue = self.traits.Get<ProductionQueue>();
|
||||
var unit = Rules.ActorInfo[ order.TargetString ];
|
||||
var producing = queue.CurrentItem(unit.Category);
|
||||
if( producing == null || producing.Item != order.TargetString || producing.RemainingTime != 0 )
|
||||
return;
|
||||
|
||||
Game.world.CreateActor( order.TargetString, order.TargetLocation - Footprint.AdjustForBuildingSize( unit.Traits.Get<BuildingInfo>() ), order.Player );
|
||||
if (order.Player == Game.LocalPlayer)
|
||||
{
|
||||
Sound.Play("placbldg.aud");
|
||||
Sound.Play("build5.aud");
|
||||
}
|
||||
|
||||
queue.FinishProduction(unit.Category);
|
||||
} );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user