Add PlaceBuildingVariant trait.
This commit is contained in:
@@ -36,15 +36,58 @@ namespace OpenRA.Mods.Common.Orders
|
|||||||
IEnumerable<IRenderable> Render(WorldRenderer wr, CPos topLeft, Dictionary<CPos, PlaceBuildingCellType> footprint);
|
IEnumerable<IRenderable> Render(WorldRenderer wr, CPos topLeft, Dictionary<CPos, PlaceBuildingCellType> footprint);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class PlaceBuildingOrderGenerator : OrderGenerator
|
public class PlaceBuildingOrderGenerator : IOrderGenerator
|
||||||
{
|
{
|
||||||
|
class VariantWrapper
|
||||||
|
{
|
||||||
|
public readonly ActorInfo ActorInfo;
|
||||||
|
public readonly BuildingInfo BuildingInfo;
|
||||||
|
public readonly PlugInfo PlugInfo;
|
||||||
|
public readonly LineBuildInfo LineBuildInfo;
|
||||||
|
public readonly IPlaceBuildingPreview Preview;
|
||||||
|
|
||||||
|
public VariantWrapper(WorldRenderer wr, ProductionQueue queue, ActorInfo ai)
|
||||||
|
{
|
||||||
|
ActorInfo = ai;
|
||||||
|
BuildingInfo = ActorInfo.TraitInfo<BuildingInfo>();
|
||||||
|
PlugInfo = ActorInfo.TraitInfoOrDefault<PlugInfo>();
|
||||||
|
LineBuildInfo = ActorInfo.TraitInfoOrDefault<LineBuildInfo>();
|
||||||
|
|
||||||
|
var previewGeneratorInfo = ActorInfo.TraitInfoOrDefault<IPlaceBuildingPreviewGeneratorInfo>();
|
||||||
|
if (previewGeneratorInfo != null)
|
||||||
|
{
|
||||||
|
string faction;
|
||||||
|
var buildableInfo = ActorInfo.TraitInfoOrDefault<BuildableInfo>();
|
||||||
|
if (buildableInfo != null && buildableInfo.ForceFaction != null)
|
||||||
|
faction = buildableInfo.ForceFaction;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var mostLikelyProducer = queue.MostLikelyProducer();
|
||||||
|
faction = mostLikelyProducer.Trait != null ? mostLikelyProducer.Trait.Faction : queue.Actor.Owner.Faction.InternalName;
|
||||||
|
}
|
||||||
|
|
||||||
|
var td = new TypeDictionary()
|
||||||
|
{
|
||||||
|
new FactionInit(faction),
|
||||||
|
new OwnerInit(queue.Actor.Owner),
|
||||||
|
};
|
||||||
|
|
||||||
|
foreach (var api in ActorInfo.TraitInfos<IActorPreviewInitInfo>())
|
||||||
|
foreach (var o in api.ActorPreviewInits(ActorInfo, ActorPreviewType.PlaceBuilding))
|
||||||
|
td.Add(o);
|
||||||
|
|
||||||
|
Preview = previewGeneratorInfo.CreatePreview(wr, ActorInfo, td);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
readonly ProductionQueue queue;
|
readonly ProductionQueue queue;
|
||||||
readonly PlaceBuildingInfo placeBuildingInfo;
|
readonly PlaceBuildingInfo placeBuildingInfo;
|
||||||
readonly BuildingInfluence buildingInfluence;
|
readonly BuildingInfluence buildingInfluence;
|
||||||
|
readonly ResourceLayer resourceLayer;
|
||||||
readonly Viewport viewport;
|
readonly Viewport viewport;
|
||||||
readonly ActorInfo actorInfo;
|
readonly VariantWrapper[] variants;
|
||||||
readonly BuildingInfo buildingInfo;
|
int variant;
|
||||||
readonly IPlaceBuildingPreview preview;
|
|
||||||
|
|
||||||
public PlaceBuildingOrderGenerator(ProductionQueue queue, string name, WorldRenderer worldRenderer)
|
public PlaceBuildingOrderGenerator(ProductionQueue queue, string name, WorldRenderer worldRenderer)
|
||||||
{
|
{
|
||||||
@@ -52,37 +95,23 @@ namespace OpenRA.Mods.Common.Orders
|
|||||||
this.queue = queue;
|
this.queue = queue;
|
||||||
placeBuildingInfo = queue.Actor.Owner.PlayerActor.Info.TraitInfo<PlaceBuildingInfo>();
|
placeBuildingInfo = queue.Actor.Owner.PlayerActor.Info.TraitInfo<PlaceBuildingInfo>();
|
||||||
buildingInfluence = world.WorldActor.Trait<BuildingInfluence>();
|
buildingInfluence = world.WorldActor.Trait<BuildingInfluence>();
|
||||||
|
resourceLayer = world.WorldActor.TraitOrDefault<ResourceLayer>();
|
||||||
viewport = worldRenderer.Viewport;
|
viewport = worldRenderer.Viewport;
|
||||||
|
|
||||||
// Clear selection if using Left-Click Orders
|
// Clear selection if using Left-Click Orders
|
||||||
if (Game.Settings.Game.UseClassicMouseStyle)
|
if (Game.Settings.Game.UseClassicMouseStyle)
|
||||||
world.Selection.Clear();
|
world.Selection.Clear();
|
||||||
|
|
||||||
actorInfo = world.Map.Rules.Actors[name];
|
var variants = new List<VariantWrapper>()
|
||||||
buildingInfo = actorInfo.TraitInfo<BuildingInfo>();
|
|
||||||
|
|
||||||
var previewGeneratorInfo = actorInfo.TraitInfoOrDefault<IPlaceBuildingPreviewGeneratorInfo>();
|
|
||||||
if (previewGeneratorInfo != null)
|
|
||||||
{
|
{
|
||||||
var faction = actorInfo.TraitInfo<BuildableInfo>().ForceFaction;
|
new VariantWrapper(worldRenderer, queue, world.Map.Rules.Actors[name])
|
||||||
if (faction == null)
|
};
|
||||||
{
|
|
||||||
var mostLikelyProducer = queue.MostLikelyProducer();
|
|
||||||
faction = mostLikelyProducer.Trait != null ? mostLikelyProducer.Trait.Faction : queue.Actor.Owner.Faction.InternalName;
|
|
||||||
}
|
|
||||||
|
|
||||||
var td = new TypeDictionary()
|
foreach (var v in variants[0].ActorInfo.TraitInfos<PlaceBuildingVariantsInfo>())
|
||||||
{
|
foreach (var a in v.Actors)
|
||||||
new FactionInit(faction),
|
variants.Add(new VariantWrapper(worldRenderer, queue, world.Map.Rules.Actors[a]));
|
||||||
new OwnerInit(queue.Actor.Owner),
|
|
||||||
};
|
|
||||||
|
|
||||||
foreach (var api in actorInfo.TraitInfos<IActorPreviewInitInfo>())
|
this.variants = variants.ToArray();
|
||||||
foreach (var o in api.ActorPreviewInits(actorInfo, ActorPreviewType.PlaceBuilding))
|
|
||||||
td.Add(o);
|
|
||||||
|
|
||||||
preview = previewGeneratorInfo.CreatePreview(worldRenderer, actorInfo, td);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PlaceBuildingCellType MakeCellType(bool valid, bool lineBuild = false)
|
PlaceBuildingCellType MakeCellType(bool valid, bool lineBuild = false)
|
||||||
@@ -94,20 +123,25 @@ namespace OpenRA.Mods.Common.Orders
|
|||||||
return cell;
|
return cell;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override IEnumerable<Order> OrderInner(World world, CPos cell, int2 worldPixel, MouseInput mi)
|
public IEnumerable<Order> Order(World world, CPos cell, int2 worldPixel, MouseInput mi)
|
||||||
{
|
{
|
||||||
if (mi.Button == MouseButton.Right)
|
if ((mi.Button == MouseButton.Left && mi.Event == MouseInputEvent.Down) || (mi.Button == MouseButton.Right && mi.Event == MouseInputEvent.Up))
|
||||||
world.CancelInputMode();
|
{
|
||||||
|
if (mi.Button == MouseButton.Right)
|
||||||
|
world.CancelInputMode();
|
||||||
|
|
||||||
var ret = InnerOrder(world, cell, mi).ToArray();
|
var ret = InnerOrder(world, cell, mi).ToArray();
|
||||||
|
|
||||||
// If there was a successful placement order
|
// If there was a successful placement order
|
||||||
if (ret.Any(o => o.OrderString == "PlaceBuilding"
|
if (ret.Any(o => o.OrderString == "PlaceBuilding"
|
||||||
|| o.OrderString == "LineBuild"
|
|| o.OrderString == "LineBuild"
|
||||||
|| o.OrderString == "PlacePlug"))
|
|| o.OrderString == "PlacePlug"))
|
||||||
world.CancelInputMode();
|
world.CancelInputMode();
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Enumerable.Empty<Order>();
|
||||||
}
|
}
|
||||||
|
|
||||||
CPos TopLeft
|
CPos TopLeft
|
||||||
@@ -115,8 +149,8 @@ namespace OpenRA.Mods.Common.Orders
|
|||||||
get
|
get
|
||||||
{
|
{
|
||||||
var offsetPos = Viewport.LastMousePos;
|
var offsetPos = Viewport.LastMousePos;
|
||||||
if (preview != null)
|
if (variants[variant].Preview != null)
|
||||||
offsetPos += preview.TopLeftScreenOffset;
|
offsetPos += variants[variant].Preview.TopLeftScreenOffset;
|
||||||
|
|
||||||
return viewport.ViewToWorld(offsetPos);
|
return viewport.ViewToWorld(offsetPos);
|
||||||
}
|
}
|
||||||
@@ -128,12 +162,15 @@ namespace OpenRA.Mods.Common.Orders
|
|||||||
yield break;
|
yield break;
|
||||||
|
|
||||||
var owner = queue.Actor.Owner;
|
var owner = queue.Actor.Owner;
|
||||||
|
var ai = variants[variant].ActorInfo;
|
||||||
|
var bi = variants[variant].BuildingInfo;
|
||||||
|
|
||||||
if (mi.Button == MouseButton.Left)
|
if (mi.Button == MouseButton.Left)
|
||||||
{
|
{
|
||||||
var orderType = "PlaceBuilding";
|
var orderType = "PlaceBuilding";
|
||||||
var topLeft = TopLeft;
|
var topLeft = TopLeft;
|
||||||
|
|
||||||
var plugInfo = actorInfo.TraitInfoOrDefault<PlugInfo>();
|
var plugInfo = ai.TraitInfoOrDefault<PlugInfo>();
|
||||||
if (plugInfo != null)
|
if (plugInfo != null)
|
||||||
{
|
{
|
||||||
orderType = "PlacePlug";
|
orderType = "PlacePlug";
|
||||||
@@ -145,8 +182,8 @@ namespace OpenRA.Mods.Common.Orders
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!world.CanPlaceBuilding(topLeft, actorInfo, buildingInfo, null)
|
if (!world.CanPlaceBuilding(topLeft, ai, bi, null)
|
||||||
|| !buildingInfo.IsCloseEnoughToBase(world, owner, actorInfo, topLeft))
|
|| !bi.IsCloseEnoughToBase(world, owner, ai, topLeft))
|
||||||
{
|
{
|
||||||
foreach (var order in ClearBlockersOrders(world, topLeft))
|
foreach (var order in ClearBlockersOrders(world, topLeft))
|
||||||
yield return order;
|
yield return order;
|
||||||
@@ -155,29 +192,31 @@ namespace OpenRA.Mods.Common.Orders
|
|||||||
yield break;
|
yield break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (actorInfo.HasTraitInfo<LineBuildInfo>() && !mi.Modifiers.HasModifier(Modifiers.Shift))
|
if (ai.HasTraitInfo<LineBuildInfo>() && !mi.Modifiers.HasModifier(Modifiers.Shift))
|
||||||
orderType = "LineBuild";
|
orderType = "LineBuild";
|
||||||
}
|
}
|
||||||
|
|
||||||
yield return new Order(orderType, owner.PlayerActor, Target.FromCell(world, topLeft), false)
|
yield return new Order(orderType, owner.PlayerActor, Target.FromCell(world, topLeft), false)
|
||||||
{
|
{
|
||||||
// Building to place
|
// Building to place
|
||||||
TargetString = actorInfo.Name,
|
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 to associate the placement with
|
|
||||||
ExtraData = queue.Actor.ActorID,
|
|
||||||
SuppressVisualFeedback = true
|
SuppressVisualFeedback = true
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Tick(World world)
|
void IOrderGenerator.Tick(World world)
|
||||||
{
|
{
|
||||||
if (queue.AllQueued().All(i => !i.Done || i.Item != actorInfo.Name))
|
if (queue.AllQueued().All(i => !i.Done || i.Item != variants[0].ActorInfo.Name))
|
||||||
world.CancelInputMode();
|
world.CancelInputMode();
|
||||||
|
|
||||||
if (preview != null)
|
foreach (var v in variants)
|
||||||
preview.Tick();
|
if (v.Preview != null)
|
||||||
|
v.Preview.Tick();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AcceptsPlug(CPos cell, PlugInfo plug)
|
bool AcceptsPlug(CPos cell, PlugInfo plug)
|
||||||
@@ -190,12 +229,18 @@ namespace OpenRA.Mods.Common.Orders
|
|||||||
return host.TraitsImplementing<Pluggable>().Any(p => location + p.Info.Offset == cell && p.AcceptsPlug(host, plug.Type));
|
return host.TraitsImplementing<Pluggable>().Any(p => location + p.Info.Offset == cell && p.AcceptsPlug(host, plug.Type));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override IEnumerable<IRenderable> Render(WorldRenderer wr, World world) { yield break; }
|
IEnumerable<IRenderable> IOrderGenerator.Render(WorldRenderer wr, World world) { yield break; }
|
||||||
protected override IEnumerable<IRenderable> RenderAboveShroud(WorldRenderer wr, World world)
|
IEnumerable<IRenderable> IOrderGenerator.RenderAboveShroud(WorldRenderer wr, World world)
|
||||||
{
|
{
|
||||||
var topLeft = TopLeft;
|
var topLeft = TopLeft;
|
||||||
var footprint = new Dictionary<CPos, PlaceBuildingCellType>();
|
var footprint = new Dictionary<CPos, PlaceBuildingCellType>();
|
||||||
var plugInfo = actorInfo.TraitInfoOrDefault<PlugInfo>();
|
var activeVariant = variants[variant];
|
||||||
|
var actorInfo = activeVariant.ActorInfo;
|
||||||
|
var buildingInfo = activeVariant.BuildingInfo;
|
||||||
|
var plugInfo = activeVariant.PlugInfo;
|
||||||
|
var lineBuildInfo = activeVariant.LineBuildInfo;
|
||||||
|
var preview = activeVariant.Preview;
|
||||||
|
|
||||||
if (plugInfo != null)
|
if (plugInfo != null)
|
||||||
{
|
{
|
||||||
if (buildingInfo.Dimensions.X != 1 || buildingInfo.Dimensions.Y != 1)
|
if (buildingInfo.Dimensions.X != 1 || buildingInfo.Dimensions.Y != 1)
|
||||||
@@ -203,7 +248,7 @@ namespace OpenRA.Mods.Common.Orders
|
|||||||
|
|
||||||
footprint.Add(topLeft, MakeCellType(AcceptsPlug(topLeft, plugInfo)));
|
footprint.Add(topLeft, MakeCellType(AcceptsPlug(topLeft, plugInfo)));
|
||||||
}
|
}
|
||||||
else if (actorInfo.HasTraitInfo<LineBuildInfo>())
|
else if (lineBuildInfo != null)
|
||||||
{
|
{
|
||||||
// Linebuild for walls.
|
// Linebuild for walls.
|
||||||
if (buildingInfo.Dimensions.X != 1 || buildingInfo.Dimensions.Y != 1)
|
if (buildingInfo.Dimensions.X != 1 || buildingInfo.Dimensions.Y != 1)
|
||||||
@@ -225,20 +270,34 @@ namespace OpenRA.Mods.Common.Orders
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var res = world.WorldActor.TraitOrDefault<ResourceLayer>();
|
|
||||||
var isCloseEnough = buildingInfo.IsCloseEnoughToBase(world, world.LocalPlayer, actorInfo, topLeft);
|
var isCloseEnough = buildingInfo.IsCloseEnoughToBase(world, world.LocalPlayer, actorInfo, topLeft);
|
||||||
foreach (var t in buildingInfo.Tiles(topLeft))
|
foreach (var t in buildingInfo.Tiles(topLeft))
|
||||||
footprint.Add(t, MakeCellType(isCloseEnough && world.IsCellBuildable(t, actorInfo, buildingInfo) && (res == null || res.GetResource(t) == null)));
|
footprint.Add(t, MakeCellType(isCloseEnough && world.IsCellBuildable(t, actorInfo, buildingInfo) && (resourceLayer == null || resourceLayer.GetResource(t) == null)));
|
||||||
}
|
}
|
||||||
|
|
||||||
return preview != null ? preview.Render(wr, topLeft, footprint) : Enumerable.Empty<IRenderable>();
|
return preview != null ? preview.Render(wr, topLeft, footprint) : Enumerable.Empty<IRenderable>();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override string GetCursor(World world, CPos cell, int2 worldPixel, MouseInput mi) { return "default"; }
|
string IOrderGenerator.GetCursor(World world, CPos cell, int2 worldPixel, MouseInput mi) { return "default"; }
|
||||||
|
|
||||||
|
bool IOrderGenerator.HandleKeyPress(KeyInput e)
|
||||||
|
{
|
||||||
|
if (variants.Length > 0 && placeBuildingInfo.ToggleVariantKey.IsActivatedBy(e))
|
||||||
|
{
|
||||||
|
if (++variant >= variants.Length)
|
||||||
|
variant = 0;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void IOrderGenerator.Deactivate() { }
|
||||||
|
|
||||||
IEnumerable<Order> ClearBlockersOrders(World world, CPos topLeft)
|
IEnumerable<Order> ClearBlockersOrders(World world, CPos topLeft)
|
||||||
{
|
{
|
||||||
var allTiles = buildingInfo.Tiles(topLeft).ToArray();
|
var allTiles = variants[variant].BuildingInfo.Tiles(topLeft).ToArray();
|
||||||
var neightborTiles = Util.ExpandFootprint(allTiles, true).Except(allTiles)
|
var neightborTiles = Util.ExpandFootprint(allTiles, true).Except(allTiles)
|
||||||
.Where(world.Map.Contains).ToList();
|
.Where(world.Map.Contains).ToList();
|
||||||
|
|
||||||
|
|||||||
28
OpenRA.Mods.Common/Traits/Buildings/PlaceBuildingVariants.cs
Normal file
28
OpenRA.Mods.Common/Traits/Buildings/PlaceBuildingVariants.cs
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
#region Copyright & License Information
|
||||||
|
/*
|
||||||
|
* Copyright 2007-2019 The OpenRA Developers (see AUTHORS)
|
||||||
|
* This file is part of OpenRA, which is free software. It is made
|
||||||
|
* available to you under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation, either version 3 of
|
||||||
|
* the License, or (at your option) any later version. For more
|
||||||
|
* information, see COPYING.
|
||||||
|
*/
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using OpenRA.Traits;
|
||||||
|
|
||||||
|
namespace OpenRA.Mods.Common.Traits
|
||||||
|
{
|
||||||
|
[Desc("Place a different building when PlaceBuilding's ToggleVariantKey hotkey is pressed while the PlaceBuildingOrderGenerator is active.")]
|
||||||
|
public class PlaceBuildingVariantsInfo : TraitInfo<PlaceBuildingVariants>, Requires<BuildingInfo>, Requires<BuildableInfo>
|
||||||
|
{
|
||||||
|
[FieldLoader.Require]
|
||||||
|
[ActorReference(typeof(BuildingInfo))]
|
||||||
|
[Desc("Variant actors that can be cycled between when placing a structure.")]
|
||||||
|
public readonly string[] Actors = null;
|
||||||
|
|
||||||
|
public override object Create(ActorInitializer init) { return new PlaceBuildingVariants(); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class PlaceBuildingVariants { }
|
||||||
|
}
|
||||||
@@ -31,6 +31,9 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
[NotificationReference("Speech")]
|
[NotificationReference("Speech")]
|
||||||
public readonly string CannotPlaceNotification = null;
|
public readonly string CannotPlaceNotification = null;
|
||||||
|
|
||||||
|
[Desc("Hotkey to toggle between PlaceBuildingVariants when placing a structure.")]
|
||||||
|
public HotkeyReference ToggleVariantKey = new HotkeyReference();
|
||||||
|
|
||||||
public object Create(ActorInitializer init) { return new PlaceBuilding(this); }
|
public object Create(ActorInitializer init) { return new PlaceBuilding(this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,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(order.ExtraData);
|
var targetActor = w.GetActorById((uint)order.ExtraLocation.X);
|
||||||
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)
|
||||||
@@ -75,6 +78,18 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
if (item == null)
|
if (item == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// Override with the alternate actor
|
||||||
|
if (order.ExtraLocation.Y > 0)
|
||||||
|
{
|
||||||
|
var variant = actorInfo.TraitInfos<PlaceBuildingVariantsInfo>()
|
||||||
|
.SelectMany(p => p.Actors)
|
||||||
|
.Skip(order.ExtraLocation.Y - 1)
|
||||||
|
.FirstOrDefault();
|
||||||
|
|
||||||
|
if (variant != null)
|
||||||
|
actorInfo = self.World.Map.Rules.Actors[variant];
|
||||||
|
}
|
||||||
|
|
||||||
var producer = queue.MostLikelyProducer();
|
var producer = queue.MostLikelyProducer();
|
||||||
var faction = producer.Trait != null ? producer.Trait.Faction : self.Owner.Faction.InternalName;
|
var faction = producer.Trait != null ? producer.Trait.Faction : self.Owner.Faction.InternalName;
|
||||||
var buildingInfo = actorInfo.TraitInfo<BuildingInfo>();
|
var buildingInfo = actorInfo.TraitInfo<BuildingInfo>();
|
||||||
@@ -86,7 +101,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
if (os == "LineBuild")
|
if (os == "LineBuild")
|
||||||
{
|
{
|
||||||
// Build the parent actor first
|
// Build the parent actor first
|
||||||
var placed = w.CreateActor(order.TargetString, new TypeDictionary
|
var placed = w.CreateActor(actorInfo.Name, new TypeDictionary
|
||||||
{
|
{
|
||||||
new LocationInit(targetLocation),
|
new LocationInit(targetLocation),
|
||||||
new OwnerInit(order.Player),
|
new OwnerInit(order.Player),
|
||||||
@@ -100,14 +115,14 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
// Build the connection segments
|
// Build the connection segments
|
||||||
var segmentType = actorInfo.TraitInfo<LineBuildInfo>().SegmentType;
|
var segmentType = actorInfo.TraitInfo<LineBuildInfo>().SegmentType;
|
||||||
if (string.IsNullOrEmpty(segmentType))
|
if (string.IsNullOrEmpty(segmentType))
|
||||||
segmentType = order.TargetString;
|
segmentType = actorInfo.Name;
|
||||||
|
|
||||||
foreach (var t in BuildingUtils.GetLineBuildCells(w, targetLocation, actorInfo, buildingInfo))
|
foreach (var t in BuildingUtils.GetLineBuildCells(w, targetLocation, actorInfo, buildingInfo))
|
||||||
{
|
{
|
||||||
if (t.First == targetLocation)
|
if (t.First == targetLocation)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
w.CreateActor(t.First == targetLocation ? order.TargetString : segmentType, new TypeDictionary
|
w.CreateActor(t.First == targetLocation ? actorInfo.Name : segmentType, new TypeDictionary
|
||||||
{
|
{
|
||||||
new LocationInit(t.First),
|
new LocationInit(t.First),
|
||||||
new OwnerInit(order.Player),
|
new OwnerInit(order.Player),
|
||||||
@@ -157,7 +172,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var building = w.CreateActor(order.TargetString, new TypeDictionary
|
var building = w.CreateActor(actorInfo.Name, new TypeDictionary
|
||||||
{
|
{
|
||||||
new LocationInit(targetLocation),
|
new LocationInit(targetLocation),
|
||||||
new OwnerInit(order.Player),
|
new OwnerInit(order.Player),
|
||||||
|
|||||||
Reference in New Issue
Block a user