fix linebuild

This commit is contained in:
Bob
2010-04-03 00:15:12 +12:00
committed by Chris Forbes
parent 2a5d756191
commit 3caa0a3431
2 changed files with 27 additions and 15 deletions

View File

@@ -57,13 +57,10 @@ namespace OpenRA.Orders
yield break; yield break;
} }
yield return new Order("PlaceBuilding", Producer.Owner.PlayerActor, topLeft, Building);
// Linebuild for walls.
// Assumes a 1x1 footprint; weird things will happen for other footprints
if (Rules.Info[ Building ].Traits.Contains<LineBuildInfo>()) if (Rules.Info[ Building ].Traits.Contains<LineBuildInfo>())
foreach( var t in LineBuildUtils.GetLineBuildCells( world, topLeft, Building, BuildingInfo )) yield return new Order("LineBuild", Producer.Owner.PlayerActor, topLeft, Building);
yield return new Order("PlaceBuilding", Producer.Owner.PlayerActor, t, Building); else
yield return new Order("PlaceBuilding", Producer.Owner.PlayerActor, topLeft, Building);
} }
} }

View File

@@ -28,7 +28,7 @@ namespace OpenRA.Traits
{ {
public void ResolveOrder( Actor self, Order order ) public void ResolveOrder( Actor self, Order order )
{ {
if( order.OrderString == "PlaceBuilding" ) if( order.OrderString == "PlaceBuilding" || order.OrderString == "LineBuild" )
{ {
self.World.AddFrameEndTask( _ => self.World.AddFrameEndTask( _ =>
{ {
@@ -39,10 +39,25 @@ namespace OpenRA.Traits
if( producing == null || producing.Item != order.TargetString || producing.RemainingTime != 0 ) if( producing == null || producing.Item != order.TargetString || producing.RemainingTime != 0 )
return; return;
var building = self.World.CreateActor( order.TargetString, order.TargetLocation, order.Player ); if( order.OrderString == "LineBuild" )
{
foreach (var s in building.Info.Traits.Get<BuildingInfo>().BuildSounds) bool playSounds = true;
Sound.PlayToPlayer(order.Player, s); var buildingInfo = unit.Traits.Get<BuildingInfo>();
foreach( var t in LineBuildUtils.GetLineBuildCells( self.World, order.TargetLocation, order.TargetString, buildingInfo ) )
{
var building = self.World.CreateActor( order.TargetString, order.TargetLocation, order.Player );
if( playSounds )
foreach( var s in building.Info.Traits.Get<BuildingInfo>().BuildSounds )
Sound.PlayToPlayer( order.Player, s );
playSounds = false;
}
}
else
{
var building = self.World.CreateActor( order.TargetString, order.TargetLocation, order.Player );
foreach (var s in building.Info.Traits.Get<BuildingInfo>().BuildSounds)
Sound.PlayToPlayer(order.Player, s);
}
var facts = self.World.Queries.OwnedBy[self.Owner] var facts = self.World.Queries.OwnedBy[self.Owner]
.WithTrait<ConstructionYard>().Select(x => x.Actor); .WithTrait<ConstructionYard>().Select(x => x.Actor);