diff --git a/OpenRA.Mods.Common/HitShapes/Rectangle.cs b/OpenRA.Mods.Common/HitShapes/Rectangle.cs index 1d854e5d5d..6ea8c9a68b 100644 --- a/OpenRA.Mods.Common/HitShapes/Rectangle.cs +++ b/OpenRA.Mods.Common/HitShapes/Rectangle.cs @@ -33,10 +33,9 @@ namespace OpenRA.Mods.Common.HitShapes [Desc("Defines the bottom offset relative to the actor's target point.")] public readonly int VerticalBottomOffset = 0; - // This is just a temporary work-around until we have a customizable PolygonShape - [Desc("Rotates shape by 90 degree relative to actor facing. Mostly required for buildings on isometric terrain.", + [Desc("Rotates shape by an angle relative to actor facing. Mostly required for buildings on isometric terrain.", "Mobile actors do NOT need this!")] - public readonly bool RotateToIsometry = false; + public readonly WAngle LocalYaw = WAngle.Zero; // This is just a temporary work-around until we have a customizable PolygonShape [Desc("Applies shape to every TargetablePosition instead of just CenterPosition.")] @@ -98,8 +97,7 @@ namespace OpenRA.Mods.Common.HitShapes public WDist DistanceFromEdge(WPos pos, Actor actor) { var actorPos = actor.CenterPosition; - var orientation = new WRot(actor.Orientation.Roll, actor.Orientation.Pitch, - new WAngle(actor.Orientation.Yaw.Angle + (RotateToIsometry ? 128 : 0))); + var orientation = actor.Orientation + WRot.FromYaw(LocalYaw); var targetablePositions = actor.TraitsImplementing(); if (ApplyToAllTargetablePositions && targetablePositions.Any()) @@ -120,8 +118,7 @@ namespace OpenRA.Mods.Common.HitShapes public void DrawCombatOverlay(WorldRenderer wr, RgbaColorRenderer wcr, Actor actor) { var actorPos = actor.CenterPosition; - var orientation = new WRot(actor.Orientation.Roll, actor.Orientation.Pitch, - new WAngle(actor.Orientation.Yaw.Angle + (RotateToIsometry ? 128 : 0))); + var orientation = actor.Orientation + WRot.FromYaw(LocalYaw); var targetablePositions = actor.TraitsImplementing(); if (ApplyToAllTargetablePositions && targetablePositions.Any()) diff --git a/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs b/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs index 20b0ee56e2..6199c126d1 100644 --- a/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs +++ b/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs @@ -651,6 +651,18 @@ namespace OpenRA.Mods.Common.UtilityCommands } } + // Refactor Rectangle shape RotateToIsometry bool into WAngle LocalYaw + if (engineVersion < 20170509) + { + if (node.Key.StartsWith("RotateToIsometry", StringComparison.Ordinal)) + { + var value = FieldLoader.GetValue("RotateToIsometry", node.Value.Value); + node.Value.Value = value ? "128" : "0"; + + node.Key = "LocalYaw"; + } + } + UpgradeActorRules(modData, engineVersion, ref node.Value.Nodes, node, depth + 1); } diff --git a/mods/ts/rules/defaults.yaml b/mods/ts/rules/defaults.yaml index 041dd68759..9bfdc5bca7 100644 --- a/mods/ts/rules/defaults.yaml +++ b/mods/ts/rules/defaults.yaml @@ -284,9 +284,9 @@ ConditionManager: Health: Shape: Rectangle - RotateToIsometry: true - TopLeft: -384, -384 - BottomRight: 384, 384 + LocalYaw: 128 + TopLeft: -512, -512 + BottomRight: 512, 512 VerticalTopOffset: 512 ^BuildingPlug: @@ -899,6 +899,11 @@ Cost: 250 Health: HP: 350 + Shape: Rectangle + LocalYaw: 128 + TopLeft: -512, -512 + BottomRight: 512, 512 + VerticalTopOffset: 640 Armor: Type: Heavy LineBuildNode: @@ -923,6 +928,10 @@ ^Gate_A: Inherits: ^Gate + Health: + Shape: Rectangle + TopLeft: -512, -1536 + BottomRight: 512, 1536 Gate: Dimensions: 3,1 Footprint: xxx @@ -933,6 +942,10 @@ ^Gate_B: Inherits: ^Gate + Health: + Shape: Rectangle + TopLeft: -1536, -512 + BottomRight: 1536, 512 Gate: Dimensions: 1,3 Footprint: x x x