Fix bot PlaceBuilding orders.
This commit is contained in:
committed by
RoosterDragon
parent
db0c6d88bf
commit
1e23c0a7b7
@@ -201,8 +201,11 @@ namespace OpenRA.Mods.Common.Orders
|
|||||||
// Building to place
|
// Building to place
|
||||||
TargetString = variants[0].ActorInfo.Name,
|
TargetString = variants[0].ActorInfo.Name,
|
||||||
|
|
||||||
// Pack the actor to associate the placement with and the alternate actor flag together
|
// Actor ID to associate with placement may be quite large, so it gets its own uint
|
||||||
ExtraLocation = new CPos((int)queue.Actor.ActorID, variant),
|
ExtraData = queue.Actor.ActorID,
|
||||||
|
|
||||||
|
// Actor variant will always be small enough to safely pack in a CPos
|
||||||
|
ExtraLocation = new CPos(variant, 0),
|
||||||
|
|
||||||
SuppressVisualFeedback = true
|
SuppressVisualFeedback = true
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
self.World.AddFrameEndTask(w =>
|
self.World.AddFrameEndTask(w =>
|
||||||
{
|
{
|
||||||
var prevItems = GetNumBuildables(self.Owner);
|
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);
|
var targetLocation = w.Map.CellContaining(order.Target.CenterPosition);
|
||||||
|
|
||||||
if (targetActor == null || targetActor.IsDead)
|
if (targetActor == null || targetActor.IsDead)
|
||||||
@@ -79,11 +79,11 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// Override with the alternate actor
|
// Override with the alternate actor
|
||||||
if (order.ExtraLocation.Y > 0)
|
if (order.ExtraLocation.X > 0)
|
||||||
{
|
{
|
||||||
var variant = actorInfo.TraitInfos<PlaceBuildingVariantsInfo>()
|
var variant = actorInfo.TraitInfos<PlaceBuildingVariantsInfo>()
|
||||||
.SelectMany(p => p.Actors)
|
.SelectMany(p => p.Actors)
|
||||||
.Skip(order.ExtraLocation.Y - 1)
|
.Skip(order.ExtraLocation.X - 1)
|
||||||
.FirstOrDefault();
|
.FirstOrDefault();
|
||||||
|
|
||||||
if (variant != null)
|
if (variant != null)
|
||||||
|
|||||||
Reference in New Issue
Block a user