fix linebuild
This commit is contained in:
@@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,31 +28,46 @@ 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( _ =>
|
||||||
{
|
{
|
||||||
var queue = self.traits.Get<ProductionQueue>();
|
var queue = self.traits.Get<ProductionQueue>();
|
||||||
var unit = Rules.Info[ order.TargetString ];
|
var unit = Rules.Info[ order.TargetString ];
|
||||||
var producing = queue.CurrentItem(unit.Category);
|
var producing = queue.CurrentItem(unit.Category);
|
||||||
|
|
||||||
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 );
|
|
||||||
|
|
||||||
foreach (var s in building.Info.Traits.Get<BuildingInfo>().BuildSounds)
|
if( order.OrderString == "LineBuild" )
|
||||||
Sound.PlayToPlayer(order.Player, s);
|
{
|
||||||
|
bool playSounds = true;
|
||||||
|
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);
|
||||||
|
|
||||||
var primaryFact = facts.Where(y => y.traits.Get<Production>().IsPrimary);
|
var primaryFact = facts.Where(y => y.traits.Get<Production>().IsPrimary);
|
||||||
var fact = (primaryFact.Count() > 0) ? primaryFact.FirstOrDefault() : facts.FirstOrDefault();
|
var fact = (primaryFact.Count() > 0) ? primaryFact.FirstOrDefault() : facts.FirstOrDefault();
|
||||||
|
|
||||||
if (fact != null)
|
if (fact != null)
|
||||||
fact.traits.Get<RenderBuilding>().PlayCustomAnim(fact, "build");
|
fact.traits.Get<RenderBuilding>().PlayCustomAnim(fact, "build");
|
||||||
|
|
||||||
queue.FinishProduction(unit.Category);
|
queue.FinishProduction(unit.Category);
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user