* @brief Render an object sprite * @param out Output buffer * @param tilePosition dPiece coordinates * @param targetBufferPosition Output buffer coordinates * @param pre Is the sprite in the background */
| 491 | * @param pre Is the sprite in the background |
| 492 | */ |
| 493 | void DrawObject(const Surface &out, Point tilePosition, Point targetBufferPosition, bool pre) |
| 494 | { |
| 495 | if (LightTableIndex >= LightsMax) { |
| 496 | return; |
| 497 | } |
| 498 | |
| 499 | Object *object = FindObjectAtPosition(tilePosition); |
| 500 | if (object == nullptr) { |
| 501 | return; |
| 502 | } |
| 503 | |
| 504 | const Object &objectToDraw = *object; |
| 505 | if (objectToDraw._oPreFlag != pre) { |
| 506 | return; |
| 507 | } |
| 508 | |
| 509 | const ClxSprite sprite = (*objectToDraw._oAnimData)[objectToDraw._oAnimFrame - 1]; |
| 510 | |
| 511 | Point screenPosition = targetBufferPosition - Displacement { CalculateWidth2(sprite.width()), 0 }; |
| 512 | if (objectToDraw.position != tilePosition) { |
| 513 | // drawing a large or offset object, calculate the correct position for the center of the sprite |
| 514 | Displacement worldOffset = objectToDraw.position - tilePosition; |
| 515 | screenPosition -= worldOffset.worldToScreen(); |
| 516 | } |
| 517 | |
| 518 | if (&objectToDraw == ObjectUnderCursor) { |
| 519 | ClxDrawOutlineSkipColorZero(out, 194, screenPosition, sprite); |
| 520 | } |
| 521 | if (objectToDraw.applyLighting) { |
| 522 | ClxDrawLight(out, screenPosition, sprite, LightTableIndex); |
| 523 | } else { |
| 524 | ClxDraw(out, screenPosition, sprite); |
| 525 | } |
| 526 | } |
| 527 | |
| 528 | static void DrawDungeon(const Surface & /*out*/, Point /*tilePosition*/, Point /*targetBufferPosition*/); |
| 529 |
no test coverage detected