Fix bot PlaceBuilding orders.

This commit is contained in:
Paul Chote
2019-06-20 16:48:34 +00:00
committed by RoosterDragon
parent db0c6d88bf
commit 1e23c0a7b7
2 changed files with 8 additions and 5 deletions

View File

@@ -201,8 +201,11 @@ namespace OpenRA.Mods.Common.Orders
// Building to place
TargetString = variants[0].ActorInfo.Name,
// Pack the actor to associate the placement with and the alternate actor flag together
ExtraLocation = new CPos((int)queue.Actor.ActorID, variant),
// Actor ID to associate with placement may be quite large, so it gets its own uint
ExtraData = queue.Actor.ActorID,
// Actor variant will always be small enough to safely pack in a CPos
ExtraLocation = new CPos(variant, 0),
SuppressVisualFeedback = true
};

View File

@@ -59,7 +59,7 @@ namespace OpenRA.Mods.Common.Traits
self.World.AddFrameEndTask(w =>
{
var prevItems = GetNumBuildables(self.Owner);
var targetActor = w.GetActorById((uint)order.ExtraLocation.X);
var targetActor = w.GetActorById(order.ExtraData);
var targetLocation = w.Map.CellContaining(order.Target.CenterPosition);
if (targetActor == null || targetActor.IsDead)
@@ -79,11 +79,11 @@ namespace OpenRA.Mods.Common.Traits
return;
// Override with the alternate actor
if (order.ExtraLocation.Y > 0)
if (order.ExtraLocation.X > 0)
{
var variant = actorInfo.TraitInfos<PlaceBuildingVariantsInfo>()
.SelectMany(p => p.Actors)
.Skip(order.ExtraLocation.Y - 1)
.Skip(order.ExtraLocation.X - 1)
.FirstOrDefault();
if (variant != null)