Skip to content

Commit

Permalink
Check for placeablilty of LineBuild Segment instead of the Post.
Browse files Browse the repository at this point in the history
  • Loading branch information
MustaphaTR authored and abcdefg30 committed Mar 11, 2022
1 parent 153bd14 commit a7004b2
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
12 changes: 10 additions & 2 deletions OpenRA.Mods.Common/Orders/PlaceBuildingOrderGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -263,10 +263,18 @@ IEnumerable<IRenderable> IOrderGenerator.RenderAboveShroud(WorldRenderer wr, Wor

if (!Game.GetModifierKeys().HasModifier(Modifiers.Shift))
{
var segmentInfo = actorInfo;
var segmentBuildingInfo = buildingInfo;
if (!string.IsNullOrEmpty(lineBuildInfo.SegmentType))
{
segmentInfo = world.Map.Rules.Actors[lineBuildInfo.SegmentType];
segmentBuildingInfo = segmentInfo.TraitInfo<BuildingInfo>();
}

foreach (var t in BuildingUtils.GetLineBuildCells(world, topLeft, actorInfo, buildingInfo, owner))
{
var lineBuildable = world.IsCellBuildable(t.Cell, actorInfo, buildingInfo);
var lineCloseEnough = buildingInfo.IsCloseEnoughToBase(world, world.LocalPlayer, actorInfo, t.Cell);
var lineBuildable = world.IsCellBuildable(t.Cell, segmentInfo, segmentBuildingInfo);
var lineCloseEnough = segmentBuildingInfo.IsCloseEnoughToBase(world, world.LocalPlayer, segmentInfo, t.Cell);
footprint.Add(t.Cell, MakeCellType(lineBuildable && lineCloseEnough, true));
}
}
Expand Down
10 changes: 9 additions & 1 deletion OpenRA.Mods.Common/Traits/Buildings/BuildingUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,17 @@ public static IEnumerable<(CPos Cell, Actor Actor)> GetLineBuildCells(World worl
if (dirs[d] != 0)
continue;

var segmentInfo = ai;
var segmentBuildingInfo = bi;
if (!string.IsNullOrEmpty(lbi.SegmentType))
{
segmentInfo = world.Map.Rules.Actors[lbi.SegmentType];
segmentBuildingInfo = segmentInfo.TraitInfo<BuildingInfo>();
}

// Continue the search if the cell is empty or not visible
var c = topLeft + i * vecs[d];
if (world.IsCellBuildable(c, ai, bi) || !owner.Shroud.IsExplored(c))
if (world.IsCellBuildable(c, segmentInfo, segmentBuildingInfo) || !owner.Shroud.IsExplored(c))
continue;

// Cell contains an actor. Is it the type we want?
Expand Down
3 changes: 3 additions & 0 deletions mods/ts/rules/nod-support.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ NAFNCE:
EnergyWall:
ActiveCondition: active-posts == 2
Weapon: LaserFence
TerrainTypes: Clear, Rough, Road, DirtRoad, Green, Sand, Pavement
RequiresBuildableArea:
Adjacent: 4
GrantConditionOnLineBuildDirection@X:
Direction: X
Condition: laserfence-direction-x
Expand Down

0 comments on commit a7004b2

Please sign in to comment.