| 1706 | return true; |
| 1707 | } |
| 1708 | return true; |
| 1709 | } |
| 1710 | |
| 1711 | void AIUnit::CopyPath(const IAIPathPlanner& planner) |
| 1712 | { |
| 1713 | EntityAI* veh = GetVehicle(); |
| 1714 | float combatHeight = veh->GetCombatHeight(); |
| 1715 | |
| 1716 | int planIndex = planner.FindBestIndex(Position()); |
| 1717 | int i, n = planner.GetPlanSize() - planIndex; |
| 1718 | if (planner.GetPlanSize() > 0 && n > 0) |
| 1719 | { |
| 1720 | float sumCost = 0; |
| 1721 | Point3 lastPos = Position(); |
| 1722 | |
| 1723 | _path.Resize(n + 1); |
| 1724 | _path[0]._pos = lastPos; |
| 1725 | _path[0]._cost = sumCost; |
| 1726 | for (i = 0; i < n; i++) |
| 1727 | { |
| 1728 | Point3 pos; |
| 1729 | planner.GetPlanPosition(planIndex + i, pos); |
| 1730 | GeographyInfo geogr = planner.GetGeography(planIndex + i); |
| 1731 | float cost = veh->GetCost(geogr) * veh->GetFieldCost(geogr); |
| 1732 | if (cost >= GET_UNACCESSIBLE) |
| 1733 | { |
| 1734 | cost = 1.0; |
| 1735 | } |
| 1736 | cost *= (pos - lastPos).SizeXZ(); |
| 1737 | sumCost += cost; |
| 1738 | lastPos = GLandscape->PointOnSurface(pos[0], combatHeight, pos[2]); |
| 1739 | _path[i + 1]._pos = lastPos; |
| 1740 | _path[i + 1]._cost = sumCost; |
| 1741 | } |
| 1742 | } |
| 1743 | else |
| 1744 | { |
| 1745 | int x = toIntFloor(Position().X() * InvLandGrid); |
| 1746 | int z = toIntFloor(Position().Z() * InvLandGrid); |
| 1747 | GeographyInfo geogr = GLOB_LAND->GetGeography(x, z); |
| 1748 | float cost = veh->GetCost(geogr) * veh->GetFieldCost(geogr); |
| 1749 | if (cost >= GET_UNACCESSIBLE) |
| 1750 | { |
| 1751 | cost = 1.0; |
| 1752 | } |
| 1753 | cost *= (_expPosition - Position()).SizeXZ(); |
| 1754 | _path.Resize(2); |
| 1755 | _path[0]._pos = Position(); |
| 1756 | _path[0]._cost = 0; |
| 1757 | _path[1]._pos = GLandscape->PointOnSurface(_expPosition[0], combatHeight, _expPosition[2]); |
| 1758 | _path[1]._cost = cost; |
| 1759 | } |
| 1760 | _path.SetMaxIndex(2); |
| 1761 | _path.SetOperIndex(1); |
| 1762 | _path.SetOnRoad(false); |
| 1763 | _path.SetSearchTime(Glob.time); |
| 1764 | } |
no test coverage detected