Add a helper for multiplying by sqrt(2)

This commit is contained in:
RoosterDragon
2021-11-14 09:31:34 +00:00
committed by abcdefg30
parent f0e24f6d21
commit a59f4b2c4a
3 changed files with 12 additions and 7 deletions

View File

@@ -226,12 +226,11 @@ namespace OpenRA.Mods.Common.Pathfinder
return PathCostForInvalidPath;
}
int CalculateCellPathCost(CPos neighborCPos, CVec direction, int movementCost)
int CalculateCellPathCost(CPos neighborCPos, CVec direction, short movementCost)
{
var cellCost = movementCost;
if (direction.X * direction.Y != 0)
cellCost = (cellCost * 34) / 24;
var cellCost = direction.X * direction.Y != 0
? Exts.MultiplyBySqrtTwo(movementCost)
: movementCost;
if (CustomCost != null)
{