MCPcopy Create free account
hub / github.com/OpenLoco/OpenLoco / paintDocks

Function paintDocks

src/OpenLoco/src/Paint/PaintDocks.cpp:52–103  ·  view source on GitHub ↗

0x0048B86E

Source from the content-addressed store, hash-verified

50
51 // 0x0048B86E
52 void paintDocks(PaintSession& session, const World::StationElement& elStation)
53 {
54 session.setItemType(Ui::ViewportInteraction::InteractionItem::dock);
55
56 auto* dockObj = ObjectManager::get<DockObject>(elStation.objectId());
57
58 const auto companyColour = CompanyManager::getCompanyColour(elStation.owner());
59
60 ImageId baseColour(0, companyColour);
61 if (elStation.isGhost())
62 {
63 session.setItemType(Ui::ViewportInteraction::InteractionItem::noInteraction);
64 baseColour = Gfx::applyGhostToImage(0);
65
66 // TODO: apply company colour if playerCompanyID != elTrack.owner()?s
67 }
68
69 // Combine this with any imageId
70 const auto rotation = (session.getRotation() + elStation.rotation()) & 0x3;
71
72 const int16_t bbLengthZ = std::min(elStation.clearHeight() - elStation.baseHeight(), 128) - 2;
73
74 const auto baseHeight = elStation.baseHeight();
75
76 const auto variation = elStation.buildingType();
77
78 // Note: Image offsets will change as you move up the building but bboffset/size does not
79 const World::Pos3 imageOffset = kImageOffsetBase2x2 + World::Pos3{ 0, 0, baseHeight };
80 const World::Pos3 bbOffset = kBBOffsetBase2x2 + World::Pos3{ 0, 0, baseHeight };
81 const World::Pos3 bbSize = kBBSizeBase2x2 + World::Pos3{ 0, 0, bbLengthZ };
82
83 session.resetLastPS(); // Odd...
84 if (dockObj->hasFlags(DockObjectFlags::hasShadows))
85 {
86 if (session.getRenderTarget()->zoomLevel <= 1)
87 {
88 const auto shadowImageOffset = variation * 4 + dockObj->image + rotation + 1;
89 const ImageId shadowImage = ImageId(shadowImageOffset).withTranslucency(Colours::getShadow(Colour::orange));
90
91 session.addToPlotListAsChild(shadowImage, imageOffset, bbOffset, bbSize);
92 }
93 }
94
95 const auto sequenceIndex = elStation.sequenceIndex();
96 // Only the front of the 2x2 area will draw. Images are sized to overlap into the other tiles.
97 if ((sequenceIndex ^ (1 << 1)) == ((-session.getRotation()) & 0x3))
98 {
99 paintDocksBuilding(session, elStation, *dockObj, imageOffset, bbOffset, bbSize, baseColour, rotation);
100 }
101 session.setSegmentsSupportHeight(SegmentFlags::all, 0xFFFF, 0);
102 session.setGeneralSupportHeight(0xFFFF, 0); // TODO: Check if this works previously would not set slope to zero
103 }
104}

Callers 1

paintStationFunction · 0.85

Calls 15

getCompanyColourFunction · 0.85
applyGhostToImageFunction · 0.85
ImageIdClass · 0.85
getShadowFunction · 0.85
paintDocksBuildingFunction · 0.85
setItemTypeMethod · 0.80
clearHeightMethod · 0.80
baseHeightMethod · 0.80
resetLastPSMethod · 0.80
getRenderTargetMethod · 0.80
withTranslucencyMethod · 0.80
addToPlotListAsChildMethod · 0.80

Tested by

no test coverage detected