Pick a moveable by the given display position. @function PickMoveableByDisplayPosition @tparam Vec2 position Display space position in percent. @treturn Objects.Moveable Picked moveable (nil if no moveable was found under the cursor). @usage -- Example: Pick a moveable at the center of the screen. local screenCenter = TEN.Vec2(50, 50) local pickedMoveable = TEN.Util.PickMoveableByDisplayPosition(s
| 188 | // print("No moveable found at the center of the screen.") |
| 189 | // end |
| 190 | static sol::optional <std::unique_ptr<Moveable>> PickMoveable(const Vec2& screenPos) |
| 191 | { |
| 192 | auto ray = GetRayFrom2DPosition(PercentToScreen(screenPos)); |
| 193 | |
| 194 | auto vector = Vector3i::Zero; |
| 195 | int itemNumber = ObjectOnLOS2(&ray.first, &ray.second, &vector, nullptr); |
| 196 | |
| 197 | if (itemNumber == NO_LOS_ITEM || itemNumber < 0) |
| 198 | return sol::nullopt; |
| 199 | |
| 200 | return std::make_unique<Moveable>(itemNumber); |
| 201 | } |
| 202 | |
| 203 | /// Pick a static mesh by the given display position. |
| 204 | // @function PickStaticByDisplayPosition |
nothing calls this directly
no test coverage detected