PlaceBuilding order is now handled by the player, not in UnitOrders.
This commit is contained in:
@@ -229,6 +229,7 @@
|
|||||||
<Compile Include="Traits\LightPaletteRotator.cs" />
|
<Compile Include="Traits\LightPaletteRotator.cs" />
|
||||||
<Compile Include="Traits\LimitedAmmo.cs" />
|
<Compile Include="Traits\LimitedAmmo.cs" />
|
||||||
<Compile Include="Traits\Passenger.cs" />
|
<Compile Include="Traits\Passenger.cs" />
|
||||||
|
<Compile Include="Traits\PlaceBuilding.cs" />
|
||||||
<Compile Include="Traits\ProvidesRadar.cs" />
|
<Compile Include="Traits\ProvidesRadar.cs" />
|
||||||
<Compile Include="Traits\Repairable.cs" />
|
<Compile Include="Traits\Repairable.cs" />
|
||||||
<Compile Include="Traits\Reservable.cs" />
|
<Compile Include="Traits\Reservable.cs" />
|
||||||
|
|||||||
@@ -12,27 +12,6 @@ namespace OpenRa.Orders
|
|||||||
{
|
{
|
||||||
switch( order.OrderString )
|
switch( order.OrderString )
|
||||||
{
|
{
|
||||||
case "PlaceBuilding":
|
|
||||||
{
|
|
||||||
Game.world.AddFrameEndTask( _ =>
|
|
||||||
{
|
|
||||||
var queue = order.Player.PlayerActor.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);
|
|
||||||
} );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "Chat":
|
case "Chat":
|
||||||
{
|
{
|
||||||
Game.chat.AddLine(order.Player, order.TargetString);
|
Game.chat.AddLine(order.Player, order.TargetString);
|
||||||
|
|||||||
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);
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
Player:
|
Player:
|
||||||
ProductionQueue:
|
ProductionQueue:
|
||||||
|
PlaceBuilding:
|
||||||
|
|
||||||
World:
|
World:
|
||||||
WaterPaletteRotation:
|
WaterPaletteRotation:
|
||||||
|
|||||||
Reference in New Issue
Block a user