From a7004b2db797a62f5cb291ff4229b0fe91c40e57 Mon Sep 17 00:00:00 2001 From: Mustafa Alperen Seki Date: Fri, 4 Mar 2022 20:42:37 +0300 Subject: [PATCH] Check for placeablilty of LineBuild Segment instead of the Post. --- .../Orders/PlaceBuildingOrderGenerator.cs | 12 ++++++++++-- OpenRA.Mods.Common/Traits/Buildings/BuildingUtils.cs | 10 +++++++++- mods/ts/rules/nod-support.yaml | 3 +++ 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/OpenRA.Mods.Common/Orders/PlaceBuildingOrderGenerator.cs b/OpenRA.Mods.Common/Orders/PlaceBuildingOrderGenerator.cs index 96f530b9f8..d74c51d4c0 100644 --- a/OpenRA.Mods.Common/Orders/PlaceBuildingOrderGenerator.cs +++ b/OpenRA.Mods.Common/Orders/PlaceBuildingOrderGenerator.cs @@ -263,10 +263,18 @@ namespace OpenRA.Mods.Common.Orders 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(); + } + 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)); } } diff --git a/OpenRA.Mods.Common/Traits/Buildings/BuildingUtils.cs b/OpenRA.Mods.Common/Traits/Buildings/BuildingUtils.cs index 1b0495e77c..da694f05cb 100644 --- a/OpenRA.Mods.Common/Traits/Buildings/BuildingUtils.cs +++ b/OpenRA.Mods.Common/Traits/Buildings/BuildingUtils.cs @@ -112,9 +112,17 @@ namespace OpenRA.Mods.Common.Traits 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(); + } + // 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? diff --git a/mods/ts/rules/nod-support.yaml b/mods/ts/rules/nod-support.yaml index 37ae5a2a2a..991477a952 100644 --- a/mods/ts/rules/nod-support.yaml +++ b/mods/ts/rules/nod-support.yaml @@ -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