Fix old shape scaling
This commit is contained in:
@@ -640,14 +640,41 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
|||||||
if (node.Key == "Offset" && parent.Key.StartsWith("WithHarvestOverlay", StringComparison.Ordinal))
|
if (node.Key == "Offset" && parent.Key.StartsWith("WithHarvestOverlay", StringComparison.Ordinal))
|
||||||
RenameNodeKey(node, "LocalOffset");
|
RenameNodeKey(node, "LocalOffset");
|
||||||
|
|
||||||
if (node.Key == "LocalOffset")
|
var gridType = modData.Manifest.Get<MapGrid>().Type;
|
||||||
|
if (gridType == MapGridType.RectangularIsometric)
|
||||||
{
|
{
|
||||||
var orig = FieldLoader.GetValue<WVec[]>(node.Key, node.Value.Value);
|
if (node.Key == "LocalOffset")
|
||||||
var scaled = orig.Select(o => FieldSaver.FormatValue(new WVec(
|
{
|
||||||
(int)Math.Round(Math.Sqrt(2) * o.X),
|
var orig = FieldLoader.GetValue<WVec[]>(node.Key, node.Value.Value);
|
||||||
(int)Math.Round(Math.Sqrt(2) * o.Y),
|
var scaled = orig.Select(o => FieldSaver.FormatValue(new WVec(
|
||||||
(int)Math.Round(Math.Sqrt(2) * o.Z))));
|
(int)Math.Round(Math.Sqrt(2) * o.X),
|
||||||
node.Value.Value = scaled.JoinWith(", ");
|
(int)Math.Round(Math.Sqrt(2) * o.Y),
|
||||||
|
(int)Math.Round(Math.Sqrt(2) * o.Z))));
|
||||||
|
node.Value.Value = scaled.JoinWith(", ");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (node.Key == "Radius" && parent.Key == "Shape")
|
||||||
|
{
|
||||||
|
var orig = FieldLoader.GetValue<WDist>(node.Key, node.Value.Value);
|
||||||
|
var scaled = (int)Math.Round(Math.Sqrt(2) * orig.Length);
|
||||||
|
node.Value.Value = scaled.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (node.Key == "TopLeft" || node.Key == "BottomRight" || node.Key == "PointA" || node.Key == "PointB")
|
||||||
|
{
|
||||||
|
var orig = FieldLoader.GetValue<int2>(node.Key, node.Value.Value);
|
||||||
|
var scaled = new int2(
|
||||||
|
(int)Math.Round(Math.Sqrt(2) * orig.X),
|
||||||
|
(int)Math.Round(Math.Sqrt(2) * orig.Y));
|
||||||
|
node.Value.Value = scaled.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (node.Key == "VerticalTopOffset" || node.Key == "VerticalBottomOffset")
|
||||||
|
{
|
||||||
|
var orig = FieldLoader.GetValue<int>(node.Key, node.Value.Value);
|
||||||
|
var scaled = (int)Math.Round(Math.Sqrt(2) * orig);
|
||||||
|
node.Value.Value = scaled.ToString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user