Remove Order.TargetLocation from building code.
This commit is contained in:
@@ -88,7 +88,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public void ResolveOrder(Actor self, Order order)
|
||||
{
|
||||
if (order.OrderString == OrderID)
|
||||
Location = order.TargetLocation;
|
||||
Location = self.World.Map.CellContaining(order.Target.CenterPosition);
|
||||
}
|
||||
|
||||
public static bool IsForceSet(Order order)
|
||||
|
||||
@@ -63,6 +63,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
var prevItems = GetNumBuildables(self.Owner);
|
||||
var targetActor = w.GetActorById(order.ExtraData);
|
||||
var targetLocation = w.Map.CellContaining(order.Target.CenterPosition);
|
||||
|
||||
if (targetActor == null || targetActor.IsDead)
|
||||
return;
|
||||
@@ -93,7 +94,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
// Build the parent actor first
|
||||
var placed = w.CreateActor(order.TargetString, new TypeDictionary
|
||||
{
|
||||
new LocationInit(order.TargetLocation),
|
||||
new LocationInit(targetLocation),
|
||||
new OwnerInit(order.Player),
|
||||
new FactionInit(faction),
|
||||
new PlaceBuildingInit()
|
||||
@@ -107,17 +108,17 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (string.IsNullOrEmpty(segmentType))
|
||||
segmentType = order.TargetString;
|
||||
|
||||
foreach (var t in BuildingUtils.GetLineBuildCells(w, order.TargetLocation, actorInfo, buildingInfo))
|
||||
foreach (var t in BuildingUtils.GetLineBuildCells(w, targetLocation, actorInfo, buildingInfo))
|
||||
{
|
||||
if (t.First == order.TargetLocation)
|
||||
if (t.First == targetLocation)
|
||||
continue;
|
||||
|
||||
w.CreateActor(t.First == order.TargetLocation ? order.TargetString : segmentType, new TypeDictionary
|
||||
w.CreateActor(t.First == targetLocation ? order.TargetString : segmentType, new TypeDictionary
|
||||
{
|
||||
new LocationInit(t.First),
|
||||
new OwnerInit(order.Player),
|
||||
new FactionInit(faction),
|
||||
new LineBuildDirectionInit(t.First.X == order.TargetLocation.X ? LineBuildDirection.Y : LineBuildDirection.X),
|
||||
new LineBuildDirectionInit(t.First.X == targetLocation.X ? LineBuildDirection.Y : LineBuildDirection.X),
|
||||
new LineBuildParentInit(new[] { t.Second, placed }),
|
||||
new PlaceBuildingInit()
|
||||
});
|
||||
@@ -125,7 +126,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
}
|
||||
else if (os == "PlacePlug")
|
||||
{
|
||||
var host = self.World.WorldActor.Trait<BuildingInfluence>().GetBuildingAt(order.TargetLocation);
|
||||
var host = self.World.WorldActor.Trait<BuildingInfluence>().GetBuildingAt(targetLocation);
|
||||
if (host == null)
|
||||
return;
|
||||
|
||||
@@ -135,7 +136,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
var location = host.Location;
|
||||
var pluggable = host.TraitsImplementing<Pluggable>()
|
||||
.FirstOrDefault(p => location + p.Info.Offset == order.TargetLocation && p.AcceptsPlug(host, plugInfo.Type));
|
||||
.FirstOrDefault(p => location + p.Info.Offset == targetLocation && p.AcceptsPlug(host, plugInfo.Type));
|
||||
|
||||
if (pluggable == null)
|
||||
return;
|
||||
@@ -146,15 +147,15 @@ namespace OpenRA.Mods.Common.Traits
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!self.World.CanPlaceBuilding(order.TargetLocation, actorInfo, buildingInfo, null)
|
||||
|| !buildingInfo.IsCloseEnoughToBase(self.World, order.Player, actorInfo, order.TargetLocation))
|
||||
if (!self.World.CanPlaceBuilding(targetLocation, actorInfo, buildingInfo, null)
|
||||
|| !buildingInfo.IsCloseEnoughToBase(self.World, order.Player, actorInfo, targetLocation))
|
||||
return;
|
||||
|
||||
var replacementInfo = actorInfo.TraitInfoOrDefault<ReplacementInfo>();
|
||||
if (replacementInfo != null)
|
||||
{
|
||||
var buildingInfluence = self.World.WorldActor.Trait<BuildingInfluence>();
|
||||
foreach (var t in buildingInfo.Tiles(order.TargetLocation))
|
||||
foreach (var t in buildingInfo.Tiles(targetLocation))
|
||||
{
|
||||
var host = buildingInfluence.GetBuildingAt(t);
|
||||
if (host != null)
|
||||
@@ -164,7 +165,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
var building = w.CreateActor(order.TargetString, new TypeDictionary
|
||||
{
|
||||
new LocationInit(order.TargetLocation),
|
||||
new LocationInit(targetLocation),
|
||||
new OwnerInit(order.Player),
|
||||
new FactionInit(faction),
|
||||
new PlaceBuildingInit()
|
||||
@@ -184,7 +185,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
// May be null if the build anywhere cheat is active
|
||||
// BuildingInfo.IsCloseEnoughToBase has already verified that this is a valid build location
|
||||
var provider = buildingInfo.FindBaseProvider(w, self.Owner, order.TargetLocation);
|
||||
var provider = buildingInfo.FindBaseProvider(w, self.Owner, targetLocation);
|
||||
if (provider != null)
|
||||
provider.BeginCooldown();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user