MCPcopy Create free account
hub / github.com/OpenRCT2/OpenRCT2 / ViewportUpdateFollowSprite

Function ViewportUpdateFollowSprite

src/openrct2/interface/Viewport.cpp:610–634  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

608 }
609
610 void ViewportUpdateFollowSprite(WindowBase* window)
611 {
612 if (!window->viewportTargetSprite.IsNull() && window->viewport != nullptr)
613 {
614 auto* sprite = getGameState().entities.GetEntity(window->viewportTargetSprite);
615 if (sprite == nullptr)
616 {
617 return;
618 }
619
620 if (gLegacyScene != LegacyScene::titleSequence)
621 {
622 int32_t height = TileElementHeight({ sprite->x, sprite->y }) - 16;
623 int32_t underground = sprite->z < height;
624 ViewportSetUndergroundFlag(underground, window, window->viewport);
625 }
626
627 auto centreLoc = centre2dCoordinates(sprite->getLocation(), window->viewport);
628 if (centreLoc.has_value())
629 {
630 window->savedViewPos = *centreLoc;
631 ViewportMove(*centreLoc, window, window->viewport);
632 }
633 }
634 }
635
636 void ViewportUpdateSmartFollowEntity(WindowBase* window)
637 {

Callers 1

ViewportUpdatePositionFunction · 0.85

Calls 7

TileElementHeightFunction · 0.85
centre2dCoordinatesFunction · 0.85
ViewportMoveFunction · 0.85
getLocationMethod · 0.80
IsNullMethod · 0.45
GetEntityMethod · 0.45

Tested by

no test coverage detected