0x00478415
| 4507 | |
| 4508 | // 0x00478415 |
| 4509 | static std::optional<GameCommands::VehiclePlacementArgs> getRoadAtCursor(const int16_t x, const int16_t y) |
| 4510 | { |
| 4511 | auto [interaction, viewport] = ViewportInteraction::getMapCoordinatesFromPos(x, y, ~ViewportInteraction::InteractionItemFlags::roadAndTram); |
| 4512 | if (interaction.type != ViewportInteraction::InteractionItem::road) |
| 4513 | { |
| 4514 | return {}; |
| 4515 | } |
| 4516 | |
| 4517 | // Get the best progress along the road relative to the cursor |
| 4518 | auto* roadElement = static_cast<World::RoadElement*>(interaction.object); |
| 4519 | World::Pos3 loc(interaction.pos.x, interaction.pos.y, roadElement->baseHeight()); |
| 4520 | auto progress = getRoadProgressAtCursor({ x, y }, *viewport, *roadElement, loc); |
| 4521 | |
| 4522 | // Get the coordinates of the first tile of the possibly multi-tile road |
| 4523 | const auto& roadDataArr = World::TrackData::getRoadPiece(roadElement->roadId()); |
| 4524 | const auto& roadData = roadDataArr[roadElement->sequenceIndex()]; |
| 4525 | auto roadOffset2 = Math::Vector::rotate(World::Pos2(roadData.x, roadData.y), roadElement->rotation()); |
| 4526 | auto roadOffset = World::Pos3(roadOffset2.x, roadOffset2.y, roadData.z); |
| 4527 | auto roadFirstTile = loc - roadOffset; |
| 4528 | |
| 4529 | GameCommands::VehiclePlacementArgs placementArgs; |
| 4530 | placementArgs.pos = roadFirstTile; |
| 4531 | placementArgs.trackProgress = progress; |
| 4532 | placementArgs.trackAndDirection = roadElement->rotation() | (roadElement->roadId() << 3); |
| 4533 | return { placementArgs }; |
| 4534 | } |
| 4535 | |
| 4536 | // 0x00479707 |
| 4537 | static std::optional<GameCommands::VehiclePlacementArgs> getVehicleRoadPlacementArgsFromCursor(const Vehicles::VehicleHead& head, const int16_t x, const int16_t y) |
no test coverage detected